OS  v7.3.3
Documentation
Loading...
Searching...
No Matches
qtasks.h
1
8#ifndef QTASKS_H
9 #define QTASKS_H
10
11 #include "qtypes.h"
12 #include "qstimers.h"
13 #include "qlists.h"
14
15 #if ( Q_QUEUES == 1 )
16 #include "qqueues.h"
17 #endif
18
19 #if ( Q_FSM == 1 )
20 #include "qfsm.h"
21 #endif
22
23 #if ( Q_ATCLI == 1 )
24 #include "qatcli.h"
25 #endif
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
103
106
109
111 #define QMAX_NOTIFICATION_VALUE ( UINT32_MAX - 1UL )
112
124
125 #if ( Q_TASK_EVENT_FLAGS == 1 )
127 /*The task Bit-Flag definitions*/
128 #define QEVENTFLAG_01 ( 0x00001000UL )
129 #define QEVENTFLAG_02 ( 0x00002000UL )
130 #define QEVENTFLAG_03 ( 0x00004000UL )
131 #define QEVENTFLAG_04 ( 0x00008000UL )
132 #define QEVENTFLAG_05 ( 0x00010000UL )
133 #define QEVENTFLAG_06 ( 0x00020000UL )
134 #define QEVENTFLAG_07 ( 0x00040000UL )
135 #define QEVENTFLAG_08 ( 0x00080000UL )
136 #define QEVENTFLAG_09 ( 0x00100000UL )
137 #define QEVENTFLAG_10 ( 0x00200000UL )
138 #define QEVENTFLAG_11 ( 0x00400000UL )
139 #define QEVENTFLAG_12 ( 0x00800000UL )
140 #define QEVENTFLAG_13 ( 0x01000000UL )
141 #define QEVENTFLAG_14 ( 0x02000000UL )
142 #define QEVENTFLAG_15 ( 0x04000000UL )
143 #define QEVENTFLAG_16 ( 0x08000000UL )
144 #define QEVENTFLAG_17 ( 0x10000000UL )
145 #define QEVENTFLAG_18 ( 0x20000000UL )
146 #define QEVENTFLAG_19 ( 0x40000000UL )
147 #define QEVENTFLAG_20 ( 0x80000000UL )
150 #define QEVENTFLAG_CLEAR ( qFalse )
151
153 #define QEVENTFLAG_SET ( qTrue )
154 #endif
155
213 #ifdef DOXYGEN
214 qEvent_t;
215 #else
216 _qEvent_t_/*, *const qEvent_t*/; // skipcq: CXX-E2000
217 typedef const _qEvent_t_ *qEvent_t;
218 #endif
219
223 typedef void (*qTaskFcn_t)( qEvent_t arg );
224
268 typedef struct _qTask_s { /*Task node definition*/ // skipcq: CXX-E2000
270 struct _qTask_Private_s { /*Task control block - TCB*/ // skipcq: CXX-E2000
272 void *taskData, *asyncData;
273 qTaskFcn_t callback;
274 #if ( ( Q_FSM == 1 ) || ( Q_ATCLI == 1 ) )
275 void *aObj;
276 #endif
277 #if ( Q_QUEUES == 1 )
278 qQueue_t *aQueue;
279 qUINT32_t aQueueCount;
280 #endif
281 #if ( Q_ALLOW_TASK_NAMING == 1 )
282 const char *name;
283 #endif
284 qSTimer_t timer;
285 #if ( Q_TASK_COUNT_CYCLES == 1 )
286 qCycles_t cycles;
287 #endif
288 #if ( Q_PRESERVE_TASK_ENTRY_ORDER == 1 )
289 size_t entry; /*< To allow the OS maintain the task entry order. */
290 #endif
291 qIteration_t iterations;
292 volatile qNotifier_t notification;
293 volatile qTask_Flag_t flags;
294 qTrigger_t trigger;
295 qPriority_t priority;
296 }
297 qPrivate;
299 }
300 qTask_t;
301
302 #if ( Q_QUEUES == 1 )
314 #endif
315
333
346
361 void* eventData );
362
380 void* eventData );
381
387 qBool_t qTask_HasPendingNotifications( const qTask_t * const Task );
388
402 qState_t qTask_Get_State( const qTask_t * const Task);
403 #if ( Q_TASK_COUNT_CYCLES == 1 )
410 qCycles_t qTask_Get_Cycles( const qTask_t * const Task );
411 #endif
412
422
430 qBool_t qTask_Set_Time( qTask_t * const Task,
431 const qTime_t tValue );
432
444 const qIteration_t iValue );
445
452 qBool_t qTask_Set_Priority( qTask_t * const Task,
453 const qPriority_t pValue );
454
463 qBool_t qTask_Set_Callback( qTask_t * const Task,
464 const qTaskFcn_t cFcn );
465
485 qBool_t qTask_Set_State( qTask_t * const Task,
486 const qState_t s );
487
494 qBool_t qTask_Set_Data( qTask_t * const Task,
495 void* arg );
496
516 qBool_t qTask_Clear( qTask_t * const Task,
517 const qTask_ClrParam_t param );
518
525 qTask_t* qTask_Self( void );
526
533 #define qTask_Suspend( Task ) qTask_Set_State( (Task), qDisabled )
534
541 #define qTask_Disable( Task ) qTask_Set_State( (Task), qDisabled )
542
549 #define qTask_Resume( Task ) qTask_Set_State( (Task), qEnabled )
550
557 #define qTask_Enable( Task ) qTask_Set_State( (Task), qEnabled )
558
568 #define qTask_ASleep( Task ) qTask_Set_State( (Task), qAsleep )
569
577 #define qTask_Awake( Task ) qTask_Set_State( (Task), qAwake )
578
585 #define qTask_IsEnabled( Task ) ( qEnabled == qTask_Get_State( (Task) ) )
586
589 #if ( Q_QUEUES == 1 )
624 qBool_t qTask_Attach_Queue( qTask_t * const Task,
625 qQueue_t * const q,
626 const qQueueLinkMode_t mode,
627 const qUINT16_t arg );
628
630 #endif /*Q_QUEUES*/
631
632
633 #if ( Q_TASK_EVENT_FLAGS == 1 )
649 const qTask_Flag_t flags,
650 const qBool_t action );
651
657 qTask_Flag_t qTask_EventFlags_Read( const qTask_t * const Task );
658
684 qTask_Flag_t flagsToCheck,
685 const qBool_t clearOnExit,
686 const qBool_t checkForAll );
687
689 #endif /*Q_TASK_EVENT_FLAGS*/
690
691 #if ( Q_ALLOW_TASK_NAMING == 1 )
703 qBool_t qTask_Set_Name( qTask_t * const Task,
704 const char *name );
705
711 const char *qTask_Get_Name( const qTask_t * const Task );
712
718 qTask_t* qTask_Find_ByName( const char *name );
719
721 #endif /*Q_ALLOW_TASK_NAMING*/
722
723 #ifdef __cplusplus
724 }
725 #endif
726
727#endif /* QTASKS_H */
qUINT32_t qClock_t
A 32-bit unsigned integer to hold ticks count. Epochs counter.
Definition qclock.h:66
qFloat32_t qTime_t
The typedef that specified an time quantity, usually expressed in seconds.
Definition qclock.h:33
qBool_t qTask_EventFlags_Modify(qTask_t *const Task, const qTask_Flag_t flags, const qBool_t action)
Modify the EventFlags for the provided task.
Definition qtasks.c:277
qTask_Flag_t qTask_EventFlags_Read(const qTask_t *const Task)
Returns the current value of the task's EventFlags.
Definition qtasks.c:292
qBool_t qTask_EventFlags_Check(qTask_t *const Task, qTask_Flag_t flagsToCheck, const qBool_t clearOnExit, const qBool_t checkForAll)
Check for flags set to qTrue inside the task Event-Flags.
Definition qtasks.c:303
#define qNode_MinimalFields
This macro can be used to create custom data that can be used as node of a list. User should locate t...
Definition qlists.h:79
qTask_ClrParam_t
An enum that defines the parameters than can be cleared for a task.
Definition qtasks.h:337
qBool_t qTask_HasPendingNotifications(const qTask_t *const Task)
Check if the task has pending notifications.
Definition qtasks.c:45
qTask_NotifyMode_t
An enum that defines the modes in which a notification can be spread.
Definition qtasks.h:327
qBool_t qTask_Notification_Queue(qTask_t *const Task, void *eventData)
Insert a notification in the FIFO priority queue. The scheduler get this notification as an asynchron...
Definition qtasks.c:31
qBool_t qTask_Notification_Send(qTask_t *const Task, void *eventData)
Sends a simple notification generating an asynchronous event. This method marks the task as ready for...
Definition qtasks.c:12
@ qTask_ClearSimpleNotifications
Definition qtasks.h:341
@ qTask_ClearCycles
Definition qtasks.h:340
@ qTask_ClearNotifications
Definition qtasks.h:343
@ qTask_ClearIterations
Definition qtasks.h:338
@ qTask_ClearTimeElapsed
Definition qtasks.h:339
@ qTask_ClearQueuedNotifications
Definition qtasks.h:342
@ qTask_NotifyQueued
Definition qtasks.h:330
@ qTask_NotifySimple
Definition qtasks.h:329
@ qTask_NotifyNULL
Definition qtasks.h:328
qBool_t qTask_Attach_Queue(qTask_t *const Task, qQueue_t *const q, const qQueueLinkMode_t mode, const qUINT16_t arg)
Attach a Queue to the Task.
Definition qtasks.c:251
qCycles_t qTask_Get_Cycles(const qTask_t *const Task)
Retrieve the number of task activations.
Definition qtasks.c:78
qState_t qTask_Get_State(const qTask_t *const Task)
Retrieve the task operational state.
Definition qtasks.c:63
qBool_t qTask_Set_Time(qTask_t *const Task, const qTime_t tValue)
Set/Change the Task execution interval.
Definition qtasks.c:95
qBool_t qTask_Set_Priority(qTask_t *const Task, const qPriority_t pValue)
Set/Change the task priority value.
Definition qtasks.c:128
qTask_GlobalState_t
An enum to describe the task global states.
Definition qtasks.h:116
qTask_t * qTask_Find_ByName(const char *name)
Tries to find the first task that matches the name provided.
Definition qtasks.c:361
void(* qTaskFcn_t)(qEvent_t arg)
Pointer to a task callback.
Definition qtasks.h:223
qBool_t qTask_Clear(qTask_t *const Task, const qTask_ClrParam_t param)
Clear the specified parameter for the task.
Definition qtasks.c:200
qBool_t qTask_Set_State(qTask_t *const Task, const qState_t s)
Set the task operational state.
Definition qtasks.c:157
qBool_t qTask_Set_Name(qTask_t *const Task, const char *name)
Set the task name.
Definition qtasks.c:335
qQueueLinkMode_t
An enum that defines the modes in which a queue can be linked to a task.
Definition qtasks.h:307
qUINT32_t qNotifier_t
A 32-bit unsigned integer type to hold a notification value.
Definition qtasks.h:105
qTask_t * qTask_Self(void)
Get the current running-task handle.
Definition qtasks.c:245
qBool_t qTask_Set_Callback(qTask_t *const Task, const qTaskFcn_t cFcn)
Set/Change the task callback function.
Definition qtasks.c:141
const char * qTask_Get_Name(const qTask_t *const Task)
Retrieves the task name.
Definition qtasks.c:350
qUINT32_t qTask_Flag_t
A 32-bit unsigned integer type to hold the task flags.
Definition qtasks.h:108
qBool_t qTask_Set_Iterations(qTask_t *const Task, const qIteration_t iValue)
Set/Change the number of task iterations.
Definition qtasks.c:106
qBool_t qTask_Set_Data(qTask_t *const Task, void *arg)
Set the task data.
Definition qtasks.c:187
qTrigger_t
An enum with all the possible values for the qEvent_t::Trigger member.
Definition qtasks.h:43
qTask_GlobalState_t qTask_Get_GlobalState(const qTask_t *const Task)
Retrieve the task global-state.
Definition qtasks.c:90
@ qSuspended
Definition qtasks.h:120
@ qUndefinedGlobalState
Definition qtasks.h:117
@ qReady
Definition qtasks.h:118
@ qRunning
Definition qtasks.h:121
@ qWaiting
Definition qtasks.h:119
@ qQueueMode_Count
Definition qtasks.h:310
@ qQueueMode_Empty
Definition qtasks.h:311
@ qQueueMode_Full
Definition qtasks.h:309
@ qQueueMode_Receiver
Definition qtasks.h:308
@ byEventFlags
When any event-flag is set.
Definition qtasks.h:92
@ byQueueEmpty
When the attached queue is empty. A pointer to the queue will be available in the qEvent_t::EventData...
Definition qtasks.h:88
@ qTriggerNULL
To indicate the absence of trigger. Reserved for internal use.
Definition qtasks.h:47
@ byQueueFull
When the attached queue is full. A pointer to the queue will be available in the qEvent_t::EventData ...
Definition qtasks.h:77
@ byQueueReceiver
When there are elements available in the attached qQueue, the scheduler make a data dequeue (auto-rec...
Definition qtasks.h:72
@ byNotificationQueued
When there is a queued notification in the FIFO priority queue. For this trigger, the dispatcher perf...
Definition qtasks.h:58
@ byNoReadyTasks
Only available when the Idle Task is triggered.
Definition qtasks.h:100
@ byQueueCount
When the element-count of the attached queue reaches the specified value. A pointer to the queue will...
Definition qtasks.h:83
@ byNotificationSimple
When the execution chain does, according to a requirement of asynchronous notification event prompted...
Definition qtasks.h:65
@ bySchedulingRelease
When the scheduler is released.
Definition qtasks.h:96
@ byTimeElapsed
When the time specified for the task elapsed.
Definition qtasks.h:51
qUINT32_t qCycles_t
A type to instantiate a variable that hold the number of task cycles.
Definition qtypes.h:152
qUINT8_t qBool_t
A type to instantiate an OS boolean variable.
Definition qtypes.h:139
qINT32_t qIteration_t
A type to instantiate a variable that hold the number of task iterations.
Definition qtypes.h:129
qUINT8_t qState_t
A type to instantiate an OS state value.
Definition qtypes.h:134
uint32_t qUINT32_t
Unsigned integer type with width of exactly 32 bits respectively.
Definition qtypes.h:48
uint16_t qUINT16_t
Unsigned integer type with width of exactly 16 bits respectively.
Definition qtypes.h:46
qUINT8_t qPriority_t
A type to instantiate a variable to hold the priority value of a task.
Definition qtypes.h:123
The task argument with all the regarding information of the task execution.
Definition qtasks.h:162
void * TaskData
Task arguments defined at the time of its creation. (Storage-Pointer)
Definition qtasks.h:167
qTrigger_t Trigger
This member indicates the event source that triggers the task execution. Possible values are describe...
Definition qtasks.h:180
qBool_t FirstIteration
Indicates whether current pass is the first iteration of the task. This flag will be only set when ti...
Definition qtasks.h:193
void * EventData
Associated data of the event. Specific data will reside here according to the event source....
Definition qtasks.h:174
qBool_t FirstCall
This field indicates that a task is running for the first time. Can be used for data initialization p...
Definition qtasks.h:185
qClock_t StartDelay
The number of epochs between current system time and point in time when the task was marked as Ready....
Definition qtasks.h:211
qBool_t LastIteration
Indicates whether current pass is the last iteration of the task. This flag will be only set when tim...
Definition qtasks.h:201
A Queue object.
Definition qqueues.h:53
A STimer(Software Timer) object.
Definition qstimers.h:32
A task node object.
Definition qtasks.h:268