Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xEventGroupSetBitsFromISR

event_groups.h

    BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
 

A version of xEventGroupSetBits() that can be called from an interrupt.

Setting bits in an event group is not a deterministic operation because there are an unknown number of tasks that may be waiting for the bit or bits being set. FreeRTOS does not allow nondeterministic operations to be performed in interrupts or from critical sections. Therefore xEventGroupSetBitsFromISR() sends a message to the timer task to have the set operation performed in the context of the timer task - where a scheduler lock is used in place of a critical section.

Parameters
xEventGroupThe event group in which the bits are to be set.
uxBitsToSetA bitwise value that indicates the bit or bits to set. For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 and bit 0 set uxBitsToSet to 0x09.
pxHigherPriorityTaskWokenAs mentioned above, calling this function will result in a message being sent to the timer daemon task. If the priority of the timer daemon task is higher than the priority of the currently running task (the task the interrupt interrupted) then *pxHigherPriorityTaskWoken will be set to pdTRUE by xEventGroupSetBitsFromISR(), indicating that a context switch should be requested before the interrupt exits. For that reason *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the example code below.
Returns
If the request to execute the function was posted successfully then pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned if the timer service queue was full.

Example usage:

   #define BIT_0    ( 1 << 0 )
   #define BIT_4    ( 1 << 4 )
An event group which it is assumed has already been created by a call to
xEventGroupCreate().
   EventGroupHandle_t xEventGroup;
   void anInterruptHandler( void )
   {
   BaseType_t xHigherPriorityTaskWoken, xResult;
xHigherPriorityTaskWoken must be initialised to pdFALSE.
        xHigherPriorityTaskWoken = pdFALSE;
Set bit 0 and bit 4 in xEventGroup.
        xResult = xEventGroupSetBitsFromISR(
                            xEventGroup,    // The event group being updated.
                            BIT_0 | BIT_4   // The bits being set.
                            &xHigherPriorityTaskWoken );
Was the message posted successfully?
        if( xResult == pdPASS )
        {
If xHigherPriorityTaskWoken is now set to pdTRUE then a context
switch should be requested.  The macro used is port specific and
will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() -
refer to the documentation page for the port being used.
            portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
        }
  }
   
    BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
 

A version of xEventGroupClearBits() that can be called from an interrupt.

Setting bits in an event group is not a deterministic operation because there are an unknown number of tasks that may be waiting for the bit or bits being set. FreeRTOS does not allow nondeterministic operations to be performed while interrupts are disabled, so protects event groups that are accessed from tasks by suspending the scheduler rather than disabling interrupts. As a result event groups cannot be accessed directly from an interrupt service routine. Therefore xEventGroupClearBitsFromISR() sends a message to the timer task to have the clear operation performed in the context of the timer task.

Parameters
xEventGroupThe event group in which the bits are to be cleared.
uxBitsToClearA bitwise value that indicates the bit or bits to clear. For example, to clear bit 3 only, set uxBitsToClear to 0x08. To clear bit 3 and bit 0 set uxBitsToClear to 0x09.
Returns
If the request to execute the function was posted successfully then pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned if the timer service queue was full.

Example usage:

   #define BIT_0    ( 1 << 0 )
   #define BIT_4    ( 1 << 4 )
An event group which it is assumed has already been created by a call to
xEventGroupCreate().
   EventGroupHandle_t xEventGroup;
   void anInterruptHandler( void )
   {
Clear bit 0 and bit 4 in xEventGroup.
        xResult = xEventGroupClearBitsFromISR(
                            xEventGroup,     // The event group being updated.
                            BIT_0 | BIT_4 ); // The bits being set.
        if( xResult == pdPASS )
        {
The message was posted successfully.
        }
  }
   
    BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
 

A version of xEventGroupSetBits() that can be called from an interrupt.

Setting bits in an event group is not a deterministic operation because there are an unknown number of tasks that may be waiting for the bit or bits being set. FreeRTOS does not allow nondeterministic operations to be performed in interrupts or from critical sections. Therefore xEventGroupSetBitFromISR() sends a message to the timer task to have the set operation performed in the context of the timer task - where a scheduler lock is used in place of a critical section.

Parameters
xEventGroupThe event group in which the bits are to be set.
uxBitsToSetA bitwise value that indicates the bit or bits to set. For example, to set bit 3 only, set uxBitsToSet to 0x08. To set bit 3 and bit 0 set uxBitsToSet to 0x09.
pxHigherPriorityTaskWokenAs mentioned above, calling this function will result in a message being sent to the timer daemon task. If the priority of the timer daemon task is higher than the priority of the currently running task (the task the interrupt interrupted) then *pxHigherPriorityTaskWoken will be set to pdTRUE by xEventGroupSetBitsFromISR(), indicating that a context switch should be requested before the interrupt exits. For that reason *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the example code below.
Returns
If the request to execute the function was posted successfully then pdPASS is returned, otherwise pdFALSE is returned. pdFALSE will be returned if the timer service queue was full.

Example usage:

   #define BIT_0    ( 1 << 0 )
   #define BIT_4    ( 1 << 4 )
An event group which it is assumed has already been created by a call to
xEventGroupCreate().
   EventGroupHandle_t xEventGroup;
   void anInterruptHandler( void )
   {
   BaseType_t xHigherPriorityTaskWoken, xResult;
xHigherPriorityTaskWoken must be initialised to pdFALSE.
        xHigherPriorityTaskWoken = pdFALSE;
Set bit 0 and bit 4 in xEventGroup.
        xResult = xEventGroupSetBitsFromISR(
                            xEventGroup,    // The event group being updated.
                            BIT_0 | BIT_4   // The bits being set.
                            &xHigherPriorityTaskWoken );
Was the message posted successfully?
        if( xResult == pdPASS )
        {
If xHigherPriorityTaskWoken is now set to pdTRUE then a context
switch should be requested.  The macro used is port specific and 
will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - 
refer to the documentation page for the port being used.
            portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
        }
  }