cocoOS
5.0.1
|
#include "cocoos.h"
Go to the source code of this file.
Macros | |
#define | task_open() OS_BEGIN |
#define | task_close() OS_END |
#define | task_wait(x) OS_WAIT_TICKS(x,0) |
#define | task_wait_id(id, x) OS_WAIT_TICKS(x,id) |
#define | task_suspend(id) OS_SUSPEND_TASK( id ) |
#define | task_resume(id) OS_RESUME_TASK( id ) |
#define | event_wait(event) OS_WAIT_SINGLE_EVENT(event,0) |
#define | event_wait_timeout(event, timeout) OS_WAIT_SINGLE_EVENT(event,timeout) |
#define | event_get_timeout() OS_GET_TASK_TIMEOUT_VALUE() |
#define | event_wait_multiple(waitAll, args...) OS_WAIT_MULTIPLE_EVENTS( waitAll, args) |
#define | event_signal(event) OS_SIGNAL_EVENT(event) |
#define | event_ISR_signal(event) OS_INT_SIGNAL_EVENT(event) |
#define | sem_wait(sem) OS_WAIT_SEM(sem) |
#define | sem_signal(sem) OS_SIGNAL_SEM(sem) |
#define | sem_ISR_signal(sem) OS_SIGNAL_SEM_NO_SCHEDULE(sem) |
#define | msg_post(task_id, msg) OS_MSG_Q_POST(task_id, msg, 0, 0, 0) |
#define | msg_post_async(task_id, msg) OS_MSG_Q_POST(task_id, msg, 0, 0, 1) |
#define | msg_post_in(task_id, msg, delay) OS_MSG_Q_POST(task_id, msg, delay, 0, 0) |
#define | msg_post_every(task_id, msg, period) OS_MSG_Q_POST(task_id, msg, period, period, 0) |
#define | msg_receive(task_id, pMsg) OS_MSG_Q_RECEIVE( task_id, pMsg, 0 ) |
#define | msg_receive_async(task_id, pMsg) OS_MSG_Q_RECEIVE( task_id, pMsg, 1 ) |
Functions | |
void | os_init (void) |
void | os_start (void) |
void | os_tick (void) |
void | os_sub_tick (uint8_t id) |
void | os_sub_nTick (uint8_t id, uint16_t nTicks) |
uint8_t | os_get_running_tid (void) |
uint8_t | task_create (taskproctype taskproc, void *data, uint8_t prio, Msg_t *msgPool, uint8_t poolSize, uint16_t msgSize) |
void | task_kill (uint8_t tid) |
void * | task_get_data () |
Sem_t | sem_bin_create (uint8_t initial) |
Sem_t | sem_counting_create (uint8_t max, uint8_t initial) |
Evt_t | event_create (void) |
uint8_t | event_signaling_taskId_get (Evt_t ev) |
TaskState_t | task_state_get (uint8_t tid) |
void | os_cbkSleep (void) |
cocoOS API header file
#define event_get_timeout | ( | ) | OS_GET_TASK_TIMEOUT_VALUE() |
Get the timeout value from the task when we wait for an event with timeout. That way we know if this is due to a timeout (value == 0) or actual event (value != 0)
#define event_ISR_signal | ( | event | ) | OS_INT_SIGNAL_EVENT(event) |
#define event_signal | ( | event | ) | OS_SIGNAL_EVENT(event) |
#define event_wait | ( | event | ) | OS_WAIT_SINGLE_EVENT(event,0) |
#define event_wait_multiple | ( | waitAll, | |
args... | |||
) | OS_WAIT_MULTIPLE_EVENTS( waitAll, args) |
Macro for wait for multiple events.
waitAll | 1 if wait for all, 0 if wait for any event |
args | list of Evt_t type events |
#define event_wait_timeout | ( | event, | |
timeout | |||
) | OS_WAIT_SINGLE_EVENT(event,timeout) |
Macro for wait for a single event to be signaled or a timeout to occur.
event | the event to wait for |
timeout | maximum wait time in main clock ticks, 16bit value. If timeout = 0, no timeout will be used, and the task will wait forever until the event is signaled. |
#define msg_post | ( | task_id, | |
msg | |||
) | OS_MSG_Q_POST(task_id, msg, 0, 0, 0) |
Posts a message to the message queue of a task.
task_id | id of the task that will receive the message |
msg | the message to post |
#define msg_post_async | ( | task_id, | |
msg | |||
) | OS_MSG_Q_POST(task_id, msg, 0, 0, 1) |
Posts a message to the message queue of a task. If the queue is full, the message is not posted and the task continues execution, i.e. it will not wait for the queue to be non-full.
task_id | id of the task that will receive the message |
msg | the message to post |
#define msg_post_every | ( | task_id, | |
msg, | |||
period | |||
) | OS_MSG_Q_POST(task_id, msg, period, period, 0) |
Posts a periodic message to the message queue of a task. The message will be delivered to the receiver task each time the timer expires. The period is related to the master clock.
task_id | id of the task that will receive the message |
msg | the message to post |
period | period time in master clock ticks |
#define msg_post_in | ( | task_id, | |
msg, | |||
delay | |||
) | OS_MSG_Q_POST(task_id, msg, delay, 0, 0) |
Posts a message to the message queue of a task. The message will be received by the receiver task when the delay has expired. The delay is related to the master clock.
task_id | id of the task that will receive the message |
msg | the message to post |
delay | post delay time in master clock ticks |
#define msg_receive | ( | task_id, | |
pMsg | |||
) | OS_MSG_Q_RECEIVE( task_id, pMsg, 0 ) |
Receives a message from the queue
task_id | id of the current task |
pMsg | pointer to a message that will receive a message from the queue |
#define msg_receive_async | ( | task_id, | |
pMsg | |||
) | OS_MSG_Q_RECEIVE( task_id, pMsg, 1 ) |
Receives a message from the queue but returns immediately if queue is empty.
task_id | id of the current task |
pMsg | pointer to a message that will receive a message from the queue. If queue is empty, the signal member of the message pointed at by pMsg will be set to NO_MSG_ID. |
#define sem_ISR_signal | ( | sem | ) | OS_SIGNAL_SEM_NO_SCHEDULE(sem) |
Macro for releasing a semaphore from within an ISR. The semaphore is signalled and waiting tasks will be set to ready state, but scheduling will not be done. Scheduling will be performed when the ISR has finished and the interrupted task calls a scheduling function.
sem | Semaphore. |
#define sem_signal | ( | sem | ) | OS_SIGNAL_SEM(sem) |
#define sem_wait | ( | sem | ) | OS_WAIT_SEM(sem) |
#define task_close | ( | ) | OS_END |
#define task_open | ( | ) | OS_BEGIN |
#define task_resume | ( | id | ) | OS_RESUME_TASK( id ) |
Macro for resuming a task
id | of the task to resume |
#define task_suspend | ( | id | ) | OS_SUSPEND_TASK( id ) |
Macro for suspending a task
id | of the task to suspend |
#define task_wait | ( | x | ) | OS_WAIT_TICKS(x,0) |
Macro for suspending a task a specified amount of ticks of the master clock. When the wait time has expired, the task is ready to execute again and will continue at the next statement when the task is scheduled to run.
x | Number of master clock ticks to wait. |
#define task_wait_id | ( | id, | |
x | |||
) | OS_WAIT_TICKS(x,id) |
Macro for suspending a task a specified amount of ticks of a sub clock. When the wait time has expired, the task is ready to execute again and will continue at the next statement when the task is scheduled to run.
id | Sub clock id. Valid range 1-255. |
x | Number of sub clock ticks to wait, 16 bit value. |
Evt_t event_create | ( | void | ) |
Creates an event.
uint8_t event_signaling_taskId_get | ( | Evt_t | ev | ) |
Gets the Task Id of the task that signaled the event.
ev | event |
void os_cbkSleep | ( | void | ) |
Callback called by the os kernel when all tasks are in waiting state. Here you can put the MCU to low power mode. Remember to keep the clock running so we can wake up from sleep.
void os_init | ( | void | ) |
void os_start | ( | void | ) |
void os_sub_nTick | ( | uint8_t | id, |
uint16_t | nTicks | ||
) |
Tick function driving the sub clocks. Increments the tick count with nTicks.
id | sub clock id, allowed range 1-255. |
nTicks | increment size, 16 bit value. |
void os_sub_tick | ( | uint8_t | id | ) |
void os_tick | ( | void | ) |
Sem_t sem_bin_create | ( | uint8_t | initial | ) |
Creates and initializes a new binary semaphore.
initial | value of the semaphore |
Sem_t sem_counting_create | ( | uint8_t | max, |
uint8_t | initial | ||
) |
Creates and initializes a new counting semaphore.
max | value of the semaphore |
initial | value of the semaphore |
uint8_t task_create | ( | taskproctype | taskproc, |
void * | data, | ||
uint8_t | prio, | ||
Msg_t * | msgPool, | ||
uint8_t | poolSize, | ||
uint16_t | msgSize | ||
) |
Creates a task scheduled by the os. The task is put in the ready state.
taskproc | Function pointer to the task procedure. |
data | [optional] Pointer to task data |
prio | Task priority on a scale 0-255 where 0 is the highest priority. |
msgPool | [optional] Pointer to the message pool, containing messages. Ignored if poolSize is 0. |
poolSize | [optional] Size, in nr of messages, of the message pool. Set to 0 if no message pool needed for the task |
msgSize | [optional] Size of the message type held in the message queue |
void* task_get_data | ( | ) |
Gets a pointer to the data structure associated with the task
void task_kill | ( | uint8_t | tid | ) |
Puts the task associated with the specified id in the killed state. A killed task, cannot be resumed.
task_id | id of the task. |