/** * sets the alarm to the specified number of microseconds from now. * This function should be invoked under kernel lock which would disable interrupts. */ void setHardwareUsTimer(int32_t timeUs) { /** * #259 BUG error: not positive timeUs * Once in a while we night get an interrupt where we do not expect it */ if (timeUs <= 0) { timerFreezeCounter++; warning(CUSTOM_OBD_42, "local freeze cnt=%d", timerFreezeCounter); } if (timeUs < 2) timeUs = 2; // for some reason '1' does not really work efiAssertVoid(timeUs > 0, "not positive timeUs"); efiAssertVoid(timeUs < 10 * US_PER_SECOND, "setHardwareUsTimer() too large"); if (GPTDEVICE.state == GPT_ONESHOT) gptStopTimerI(&GPTDEVICE); efiAssertVoid(GPTDEVICE.state == GPT_READY, "hw timer"); if (hasFirmwareError()) return; gptStartOneShotI(&GPTDEVICE, timeUs); lastSetTimerTimeNt = getTimeNowNt(); lastSetTimerValue = timeUs; isTimerPending = TRUE; timerRestartCounter++; }
/** * sets the alarm to the specified number of microseconds from now. * This function should be invoked under kernel lock which would disable interrupts. */ void setHardwareUsTimer(int32_t timeUs) { setHwTimerCounter++; /** * #259 BUG error: not positive timeUs * Once in a while we night get an interrupt where we do not expect it */ if (timeUs <= 0) { timerFreezeCounter++; warning(CUSTOM_OBD_LOCAL_FREEZE, "local freeze cnt=%d", timerFreezeCounter); } if (timeUs < 2) timeUs = 2; // for some reason '1' does not really work efiAssertVoid(CUSTOM_ERR_6681, timeUs > 0, "not positive timeUs"); if (timeUs >= 10 * US_PER_SECOND) { firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareUsTimer() too long: %d", timeUs); return; } if (GPTDEVICE.state == GPT_ONESHOT) { gptStopTimerI(&GPTDEVICE); } if (GPTDEVICE.state != GPT_READY) { firmwareError(CUSTOM_HW_TIMER, "HW timer state %d/%d", GPTDEVICE.state, setHwTimerCounter); return; } if (hasFirmwareError()) return; gptStartOneShotI(&GPTDEVICE, timeUs); lastSetTimerTimeNt = getTimeNowNt(); lastSetTimerValue = timeUs; isTimerPending = TRUE; timerRestartCounter++; }
void vMBPortTimersDisable( ) { if (bMBPortIsWithinException() == TRUE) gptStopTimerI (&GPTDRIVER); else gptStopTimer (&GPTDRIVER); }
/* * EXTI callback. * Triggered when echo signal is received. */ static void ext6cb(EXTDriver *extp, expchannel_t channel) { uint32_t tmp; (void)extp; (void)channel; chSysLockFromIsr(); tmp = (&GPT_DRIVER)->tim->CNT; if (tmp > 1500) { measure = tmp; gptStopTimerI(&GPT_DRIVER); } chSysUnlockFromIsr(); }
/** * sets the alarm to the specified number of microseconds from now. * This function should be invoked under kernel lock which would disable interrupts. */ void setHardwareUsTimer(int32_t timeUs) { if (timeUs == 1) timeUs = 2; // for some reason '1' does not really work efiAssertVoid(timeUs > 0, "neg timeUs"); efiAssertVoid(timeUs < 10 * US_PER_SECOND, "setHardwareUsTimer() too large"); if (GPTDEVICE.state == GPT_ONESHOT) gptStopTimerI(&GPTDEVICE); gptStartOneShotI(&GPTDEVICE, timeUs); lastSetTimerTime = getTimeNowUs(); lastSetTimerValue = timeUs; isTimerPending = TRUE; timerRestartCounter++; }
void vMBPortTimersEnable( ) { #ifdef DEBUG_MB palClearPad (BOARD_LED2_P, BOARD_LED2); tmStartMeasurement (&tm); #endif if (bMBPortIsWithinException() == TRUE) { gptStopTimerI (&GPTDRIVER); gptStartOneShotI(&GPTDRIVER, timerout); } else { gptStopTimer (&GPTDRIVER); gptStartOneShot(&GPTDRIVER, timerout); } }
/** * @brief Stops the timer. * * @param[in] gptp pointer to the @p GPTDriver object * * @api */ void gptStopTimer(GPTDriver *gptp) { osalSysLock(); gptStopTimerI(gptp); osalSysUnlock(); }
/** * @brief Stops the timer. * * @param[in] gptp pointer to the @p GPTDriver object * * @api */ void gptStopTimer(GPTDriver *gptp) { chSysLock(); gptStopTimerI(gptp); chSysUnlock(); }