croutine.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Kernel V10.0.0
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software. If you wish to use our Amazon
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * http://www.FreeRTOS.org
24  * http://aws.amazon.com/freertos
25  *
26  * 1 tab == 4 spaces!
27  */
28 
29 #ifndef CO_ROUTINE_H
30 #define CO_ROUTINE_H
31 
32 #ifndef INC_FREERTOS_H
33  #error "include FreeRTOS.h must appear in source files before include croutine.h"
34 #endif
35 
36 #include "list.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 /* Used to hide the implementation of the co-routine control block. The
43 control block structure however has to be included in the header due to
44 the macro implementation of the co-routine functionality. */
45 typedef void * CoRoutineHandle_t;
46 
47 /* Defines the prototype to which co-routine functions must conform. */
49 
51 {
53  ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */
54  ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */
55  UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */
56  UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */
57  uint16_t uxState; /*< Used internally by the co-routine implementation. */
58 } CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */
59 
133 
134 
174 void vCoRoutineSchedule( void );
175 
205 #define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0:
206 
236 #define crEND() }
237 
238 /*
239  * These macros are intended for internal use by the co-routine implementation
240  * only. The macros should not be used directly by application writers.
241  */
242 #define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):
243 #define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):
244 
291 #define crDELAY( xHandle, xTicksToDelay ) \
292  if( ( xTicksToDelay ) > 0 ) \
293  { \
294  vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \
295  } \
296  crSET_STATE0( ( xHandle ) );
297 
381 #define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
382 { \
383  *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \
384  if( *( pxResult ) == errQUEUE_BLOCKED ) \
385  { \
386  crSET_STATE0( ( xHandle ) ); \
387  *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \
388  } \
389  if( *pxResult == errQUEUE_YIELD ) \
390  { \
391  crSET_STATE1( ( xHandle ) ); \
392  *pxResult = pdPASS; \
393  } \
394 }
395 
473 #define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
474 { \
475  *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \
476  if( *( pxResult ) == errQUEUE_BLOCKED ) \
477  { \
478  crSET_STATE0( ( xHandle ) ); \
479  *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \
480  } \
481  if( *( pxResult ) == errQUEUE_YIELD ) \
482  { \
483  crSET_STATE1( ( xHandle ) ); \
484  *( pxResult ) = pdPASS; \
485  } \
486 }
487 
582 #define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )
583 
584 
695 #define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )
696 
697 /*
698  * This function is intended for internal use by the co-routine macros only.
699  * The macro nature of the co-routine implementation requires that the
700  * prototype appears here. The function should not be used by application
701  * writers.
702  *
703  * Removes the current co-routine from its ready list and places it in the
704  * appropriate delayed list.
705  */
706 void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList );
707 
708 /*
709  * This function is intended for internal use by the queue implementation only.
710  * The function should not be used by application writers.
711  *
712  * Removes the highest priority co-routine from the event list and places it in
713  * the pending ready list.
714  */
715 BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList );
716 
717 #ifdef __cplusplus
718 }
719 #endif
720 
721 #endif /* CO_ROUTINE_H */
Definition: list.h:164
ListItem_t xEventListItem
Definition: croutine.h:54
BaseType_t xCoRoutineCreate(crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex)
unsigned long UBaseType_t
Definition: portmacro.h:58
uint32_t TickType_t
Definition: portmacro.h:64
long BaseType_t
Definition: portmacro.h:57
void vCoRoutineSchedule(void)
void vCoRoutineAddToDelayedList(TickType_t xTicksToDelay, List_t *pxEventList)
void * CoRoutineHandle_t
Definition: croutine.h:45
UBaseType_t uxIndex
Definition: croutine.h:56
BaseType_t xCoRoutineRemoveFromEventList(const List_t *pxEventList)
crCOROUTINE_CODE pxCoRoutineFunction
Definition: croutine.h:52
ListItem_t xGenericListItem
Definition: croutine.h:53
void(* crCOROUTINE_CODE)(CoRoutineHandle_t, UBaseType_t)
Definition: croutine.h:48
struct corCoRoutineControlBlock CRCB_t
UBaseType_t uxPriority
Definition: croutine.h:55


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:04