/* The ISR executed when the user button is pushed. */ void INT0_7_Handler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ vParTestSetLEDFromISR( mainTIMER_CONTROLLED_LED, pdTRUE ); /* This interrupt safe FreeRTOS function can be called from this interrupt because the interrupt priority is below the configMAX_SYSCALL_INTERRUPT_PRIORITY setting in FreeRTOSConfig.h. */ xTimerResetFromISR( xLEDTimer, &xHigherPriorityTaskWoken ); /* Clear the interrupt before leaving. This just clears all the interrupts for simplicity, as only one is actually used in this simple demo anyway. */ FM3_EXTI->EICL = 0x0000; /* If calling xTimerResetFromISR() caused a task (in this case the timer service/daemon task) to unblock, and the unblocked task has a priority higher than or equal to the task that was interrupted, then xHigherPriorityTaskWoken will now be set to pdTRUE, and calling portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
/* The ISR executed when the user button is pushed. */ void GPIO8_IRQHandler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ ulGPIOState &= ~mainTIMER_CONTROLLED_LED; MSS_GPIO_set_outputs( ulGPIOState ); /* This interrupt safe FreeRTOS function can be called from this interrupt because the interrupt priority is below the configMAX_SYSCALL_INTERRUPT_PRIORITY setting in FreeRTOSConfig.h. */ xTimerResetFromISR( xLEDTimer, &xHigherPriorityTaskWoken ); /* Clear the interrupt before leaving. */ MSS_GPIO_clear_irq( MSS_GPIO_8 ); /* If calling xTimerResetFromISR() caused a task (in this case the timer service/daemon task) to unblock, and the unblocked task has a priority higher than or equal to the task that was interrupted, then xHigherPriorityTaskWoken will now be set to pdTRUE, and calling portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
int os_timer_change(os_timer_t timer, os_timer_change_t change, bool fromISR, unsigned period, unsigned block, void* reserved) { portBASE_TYPE woken; switch (change) { case OS_TIMER_CHANGE_START: if (fromISR) return xTimerStartFromISR(timer, &woken)!=pdPASS; else return xTimerStart(timer, block)!=pdPASS; case OS_TIMER_CHANGE_RESET: if (fromISR) return xTimerResetFromISR(timer, &woken)!=pdPASS; else return xTimerReset(timer, block)!=pdPASS; case OS_TIMER_CHANGE_STOP: if (fromISR) return xTimerStopFromISR(timer, &woken)!=pdPASS; else return xTimerStop(timer, block)!=pdPASS; case OS_TIMER_CHANGE_PERIOD: if (fromISR) return xTimerChangePeriodFromISR(timer, period, &woken)!=pdPASS; else return xTimerChangePeriod(timer, period, block)!=pdPASS; } return -1; }
static bool_t lora_recv_ch_cb(uint8_t id, uint8_t ch) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; lora_recv_data[lora_recv_index++] = ch; xTimerResetFromISR(lora_daemon_timer, &xHigherPriorityTaskWoken); return FALSE; }
/* Overridden weak function, from hw_rf.c */ void hw_rf_postconf_cb(void) { BaseType_t xHigherPriorityTaskWoken; if (dg_configRF_RECALIBRATION_TIMER_TIMEOUT == 0) return; /* Start/Reset Timer */ if (is_called_from_isr()) { xTimerResetFromISR(recalib_timer, &xHigherPriorityTaskWoken); portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); } else { xTimerReset(recalib_timer, portMAX_DELAY); } }
/* The ISR executed when the user button is pushed. */ void EXTI0_IRQHandler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ STM32vldiscovery_LEDOn( LED4 ); /* This interrupt safe FreeRTOS function can be called from this interrupt because the interrupt priority is below the configMAX_SYSCALL_INTERRUPT_PRIORITY setting in FreeRTOSConfig.h. */ xTimerResetFromISR( xLEDTimer, &xHigherPriorityTaskWoken ); /* Clear the interrupt before leaving. */ EXTI_ClearITPendingBit( EXTI_Line0 ); /* If calling xTimerResetFromISR() caused a task (in this case the timer service/daemon task) to unblock, and the unblocked task has a priority higher than or equal to the task that was interrupted, then xHigherPriorityTaskWoken will now be set to pdTRUE, and calling portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
/* The ISR is executed when the user button is pushed. */ static void prvButtonInputInterruptHandler( void *pvUnused ) { long lHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ ucGPIOState |= mainTIMER_CONTROLLED_LED; XGpio_DiscreteWrite( &xOutputGPIOInstance, ulGPIOOutputChannel, ucGPIOState ); /* Ensure only the ISR safe reset API function is used, as this is executed in an interrupt context. */ xTimerResetFromISR( xLEDTimer, &lHigherPriorityTaskWoken ); /* Clear the interrupt before leaving. */ XGpio_InterruptClear( &xInputGPIOInstance, ulGPIOInputChannel ); /* If calling xTimerResetFromISR() caused a task (in this case the timer service/daemon task) to unblock, and the unblocked task has a priority higher than or equal to the task that was interrupted, then lHigherPriorityTaskWoken will now be set to pdTRUE, and calling portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */ portYIELD_FROM_ISR( lHigherPriorityTaskWoken ); }
/* The ISR executed when the user button is pushed. */ void vPort_E_ISRHandler( void ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* The button was pushed, so ensure the LED is on before resetting the LED timer. The LED timer will turn the LED off if the button is not pushed within 5000ms. */ vParTestSetLED( mainTIMER_CONTROLLED_LED, pdTRUE ); /* This interrupt safe FreeRTOS function can be called from this interrupt because the interrupt priority is equal to or below the configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY setting in FreeRTOSConfig.h. */ xTimerResetFromISR( xLEDButtonTimer, &xHigherPriorityTaskWoken ); /* Clear the interrupt before leaving. */ PORTE_ISFR = 0xFFFFFFFFUL; /* If calling xTimerResetFromISR() caused a task (in this case the timer service/daemon task) to unblock, and the unblocked task has a priority higher than or equal to the task that was interrupted, then xHigherPriorityTaskWoken will now be set to pdTRUE, and calling portEND_SWITCHING_ISR() will ensure the unblocked task runs next. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
bool SoftTimer::resetFromISR( int32_t *pxHigherPriorityTaskWoken ) { return xTimerResetFromISR(_hnd, pxHigherPriorityTaskWoken) == pdPASS; }
/** * @brief Start or restart a timer. * @param timer_id timer ID obtained by \ref osTimerCreate. * @param millisec time delay value of the timer. * @retval status code that indicates the execution status of the function * @note MUST REMAIN UNCHANGED: \b osTimerStart shall be consistent in every CMSIS-RTOS. */ osStatus osTimerStart (osTimerId timer_id, uint32_t millisec) { osStatus result = osOK; #if (configUSE_TIMERS == 1) portBASE_TYPE taskWoken = pdFALSE; TickType_t ticks = millisec / portTICK_PERIOD_MS; if (xTimerIsTimerActive(timer_id) != pdFALSE) { if (inHandlerMode()) { if(xTimerResetFromISR(timer_id, &taskWoken) != pdPASS) { result = osErrorOS; } else { portEND_SWITCHING_ISR(taskWoken); result = osOK; } } else { if (xTimerReset(timer_id, 0) != pdPASS) result = osErrorOS; else result = osOK; } } else { if (ticks == 0) ticks = 1; if (inHandlerMode()) { if (xTimerChangePeriodFromISR(timer_id, ticks, &taskWoken) != pdPASS) result = osErrorOS; else { xTimerStartFromISR(timer_id, &taskWoken); portEND_SWITCHING_ISR(taskWoken); result = osOK; } } else { if (xTimerChangePeriod(timer_id, ticks, 0) != pdPASS) result = osErrorOS; else { if (xTimerStart(timer_id, 0) != pdPASS) result = osErrorOS; } } } #else result = osErrorOS; #endif return result; }