Class TaskAPI
#include <TaskAPI.h>
Public Functions
Type | Name |
---|---|
int8_t | createBackground (task_function_t routine) Creates a background task. Background tasks are asynchronous tasks that run in the background when there is no critical task running. |
int8_t | createCritical (task_function_t periodic_task, uint32_t task_period_us, scheduling_interrupt_source_t int_source=source_hrtim) Creates a time critical task. |
void | startBackground (uint8_t task_number) Use this function to start a previously defined background task using its task number. |
void | startCritical (bool manage_data_acquisition=true) Use this function to start a previously defined a critical task. |
void | stopBackground (uint8_t task_number) Use this function to stop a previously started background task using its task number. |
void | stopCritical () Stop the previously started critical task. A critical task is an Uninterruptible Synchronous Task that uses a precise timer to execute a periodic, non-interruptable user task. The task can be then resumed by calling startCritical() again. |
void | suspendBackgroundMs (uint32_t duration_ms) This function allows to suspend a background task for a specified duration expressed in milliseconds. For example, you can call this function at the end of a background task function, when there is no need for the task to run permanently. |
void | suspendBackgroundUs (uint32_t duration_us) This function allows to suspend a background task for a specified duration expressed in microseconds. For example, you can call this function at the end of a background task function, when there is no need for the task to run permanently. |
Detailed Description
Static class definition
Public Functions Documentation
function createBackground
Creates a background task. Background tasks are asynchronous tasks that run in the background when there is no critical task running.
Parameters:
routine
Pointer to the void(void) function that will act as the task main function.
Returns:
Number assigned to the task. Will be -1 if max number of asynchronous task has been reached. In such a case, the task definition is ignored. Increase maximum number of asynchronous tasks in prj.conf if required.
function createCritical
Creates a time critical task.
int8_t TaskAPI::createCritical (
task_function_t periodic_task,
uint32_t task_period_us,
scheduling_interrupt_source_t int_source=source_hrtim
)
Note:
If the HRTIM
is used to trigger the task (which is the default behavior), then the HRTIM
must have been configured before calling this function.
Parameters:
periodic_task
Pointer to the void(void) function to be executed periodically.task_period_us
Period of the function in µs. Allowed range: 1 to 6553 µs. If interrupt source isHRTIM
, this value must be an integer multiple of theHRTIM
period.int_source
Interrupt source that triggers the task. By default, theHRTIM
is the source, but this optional parameter can be provided to set TIM6 as the source in case theHRTIM
is not used or if the task can't be correlated to anHRTIM
event. Allowed values are source_hrtim and source_tim6.
Returns:
0
if everything went well, -1
if there was an error defining the task.
An error can occur notably when an uninterruptible task has already been defined previously.
function startBackground
Use this function to start a previously defined background task using its task number.
Background tasks are asynchronous tasks that run in the background when there is no critical task running.
Parameters:
task_number
Number of the task to start, obtained using the defineAsynchronousTask() function.
function startCritical
Use this function to start a previously defined a critical task.
A critical task is an Uninterruptible Synchronous Task that uses a precise timer to execute a periodic, non-interruptable user task.
If no value is provided for the parameter and Data Acquisition has not been started yet, Scheduling will automatically start Data Acquisition. Thus, make sure all ADC configuration has been carried out before starting the uninterruptible task.
Parameters:
manage_data_acquisition
Set to false if you want the Scheduling module to not be in charge of Data Acquisition scheduling. If set to false, Data Acquisition has to be manually started if you want to use it.
function stopBackground
Use this function to stop a previously started background task using its task number.
Background tasks are asynchronous tasks that run in the background when there is no critical task running. The task can be then resumed by calling startAsynchronousTask() again.
Parameters:
task_number
Number of the task to start, obtained using the defineAsynchronousTask() function.
function stopCritical
Stop the previously started critical task. A critical task is an Uninterruptible Synchronous Task that uses a precise timer to execute a periodic, non-interruptable user task. The task can be then resumed by calling startCritical() again.
function suspendBackgroundMs
This function allows to suspend a background task for a specified duration expressed in milliseconds. For example, you can call this function at the end of a background task function, when there is no need for the task to run permanently.
DO NOT use this function in a critical task!
function suspendBackgroundUs
This function allows to suspend a background task for a specified duration expressed in microseconds. For example, you can call this function at the end of a background task function, when there is no need for the task to run permanently.
DO NOT use this function in a critical task!
The documentation for this class was generated from the following file docs/core/zephyr/modules/owntech_task_api/zephyr/public_api/TaskAPI.h