Components/Libraries/XF/FreeRTOS/BaseThread

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
 
= BaseThread =
 
= 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 class BaseThread is a C++ version of a FreeRTOS task. It is an interface that implement all Free RTOS function too manage a Free RTOS task.
  
 
The function threadMain is the main function of the thread. But in the class it is just a pure virtual function that must be reimplemented in a subclass.
 
The function threadMain is the main function of the thread. But in the 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=
 
= Member Functions Documentation=
 
== BaseThread(string oName, PRIORITY_SIZE oPriority, STACKSIZE_SIZE oStackDepth) ==
 
== BaseThread(string oName, PRIORITY_SIZE oPriority, STACKSIZE_SIZE oStackDepth) ==
=== Descritption ===
 
 
Construct a new BaseThread to manage a new FreeRTOS task. This will create the FreeRTOS task. The thread does not begin executing until startScheduler is called.
 
Construct a new BaseThread to manage a new FreeRTOS task. This will create the FreeRTOS task. The thread does not begin executing until startScheduler is called.
  
If the value of oPriority is bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is send.
+
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 send.
 
 
=== Parameters ===
 
=== Parameters ===
 
oName : the name of the thread (automatically set to "a Thread")
 
oName : the name of the thread (automatically set to "a Thread")
Line 21: Line 28:
  
 
== ~BaseThread() [virtual] ==
 
== ~BaseThread() [virtual] ==
=== Descritption ===
 
 
Delete the BaseThread and the FreeRTOS task that it manages same if this one is runing.
 
Delete the BaseThread and the FreeRTOS task that it manages same if this one is runing.
  
 
== string getName() ==
 
== string getName() ==
=== Descritption ===
 
 
Returns the name of the BaseThread.
 
Returns the name of the BaseThread.
 
== PRIORITY_SIZE getPriority() ==
 
== PRIORITY_SIZE getPriority() ==
 
Returns the priority of the BaseThread.
 
Returns the priority of the BaseThread.
 
 
== bool setPriority(PRIORITY_SIZE oNewPriority) [virtual] ==
 
== bool setPriority(PRIORITY_SIZE oNewPriority) [virtual] ==
 
Set the priority of the BaseThread to the value of oNewPriority.
 
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.
 
If the value of oNewPriorityis bigger than MAX_SYSTEM_PRIORITY and useErrorHandler is defined also an error "OS_BAD_PRIORITY" is send.
 
=== Parameters ===
 
oNewPriority : the new priority of the thread (must be lower than MAX_SYSTEM_PRIORITY)
 
=== Return ===
 
Return true if priority has been changed successfully else false
 
 
 
== void waitMs(tickSize oMsToWait) ==
 
== void waitMs(tickSize oMsToWait) ==
=== Descritption ===
 
 
Put the FreeRTOS task in a waiting state for the given time.
 
Put the FreeRTOS task in a waiting state for the given time.
=== Parameters ===
 
oMsToWait : the number of ms that the thread should block
 
 
 
== void stop() ==
 
== void stop() ==
 
Put the FreeRTOS task to the waiting state until restart is called.
 
Put the FreeRTOS task to the waiting state until restart is called.
 
 
== void restart() ==
 
== void restart() ==
=== Descritption ===
 
 
Resart the task that was stopped.
 
Resart the task that was stopped.
 
 
== bool restartFromISR() ==
 
== bool restartFromISR() ==
=== Descritption ===
 
 
Restart the task that was stopped from an ISR.
 
Restart the task that was stopped from an ISR.
=== Return ===
 
Return true if the thread has been restarted successfully
 
 
 
== bool isCreated() ==
 
== bool isCreated() ==
=== Descritption ===
 
 
Returns true if the FreeRTOS task has been created successfully.
 
Returns true if the FreeRTOS task has been created successfully.
  
 
== void startScheduler() [static] ==
 
== void startScheduler() [static] ==
=== Descritption ===
 
 
Starts the FreeRTOS scheduler.
 
Starts the FreeRTOS scheduler.
 
 
== void endScheduler() [static] ==
 
== void endScheduler() [static] ==
=== Descritption ===
 
 
Ends the FreeRTOS scheduler.
 
Ends the FreeRTOS scheduler.
  
 
== void threadMainWrapper(void* pvParameter) [static] [protected] ==
 
== void threadMainWrapper(void* pvParameter) [static] [protected] ==
=== Descritption ===
 
 
The thread main wrapper. The Free RTOS task only accept static methods to execute as main function. This function get in parameter the thread and call it's threadMain function.
 
The thread main wrapper. The Free RTOS task only accept static methods to execute as main function. This function get in parameter the thread and call it's threadMain function.
=== Parameters ===
 
pvParameter : a pointer to the thread to call the correct threadMain function
 
  
 
== void threadMain() [pure virtual] [protected] ==
 
== void threadMain() [pure virtual] [protected] ==
=== Descritption ===
+
This function is not implemented here
This function is not implemented here. This is the main function executed by the thead.
+

Revision as of 11:36, 10 August 2017

Contents

BaseThread

The class BaseThread is a C++ version of a FreeRTOS task. It is an interface that implement all Free RTOS function too manage a Free RTOS task.

The function threadMain is the main function of the thread. But in the 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)

Construct a new BaseThread to manage a new FreeRTOS task. This will create the FreeRTOS task. The thread does not begin executing until startScheduler is called.

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.

Parameters

oName : the name of the thread (automatically set to "a Thread")

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)

~BaseThread() [virtual]

Delete the BaseThread and the FreeRTOS task that it manages same if this one is runing.

string getName()

Returns the name of the BaseThread.

PRIORITY_SIZE getPriority()

Returns the priority of the BaseThread.

bool setPriority(PRIORITY_SIZE oNewPriority) [virtual]

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.

void waitMs(tickSize oMsToWait)

Put the FreeRTOS task in a waiting state for the given time.

void stop()

Put the FreeRTOS task to the waiting state until restart is called.

void restart()

Resart the task that was stopped.

bool restartFromISR()

Restart the task that was stopped from an ISR.

bool isCreated()

Returns true if the FreeRTOS task has been created successfully.

void startScheduler() [static]

Starts the FreeRTOS scheduler.

void endScheduler() [static]

Ends the FreeRTOS scheduler.

void threadMainWrapper(void* pvParameter) [static] [protected]

The thread main wrapper. The Free RTOS task only accept static methods to execute as main function. This function get in parameter the thread and call it's threadMain function.

void threadMain() [pure virtual] [protected]

This function is not implemented here

Personal tools
Namespaces
Variants
Actions
Navigation
Browse
Toolbox