Components/Libraries/XF/FreeRTOS/Queue
Sara.chalokh (Talk | contribs) (→~Queue()) |
Sara.chalokh (Talk | contribs) (→Member Attibuts) |
||
(19 intermediate revisions by one user not shown) | |||
Line 4: | Line 4: | ||
= Member Attibuts = | = Member Attibuts = | ||
+ | QueueHandle_t _queue : the Free RTOS queue | ||
+ | |||
+ | bool _isCreated : indicate if the queue has been created successfully | ||
+ | |||
+ | = Member Functions Description = | ||
== Queue() == | == Queue() == | ||
=== Description === | === Description === | ||
Line 12: | Line 17: | ||
== Queue(baseUInt oSizeofObject) == | == Queue(baseUInt oSizeofObject) == | ||
− | == Description == | + | |
+ | === Description === | ||
The constructor of the queue. It will create a free RTOS queue and initialize it for the given object size. | The constructor of the queue. It will create a free RTOS queue and initialize it for the given object size. | ||
− | == Parameters == | + | === Parameters === |
oSizeofObject : the size of the element that must be contained by the Queue | oSizeofObject : the size of the element that must be contained by the Queue | ||
Line 32: | Line 38: | ||
== bool push(void* opEl, timeSize oTimeToWait) == | == bool push(void* opEl, timeSize oTimeToWait) == | ||
+ | === Description === | ||
+ | Add an element to the queue. | ||
+ | |||
+ | This will just push a pointer to the element and not a copy. see pushCopy if you want to add a copy of the element | ||
+ | |||
+ | === Parameters === | ||
+ | opEl : a pointer to the element to add | ||
+ | oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is full | ||
+ | |||
+ | === Return === | ||
+ | Return true if the element has been pushed successfully, else false. | ||
+ | |||
== bool pushCopy(void* opEl, TickType_t oTimeToWait) == | == bool pushCopy(void* opEl, TickType_t oTimeToWait) == | ||
+ | === Description === | ||
+ | Add a copy of the element to the queue. | ||
+ | |||
+ | IMPORTANT do not use this function if elements to add are pointers. | ||
+ | === Parameters === | ||
+ | opEl : a pointer to the element to add | ||
+ | oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is full | ||
+ | === Return === | ||
+ | Return true if a copy of the element has been pushed successfully in the Queue | ||
+ | |||
== bool pushFromISR(void* opEl) == | == bool pushFromISR(void* opEl) == | ||
+ | === Description === | ||
+ | Add a pointer to the element in the queue from an ISR. | ||
+ | === Parameters === | ||
+ | opEl : a pointer to the element to add | ||
+ | === Return === | ||
+ | Return true if the element has been pushed successfully | ||
+ | |||
== bool pushCopyFromISR(void* opEl) == | == bool pushCopyFromISR(void* opEl) == | ||
+ | === Description === | ||
+ | Add a copy of the element to the queue from an ISR. | ||
+ | === Parameters === | ||
+ | opEl : a pointer to the element to add | ||
+ | === Return === | ||
+ | Return true if a copy of the element has beem sent successfully | ||
+ | |||
== void* pop(timeSize oTimeToWait) == | == void* pop(timeSize oTimeToWait) == | ||
+ | === Description === | ||
+ | Return the first element of the queue and removes it from the queue. | ||
+ | === Parameters === | ||
+ | opEl : a point to the element where put the item | ||
+ | oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is empty (Normally set as INFINIT_TIME) | ||
+ | |||
== void* popFromISR() == | == void* popFromISR() == | ||
+ | === Description === | ||
+ | Return the first event of the queue and removes it from the queue from an ISR. | ||
+ | === Parameters === | ||
+ | opEl : a point to the element where put the item | ||
+ | |||
== void* peek(timeSize oTimeToWait) == | == void* peek(timeSize oTimeToWait) == | ||
+ | === Description === | ||
+ | Return the first element of the queue (but does not delete it). | ||
+ | === Parameters === | ||
+ | opEl : a pointer to the element where put the item | ||
+ | oTimeToWait : maximal amount of time (in ticks) that thread should wait if queue is empty | ||
+ | |||
== void* peekFromISR() == | == void* peekFromISR() == | ||
− | == | + | === Description === |
− | == | + | Return the first event of the queue from an ISR (but does not delete it). |
− | == | + | === Parameters === |
− | + | opEl : a point to the element where put the item | |
+ | |||
== bool isEmpty() == | == bool isEmpty() == | ||
+ | === Description === | ||
+ | Test if the event queue is empty. If yes it returns true else false | ||
+ | |||
== bool isFull() == | == bool isFull() == | ||
+ | === Description === | ||
+ | Test if the event queue is full. If yes it returns true else false | ||
+ | |||
== QUEUE_LENGHT_SIZE itemsInQueue() == | == QUEUE_LENGHT_SIZE itemsInQueue() == | ||
+ | === Description === | ||
+ | Returns the number of items in the queue | ||
+ | |||
== QUEUE_LENGHT_SIZE freeSpaceInQueue() == | == QUEUE_LENGHT_SIZE freeSpaceInQueue() == | ||
+ | === Description === | ||
+ | Returns the number of free spaces in the queue | ||
+ | |||
== void reset() == | == void reset() == | ||
− | == | + | === Description === |
+ | Reset the queue to its original empty state | ||
− | = | + | Note that if the queue contains pointers you must delete them manually. |
+ | |||
+ | == bool isCreated() == | ||
+ | === Description === | ||
+ | This function just return true if the queue has been created successfully, else false. |
Latest revision as of 13:45, 10 August 2017
Queue
The class Queue is a C++ interface that manage a FreeRTOS queue.
Member Attibuts
QueueHandle_t _queue : the Free RTOS queue
bool _isCreated : indicate if the queue has been created successfully
Member Functions Description
Queue()
Description
The constructor of the queue. It will create an uninitialized FreeRTOS queue. It mean that the queue is created but could not be used. Call initQueue to initialize it.
Parameters
oSizeofObject : the size of the element that must be contained by the Queue
Queue(baseUInt oSizeofObject)
Description
The constructor of the queue. It will create a free RTOS queue and initialize it for the given object size.
Parameters
oSizeofObject : the size of the element that must be contained by the Queue
~Queue()
Description
The destructor of the Queue. It will delete the free RTOS queue.
Not that if the queue contains pointer, the objects must be deleted manually
bool initQueue(baseUInt oSizeofObject)
Description
Initialize the queue for the given size of object
Parameters
oSizeofObject : the size of the element that must be contained by the queue
Return
Return true if the Queue has been initialized correctly, else false
bool push(void* opEl, timeSize oTimeToWait)
Description
Add an element to the queue.
This will just push a pointer to the element and not a copy. see pushCopy if you want to add a copy of the element
Parameters
opEl : a pointer to the element to add oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is full
Return
Return true if the element has been pushed successfully, else false.
bool pushCopy(void* opEl, TickType_t oTimeToWait)
Description
Add a copy of the element to the queue.
IMPORTANT do not use this function if elements to add are pointers.
Parameters
opEl : a pointer to the element to add oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is full
Return
Return true if a copy of the element has been pushed successfully in the Queue
bool pushFromISR(void* opEl)
Description
Add a pointer to the element in the queue from an ISR.
Parameters
opEl : a pointer to the element to add
Return
Return true if the element has been pushed successfully
bool pushCopyFromISR(void* opEl)
Description
Add a copy of the element to the queue from an ISR.
Parameters
opEl : a pointer to the element to add
Return
Return true if a copy of the element has beem sent successfully
void* pop(timeSize oTimeToWait)
Description
Return the first element of the queue and removes it from the queue.
Parameters
opEl : a point to the element where put the item oTimeToWait : maximal amount of time (in ms) that thread should wait if queue is empty (Normally set as INFINIT_TIME)
void* popFromISR()
Description
Return the first event of the queue and removes it from the queue from an ISR.
Parameters
opEl : a point to the element where put the item
void* peek(timeSize oTimeToWait)
Description
Return the first element of the queue (but does not delete it).
Parameters
opEl : a pointer to the element where put the item oTimeToWait : maximal amount of time (in ticks) that thread should wait if queue is empty
void* peekFromISR()
Description
Return the first event of the queue from an ISR (but does not delete it).
Parameters
opEl : a point to the element where put the item
bool isEmpty()
Description
Test if the event queue is empty. If yes it returns true else false
bool isFull()
Description
Test if the event queue is full. If yes it returns true else false
QUEUE_LENGHT_SIZE itemsInQueue()
Description
Returns the number of items in the queue
QUEUE_LENGHT_SIZE freeSpaceInQueue()
Description
Returns the number of free spaces in the queue
void reset()
Description
Reset the queue to its original empty state
Note that if the queue contains pointers you must delete them manually.
bool isCreated()
Description
This function just return true if the queue has been created successfully, else false.