25 typedef _qCR_TaskPC_t qCR_ExtPosition_t;
29 #define qCR_Position_t static _qCR_TaskPC_t
33 typedef struct _qCR_Instance_s {
45 typedef struct _qCR_Semaphore_s {
53 #define QCR_RESTART ( 0 )
54 #define QCR_POSITION_SET ( 1 )
55 #define QCR_SUSPEND ( 2 )
56 #define QCR_RESUME ( 3 )
74 _qCR_PC_INIT_VAL = -1,
75 _qCR_PC_SUSPENDED_VAL = -2,
83 { _qCR_PC_INIT_VAL, _qCR_UNDEFINED, QSTIMER_INITIALIZER } \
85 #define _qCR_RT( _PT_ ) \
86 case (_qCR_TaskPC_t)(_PT_) : \
88 #define _qCR_JUMP( _DST_ ) switch (_DST_)
90 #define _qCR_LCON( _DST_ , _STATE_, _REST_, _ACTION_ ) \
91 ( _DST_ ) = (_STATE_); \
95 #define _qCR_EXIT goto _qCR_ExitPoint
98 static _qCR_Instance_t _qCRState = _qCR_LCInit; \
99 _qCR_Instance_t * const _qcr = &_qCRState \
108 _qCR_JUMP( _qcr->instr ) { \
109 _qCR_RT( _qCR_PC_INIT_VAL ) \
113 #define _qCR_hStart( handle ) \
115 if ( NULL == (handle) ) { \
116 (handle) = &_qCRState; \
118 _qCR_JUMP( _qcr->instr ) { \
119 default: _qCR_EXIT; \
120 _qCR_RT( _qCR_PC_INIT_VAL ) \
123 #define _qCR_Dispose \
124 _qcr->instr = _qCR_PC_INIT_VAL; \
126 _qCR_ExitPoint: Q_UNUSED(0) \
132 _qCR_LCON( _qcr->instr, __LINE__, _qCR_RT(__LINE__), _qCR_EXIT ); \
137 #define _qCR_Restart \
139 _qCR_LCON( _qcr->instr, _qCR_PC_INIT_VAL, Q_NONE, _qCR_EXIT ); \
144 #define _qCR_wu_Assert( condition ) \
146 _qCR_LCON( _qcr->instr, __LINE__, _qCR_RT(__LINE__), Q_UNUSED(0) ); \
147 if ( !(condition) ) { \
154 #define _qCR_GetPosition( position ) \
156 _qCR_LCON( position, __LINE__, _qCR_RT(__LINE__), Q_UNUSED(0) ); \
157 Q_UNUSED( (position) ); \
162 #define _qCR_RestoreFromPosition( position ) \
164 _qCR_LCON( _qcr->instr, (position), Q_NONE, _qCR_EXIT ); \
169 #define _qCR_Delay( dTime ) \
171 qCR_TimeoutSet( dTime ); \
172 _qCR_LCON( _qcr->instr, __LINE__, _qCR_RT(__LINE__), Q_UNUSED(0) ); \
173 if ( !qCR_TimeoutExpired() ) { \
180 #define _qCR_wu_TmrAssert( condition, timeout ) \
182 qCR_TimeoutSet( timeout ); \
183 _qCR_LCON( _qcr->instr, __LINE__, _qCR_RT(__LINE__), Q_UNUSED(0) ); \
184 if ( !( (condition) || qCR_TimeoutExpired() ) ) { \
193 _qCR_LCON( _qcr->instr, __LINE__, _qCR_RT(__LINE__), Q_UNUSED(0) ); \
197 #define _qCR_until( condition ) \
198 if ( !(condition) ) { \
222 #define qCR_Begin _qCR_Start
241 #define qCR_BeginWithHandle( handle ) _qCR_hStart( handle )
259 #define qCR_End _qCR_Dispose
268 #define qCR_Yield _qCR_Yield
275 #define qCR_Restart _qCR_Restart
288 #define qCR_WaitUntil( bCondition ) _qCR_wu_Assert( bCondition )
303 #define qCR_TimedWaitUntil( bCondition, tValue ) \
304 _qCR_wu_TmrAssert( bCondition, tValue ) \
317 #define qCR_Do _qCR_do
334 #define qCR_Until( bCondition ) _qCR_until( bCondition )
346 #define qCR_SemInit( pSem, sValue ) Q_UNUSED( _qCR_Sem( pSem, sValue ) )
358 #define qCR_SemWait( pSem ) \
359 _qCR_wu_Assert( _qCR_Sem( pSem, _qCR_SEM_TRYLOCK ) ) \
371 #define qCR_SemSignal( pSem ) \
372 Q_UNUSED( _qCR_Sem( pSem, _qCR_SEM_SIGNAL ) ) \
383 #define qCR_PositionGet( p ) _qCR_GetPosition( p )
393 #define qCR_PositionRestore( p ) _qCR_RestoreFromPosition( p )
402 #define qCR_PositionReset( p ) (p) = _qCR_PC_INIT_VAL
410 #define qCR_Delay( tValue ) _qCR_Delay( tValue )
417 #define qCR_TimeoutSet( tValue ) qSTimer_Set( &_qcr->crdelay , tValue )
423 #define qCR_TimeoutExpired( ) qSTimer_Expired( &_qcr->crdelay )
438 const qCR_ExtPosition_t pos );
qBool_t qCR_ExternControl(qCR_Handle_t h, const qCR_ExternAction_t action, const qCR_ExtPosition_t pos)
Perform an external action over the requested Co-routine.
Definition qcoroutine.c:10
qCR_ExternAction_t
An enumeration to define the possible actions that can be performed outside the context of a Co-Routi...
Definition qcoroutine.h:63
_qCR_Instance_t * qCR_Handle_t
A typedef to instantiate a Co-Routine handle.
Definition qcoroutine.h:42
@ qCR_RESUME
Definition qcoroutine.h:67
@ qCR_SUSPEND
Definition qcoroutine.h:66
@ qCR_POSITION_SET
Definition qcoroutine.h:65
@ qCR_RESTART
Definition qcoroutine.h:64
qUINT8_t qBool_t
A type to instantiate an OS boolean variable.
Definition qtypes.h:139
int32_t qINT32_t
Signed integer type with width of exactly 32 bits respectively.
Definition qtypes.h:55
A typedef to instantiate a Co-Routine Semaphore.
Definition qcoroutine.h:45
A STimer(Software Timer) object.
Definition qstimers.h:32