Components/Libraries/XF/FreeRTOS/BaseThread
Sara.chalokh (Talk | contribs) (→Member Attributes) |
Sara.chalokh (Talk | contribs) (→void threadMainWrapper(void* pvParameter) [static] [protected]) |
||
(6 intermediate revisions by one user not shown) | |||
Line 6: | Line 6: | ||
= Member Attributes = | = Member Attributes = | ||
− | ''' | + | PRIORITY_SIZE '''_priority''' : the priority of the thread |
− | + | ||
− | + | ||
− | '''string _name''' : the name of the thread | + | TaskHandle_t '''_taskHandler''' : the FreeRTOS task |
− | ''' | + | |
− | + | string '''_name''' : the name of the thread | |
+ | |||
+ | STACKSIZE_SIZE '''_stackDepth''' : the of the thread's stack in words (not bytes !) | ||
− | ''' | + | bool '''_isCreated''' : indicate if the thread has been created successfully |
= Member Functions Documentation= | = Member Functions Documentation= | ||
== BaseThread(string oName, PRIORITY_SIZE oPriority, STACKSIZE_SIZE oStackDepth) == | == BaseThread(string oName, PRIORITY_SIZE oPriority, STACKSIZE_SIZE oStackDepth) == | ||
=== Description === | === Description === | ||
− | Construct a new BaseThread to manage a | + | Construct a new BaseThread to manage a FreeRTOS task. |
If the value of oPriority is bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is sent. | If the value of oPriority is bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is sent. | ||
If the FreeRTOS task creation fails and useErrorHandler is define also an error "OS_MEMORY_COULD_NOT_BE_ALLOCATED" is sent. | If the FreeRTOS task creation fails and useErrorHandler is define also an error "OS_MEMORY_COULD_NOT_BE_ALLOCATED" is sent. | ||
+ | |||
+ | If you dont use the error handler you can know if the creation success by calling method isCreated(). | ||
=== Parameters === | === Parameters === | ||
− | oName : the name of the thread (automatically set to "a Thread") | + | string '''oName''' : the name of the thread (automatically set to "a Thread") |
− | oPriority : the thread priority (automatically set to LOW_PRIORITY) | + | PRIORITY_SIZE '''oPriority''' : the thread priority (automatically set to LOW_PRIORITY) |
− | oStackDepth : the number of words (not bytes !) to allocate for stack size (automatically set to THREAD_STACK_SIZE) | + | STACKSIZE_SIZE '''oStackDepth''' : the number of words (not bytes !) to allocate for stack size (automatically set to THREAD_STACK_SIZE) |
== ~BaseThread() [virtual] == | == ~BaseThread() [virtual] == | ||
Line 50: | Line 52: | ||
If the value of oNewPriorityis bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is send. | If the value of oNewPriorityis bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is send. | ||
=== Parameters === | === Parameters === | ||
− | oNewPriority : the new priority of the thread (must be lower than MAX_SYSTEM_PRIORITY) | + | PRIORITY_SIZE '''oNewPriority''' : the new priority of the thread (must be lower than MAX_SYSTEM_PRIORITY) |
− | == void | + | == void wait(timeSizeoTimeToWait) == |
=== Description === | === Description === | ||
− | Put the FreeRTOS task in a waiting state for the given time. | + | Put the FreeRTOS task in a waiting state for the given time (in ms). |
=== Parameters === | === Parameters === | ||
− | + | timeSize '''oTimeToWait''': the number of ms that the thread should block | |
== void stop() == | == void stop() == | ||
Line 81: | Line 83: | ||
=== Description === | === Description === | ||
Ends the FreeRTOS scheduler. | Ends the FreeRTOS scheduler. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== void threadMain() [pure virtual] [protected] == | == void threadMain() [pure virtual] [protected] == | ||
=== Description === | === Description === | ||
This function is not implemented here. This is the main function of the thread. | This function is not implemented here. This is the main function of the thread. |
Latest revision as of 13:03, 21 August 2017
BaseThread
The class BaseThread is a C++ version of a FreeRTOS task. It is an interface that implement all Free RTOS function to manage a Free RTOS task.
The function threadMain is the main function of the thread. But in this class it is just a pure virtual function that must be reimplemented in a subclass.
Member Attributes
PRIORITY_SIZE _priority : the priority of the thread
TaskHandle_t _taskHandler : the FreeRTOS task
string _name : the name of the thread
STACKSIZE_SIZE _stackDepth : the of the thread's stack in words (not bytes !)
bool _isCreated : indicate if the thread has been created successfully
Member Functions Documentation
BaseThread(string oName, PRIORITY_SIZE oPriority, STACKSIZE_SIZE oStackDepth)
Description
Construct a new BaseThread to manage a FreeRTOS task.
If the value of oPriority is bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is sent.
If the FreeRTOS task creation fails and useErrorHandler is define also an error "OS_MEMORY_COULD_NOT_BE_ALLOCATED" is sent.
If you dont use the error handler you can know if the creation success by calling method isCreated().
Parameters
string oName : the name of the thread (automatically set to "a Thread")
PRIORITY_SIZE oPriority : the thread priority (automatically set to LOW_PRIORITY)
STACKSIZE_SIZE oStackDepth : the number of words (not bytes !) to allocate for stack size (automatically set to THREAD_STACK_SIZE)
~BaseThread() [virtual]
Description
Delete the BaseThread and the FreeRTOS task that it manages same if this one is runing.
string getName()
Description
Returns the name of the BaseThread.
PRIORITY_SIZE getPriority()
Description
Returns the priority of the BaseThread.
bool setPriority(PRIORITY_SIZE oNewPriority) [virtual]
Description
Set the priority of the BaseThread to the value of oNewPriority.
If the value of oNewPriorityis bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is send.
Parameters
PRIORITY_SIZE oNewPriority : the new priority of the thread (must be lower than MAX_SYSTEM_PRIORITY)
void wait(timeSizeoTimeToWait)
Description
Put the FreeRTOS task in a waiting state for the given time (in ms).
Parameters
timeSize oTimeToWait: the number of ms that the thread should block
void stop()
Description
Put the FreeRTOS task to the waiting state until restart is called.
void restart()
Description
Resart the task that was stopped.
bool restartFromISR()
Description
Restart the task that was stopped from an ISR.
bool isCreated()
Description
Returns true if the FreeRTOS task has been created successfully.
void startScheduler() [static]
Description
Starts the FreeRTOS scheduler.
void endScheduler() [static]
Description
Ends the FreeRTOS scheduler.
void threadMain() [pure virtual] [protected]
Description
This function is not implemented here. This is the main function of the thread.