コード例 #1
0
/**
 * 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++;
}
コード例 #2
0
ファイル: microsecond_timer.cpp プロジェクト: jharvey/rusefi
/**
 * 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++;
}
コード例 #3
0
void
vMBPortTimersDisable(  )
{
  if (bMBPortIsWithinException() == TRUE)
    gptStopTimerI (&GPTDRIVER);
  else
    gptStopTimer (&GPTDRIVER);
}
コード例 #4
0
/*
 * 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();
}
コード例 #5
0
ファイル: microsecond_timer.c プロジェクト: rus084/rusefi
/**
 * 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++;
}
コード例 #6
0
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);
  }
}
コード例 #7
0
ファイル: hal_gpt.c プロジェクト: AlexShiLucky/ChibiOS
/**
 * @brief   Stops the timer.
 *
 * @param[in] gptp      pointer to the @p GPTDriver object
 *
 * @api
 */
void gptStopTimer(GPTDriver *gptp) {

  osalSysLock();
  gptStopTimerI(gptp);
  osalSysUnlock();
}
コード例 #8
0
ファイル: gpt.c プロジェクト: CCrashBandicot/portapack-hackrf
/**
 * @brief   Stops the timer.
 *
 * @param[in] gptp      pointer to the @p GPTDriver object
 *
 * @api
 */
void gptStopTimer(GPTDriver *gptp) {

  chSysLock();
  gptStopTimerI(gptp);
  chSysUnlock();
}