Exemple #1
0
void vPeriodicEventGroupsProcessing( void )
{
    static BaseType_t xCallCount = 0, xISRTestError = pdFALSE;
    const BaseType_t xSetBitCount = 100, xGetBitsCount = 200, xClearBitsCount = 300;
    const EventBits_t uxBitsToSet = 0x12U;
    EventBits_t uxReturned;
    BaseType_t xMessagePosted;

    /* Called periodically from the tick hook to exercise the "FromISR"
    functions. */

    xCallCount++;

    if( xCallCount == xSetBitCount ) {
        /* All the event bits should start clear. */
        uxReturned = xEventGroupGetBitsFromISR( xISREventGroup );
        if( uxReturned != 0x00 ) {
            xISRTestError = pdTRUE;
        } else {
            /* Set the bits.  This is called from the tick hook so it is not
            necessary to use the last parameter to ensure a context switch
            occurs immediately. */
            xMessagePosted = xEventGroupSetBitsFromISR( xISREventGroup, uxBitsToSet, NULL );
            if( xMessagePosted != pdPASS ) {
                xISRTestError = pdTRUE;
            }
        }
    } else if( xCallCount == xGetBitsCount ) {
        /* Check the bits were set as expected. */
        uxReturned = xEventGroupGetBitsFromISR( xISREventGroup );
        if( uxReturned != uxBitsToSet ) {
            xISRTestError = pdTRUE;
        }
    } else if( xCallCount == xClearBitsCount ) {
        /* Clear the bits again. */
        uxReturned = ( EventBits_t ) xEventGroupClearBitsFromISR( xISREventGroup, uxBitsToSet );

        /* Check the message was posted. */
        if( uxReturned != pdPASS ) {
            xISRTestError = pdTRUE;
        }

        /* Go back to the start. */
        xCallCount = 0;

        /* If no errors have been detected then increment the count of test
        cycles. */
        if( xISRTestError == pdFALSE ) {
            ulISRCycles++;
        }
    } else {
        /* Nothing else to do. */
    }
}
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_EventGetFlags
 * Description   : Get event flags status.
 * Return current event flags.
 *
 *END**************************************************************************/
event_flags_t OSA_EventGetFlags(event_t *pEvent)
{
    assert(pEvent);

    if (__get_IPSR())
    {
        return xEventGroupGetBitsFromISR(pEvent->eventHandler);
    }
    else
    {
        return xEventGroupGetBits(pEvent->eventHandler);
    }
}
Exemple #3
0
/// Set the specified Signal Flags of an active thread.
/// \param[in]     thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
/// \param[in]     signals       specifies the signal flags of the thread that should be set.
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
/// \note MUST REMAIN UNCHANGED: \b osSignalSet shall be consistent in every CMSIS-RTOS.
int32_t osSignalSet (osThreadId thread_id, int32_t signals)
{
    EventGroupHandle_t event_handle;
    portBASE_TYPE taskWoken = pdFALSE;
    portBASE_TYPE xResult;
    EventBits_t uxBits_ret=0x80000000;
#ifdef CHECK_VALUE_OF_EVENT_GROUP    
    EventBits_t uxBits;
#endif    

    if (signals & (0xFFFFFFFF << osFeature_Signals)) {
        return 0x80000000;
    }

    event_handle = find_signal_by_thread(thread_id);
    if (event_handle) {
        if (inHandlerMode()) {
            uxBits_ret = xEventGroupGetBitsFromISR(event_handle);
            xResult = xEventGroupSetBitsFromISR(
                            event_handle,    /* The event group being updated. */
                            signals,         /* The bits being set. */
                            &taskWoken );
            if( xResult != pdFAIL )
            {
                portYIELD_FROM_ISR(taskWoken);
            }
        }
        else {
            uxBits_ret = xEventGroupGetBits(event_handle);
#ifdef CHECK_VALUE_OF_EVENT_GROUP                
            uxBits = 
#endif              
                      xEventGroupSetBits(
                           event_handle,    /* The event group being updated. */
                           signals );/* The bits being set. */
        }
    }

    return uxBits_ret;
}
Exemple #4
0
/// Clear the specified Signal Flags of an active thread.
/// \param[in]     thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
/// \param[in]     signals       specifies the signal flags of the thread that shall be cleared.
/// \return previous signal flags of the specified thread or 0x80000000 in case of incorrect parameters.
/// \note MUST REMAIN UNCHANGED: \b osSignalClear shall be consistent in every CMSIS-RTOS.
int32_t osSignalClear (osThreadId thread_id, int32_t signals)
{
    EventGroupHandle_t event_handle;
    //portBASE_TYPE taskWoken = pdFALSE;
    EventBits_t uxBits_ret=0x80000000;
#ifdef CHECK_VALUE_OF_EVENT_GROUP     
    EventBits_t uxBits;
#endif    

    if (signals & (0xFFFFFFFF << osFeature_Signals)) {
        return 0x80000000;
    }

    event_handle = find_signal_by_thread(thread_id);
    if (event_handle) {
        if (inHandlerMode()) {
            uxBits_ret = xEventGroupGetBitsFromISR(event_handle);
#ifdef CHECK_VALUE_OF_EVENT_GROUP                
            uxBits = 
#endif              
                      xEventGroupClearBitsFromISR(
                         event_handle,    /* The event group being updated. */
                         signals);/* The bits being cleared. */
        }
        else {
            uxBits_ret = xEventGroupGetBits(event_handle);
#ifdef CHECK_VALUE_OF_EVENT_GROUP                
            uxBits = 
#endif              
                      xEventGroupClearBits(                                          
                         event_handle,    /* The event group being updated. */
                         signals);/* The bits being cleared. */
        }
    }

    return uxBits_ret;
}