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; }
uint32_t app_timer_stop(app_timer_id_t timer_id) { app_timer_info_t * pinfo = (app_timer_info_t*)(timer_id); TimerHandle_t hTimer = pinfo->osHandle; if (hTimer == NULL) { return NRF_ERROR_INVALID_STATE; } if (__get_IPSR() != 0) { BaseType_t yieldReq = pdFALSE; if (xTimerStopFromISR(timer_id, &yieldReq) != pdPASS) { return NRF_ERROR_NO_MEM; } portYIELD_FROM_ISR(yieldReq); } else { if (xTimerStop(timer_id, APP_TIMER_WAIT_FOR_QUEUE) != pdPASS) { return NRF_ERROR_NO_MEM; } } pinfo->active = false; return NRF_SUCCESS; }
/// Stop the timer. /// \param[in] timer_id timer ID obtained by \ref osTimerCreate. /// \return status code that indicates the execution status of the function. /// \note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS. osStatus osTimerStop (osTimerId timer_id) { portBASE_TYPE taskWoken = pdFALSE; osStatus result = osOK; if (inHandlerMode()) { xTimerStopFromISR(timer_id, &taskWoken); portEND_SWITCHING_ISR(taskWoken); } else { if (xTimerStop(timer_id, 0) != pdPASS) { //TODO: add timeout support result = osErrorOS; } } return result; }
/** * @brief Stop a timer. * @param timer_id timer ID obtained by \ref osTimerCreate * @retval status code that indicates the execution status of the function. * @note MUST REMAIN UNCHANGED: \b osTimerStop shall be consistent in every CMSIS-RTOS. */ osStatus osTimerStop (osTimerId timer_id) { osStatus result = osOK; #if (configUSE_TIMERS == 1) portBASE_TYPE taskWoken = pdFALSE; if (inHandlerMode()) { xTimerStopFromISR(timer_id, &taskWoken); portEND_SWITCHING_ISR(taskWoken); } else { if (xTimerStop(timer_id, 0) != pdPASS) { result = osErrorOS; } } #else result = osErrorOS; #endif return result; }
/* Overridden weak function, from hw_rf.c*/ bool hw_rf_preoff_cb(void) { /* Default sleep duration value is UINT_MAX. This value * marks that the MACs either never sleep, or don't * want to be waken up by a timer. */ uint32_t sleep_duration_in_lp = UINT32_MAX; /* Stop recalib timer */ if (dg_configRF_RECALIBRATION_TIMER_TIMEOUT > 0) { if (recalib_timer != NULL) { if (is_called_from_isr()) { BaseType_t xHigherPriorityTaskWoken; xTimerStopFromISR(recalib_timer, &xHigherPriorityTaskWoken); portEND_SWITCHING_ISR(xHigherPriorityTaskWoken); } else { xTimerStop(recalib_timer, portMAX_DELAY); } } } if (dg_configRF_ENABLE_RECALIBRATION == 0) { return false; } #if defined(CONFIG_USE_BLE) uint32_t ble_wakeup = pm_get_mac_wakeup_time(PM_BLE_ID); sleep_duration_in_lp = get_distance(ble_wakeup); #endif if (ad_rf_check_calibration(sleep_duration_in_lp) == true) { ad_rf_start_and_check_calibration(); return true; } return false; }
bool SoftTimer::stopFromISR( int32_t *pxHigherPriorityTaskWoken ) { return xTimerStopFromISR(_hnd, pxHigherPriorityTaskWoken) == pdPASS; }