SAM4S-EK_FreeRTOS+FAT-SL  1.0
An example project to test the functionality of FreeRTOS+FAT-SL using SD card as data storage medium
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
croutine.h
Go to the documentation of this file.
1 /*
2  FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.
3  All rights reserved
4 
5  VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7  ***************************************************************************
8  * *
9  * FreeRTOS provides completely free yet professionally developed, *
10  * robust, strictly quality controlled, supported, and cross *
11  * platform software that has become a de facto standard. *
12  * *
13  * Help yourself get started quickly and support the FreeRTOS *
14  * project by purchasing a FreeRTOS tutorial book, reference *
15  * manual, or both from: http://www.FreeRTOS.org/Documentation *
16  * *
17  * Thank you! *
18  * *
19  ***************************************************************************
20 
21  This file is part of the FreeRTOS distribution.
22 
23  FreeRTOS is free software; you can redistribute it and/or modify it under
24  the terms of the GNU General Public License (version 2) as published by the
25  Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
26 
27  >>! NOTE: The modification to the GPL is included to allow you to !<<
28  >>! distribute a combined work that includes FreeRTOS without being !<<
29  >>! obliged to provide the source code for proprietary components !<<
30  >>! outside of the FreeRTOS kernel. !<<
31 
32  FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
33  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34  FOR A PARTICULAR PURPOSE. Full license text is available from the following
35  link: http://www.freertos.org/a00114.html
36 
37  1 tab == 4 spaces!
38 
39  ***************************************************************************
40  * *
41  * Having a problem? Start by reading the FAQ "My application does *
42  * not run, what could be wrong?" *
43  * *
44  * http://www.FreeRTOS.org/FAQHelp.html *
45  * *
46  ***************************************************************************
47 
48  http://www.FreeRTOS.org - Documentation, books, training, latest versions,
49  license and Real Time Engineers Ltd. contact details.
50 
51  http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
52  including FreeRTOS+Trace - an indispensable productivity tool, a DOS
53  compatible FAT file system, and our tiny thread aware UDP/IP stack.
54 
55  http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
56  Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
57  licenses offer ticketed support, indemnification and middleware.
58 
59  http://www.SafeRTOS.com - High Integrity Systems also provide a safety
60  engineered and independently SIL3 certified version for use in safety and
61  mission critical applications that require provable dependability.
62 
63  1 tab == 4 spaces!
64 */
65 
66 #ifndef CO_ROUTINE_H
67 #define CO_ROUTINE_H
68 
69 #ifndef INC_FREERTOS_H
70  #error "include FreeRTOS.h must appear in source files before include croutine.h"
71 #endif
72 
73 #include "list.h"
74 
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78 
79 /* Used to hide the implementation of the co-routine control block. The
80 control block structure however has to be included in the header due to
81 the macro implementation of the co-routine functionality. */
82 typedef void * CoRoutineHandle_t;
83 
84 /* Defines the prototype to which co-routine functions must conform. */
86 
88 {
90  ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */
91  ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */
92  UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */
93  UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */
94  uint16_t uxState; /*< Used internally by the co-routine implementation. */
95 } CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */
96 
169 BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex );
170 
171 
211 void vCoRoutineSchedule( void );
212 
242 #define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0:
243 
273 #define crEND() }
274 
275 /*
276  * These macros are intended for internal use by the co-routine implementation
277  * only. The macros should not be used directly by application writers.
278  */
279 #define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):
280 #define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):
281 
328 #define crDELAY( xHandle, xTicksToDelay ) \
329  if( ( xTicksToDelay ) > 0 ) \
330  { \
331  vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \
332  } \
333  crSET_STATE0( ( xHandle ) );
334 
418 #define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
419 { \
420  *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \
421  if( *( pxResult ) == errQUEUE_BLOCKED ) \
422  { \
423  crSET_STATE0( ( xHandle ) ); \
424  *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \
425  } \
426  if( *pxResult == errQUEUE_YIELD ) \
427  { \
428  crSET_STATE1( ( xHandle ) ); \
429  *pxResult = pdPASS; \
430  } \
431 }
432 
510 #define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
511 { \
512  *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \
513  if( *( pxResult ) == errQUEUE_BLOCKED ) \
514  { \
515  crSET_STATE0( ( xHandle ) ); \
516  *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \
517  } \
518  if( *( pxResult ) == errQUEUE_YIELD ) \
519  { \
520  crSET_STATE1( ( xHandle ) ); \
521  *( pxResult ) = pdPASS; \
522  } \
523 }
524 
619 #define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )
620 
621 
732 #define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )
733 
734 /*
735  * This function is intended for internal use by the co-routine macros only.
736  * The macro nature of the co-routine implementation requires that the
737  * prototype appears here. The function should not be used by application
738  * writers.
739  *
740  * Removes the current co-routine from its ready list and places it in the
741  * appropriate delayed list.
742  */
743 void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList );
744 
745 /*
746  * This function is intended for internal use by the queue implementation only.
747  * The function should not be used by application writers.
748  *
749  * Removes the highest priority co-routine from the event list and places it in
750  * the pending ready list.
751  */
752 BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList );
753 
754 #ifdef __cplusplus
755 }
756 #endif
757 
758 #endif /* CO_ROUTINE_H */
BaseType_t xCoRoutineCreate(crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex)
Definition: croutine.c:137
void(* crCOROUTINE_CODE)(CoRoutineHandle_t, UBaseType_t)
Definition: croutine.h:85
crCOROUTINE_CODE pxCoRoutineFunction
Definition: croutine.h:89
unsigned long UBaseType_t
Definition: portmacro.h:95
uint32_t TickType_t
Definition: portmacro.h:101
UBaseType_t uxIndex
Definition: croutine.h:93
ListItem_t xEventListItem
Definition: croutine.h:91
long BaseType_t
Definition: portmacro.h:94
void vCoRoutineSchedule(void)
Definition: croutine.c:313
void vCoRoutineAddToDelayedList(TickType_t xTicksToDelay, List_t *pxEventList)
Definition: croutine.c:194
void * CoRoutineHandle_t
Definition: croutine.h:82
BaseType_t xCoRoutineRemoveFromEventList(const List_t *pxEventList)
Definition: croutine.c:363
UBaseType_t uxPriority
Definition: croutine.h:92
ListItem_t xGenericListItem
Definition: croutine.h:90
Definition: list.h:157
struct corCoRoutineControlBlock CRCB_t