From 270d3a263d2947d6b6188c0a1174bf9d60c6da7d Mon Sep 17 00:00:00 2001 From: Fabien Poussin Date: Thu, 23 Mar 2017 00:46:05 +0100 Subject: [PATCH] Fixed ICU. --- firmware/hw_layer/microsecond_timer.cpp | 2 +- firmware/hw_layer/trigger_input.cpp | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/firmware/hw_layer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer.cpp index 5198d575a5..dc0c504507 100644 --- a/firmware/hw_layer/microsecond_timer.cpp +++ b/firmware/hw_layer/microsecond_timer.cpp @@ -127,7 +127,7 @@ static msg_t mwThread(int param) { static const GPTConfig gpt5cfg = { 1000000, /* 1 MHz timer clock.*/ callback, /* Timer callback.*/ -0 }; +0, 0 }; void initMicrosecondTimer(void) { diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index b9c5842eac..a3c2d78150 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -31,11 +31,13 @@ int vvtEventRiseCounter = 0; int vvtEventFallCounter = 0; static void cam_icu_width_callback(ICUDriver *icup) { + (void)icup; vvtEventRiseCounter++; hwHandleVvtCamSignal(TV_RISE); } static void cam_icu_period_callback(ICUDriver *icup) { + (void)icup; vvtEventFallCounter++; hwHandleVvtCamSignal(TV_FALL); } @@ -80,14 +82,24 @@ static void shaft_icu_period_callback(ICUDriver *icup) { /** * the main purpose of this configuration structure is to specify the input interrupt callbacks */ -static ICUConfig shaft_icucfg = { ICU_INPUT_ACTIVE_LOW, 100000, /* 100kHz ICU clock frequency. */ -shaft_icu_width_callback, shaft_icu_period_callback }; +static ICUConfig shaft_icucfg = { ICU_INPUT_ACTIVE_LOW, + 100000, /* 100kHz ICU clock frequency. */ + shaft_icu_width_callback, + shaft_icu_period_callback, + NULL, + ICU_CHANNEL_1, + 0}; /** * this is about VTTi and stuff kind of cam sensor */ -static ICUConfig cam_icucfg = { ICU_INPUT_ACTIVE_LOW, 100000, /* 100kHz ICU clock frequency. */ -cam_icu_width_callback, cam_icu_period_callback }; +static ICUConfig cam_icucfg = { ICU_INPUT_ACTIVE_LOW, + 100000, /* 100kHz ICU clock frequency. */ + cam_icu_width_callback, + cam_icu_period_callback, + NULL, + ICU_CHANNEL_1, + 0}; static ICUDriver *turnOnTriggerInputPin(const char *msg, brain_pin_e hwPin, ICUConfig *icucfg) { @@ -112,6 +124,7 @@ static ICUDriver *turnOnTriggerInputPin(const char *msg, brain_pin_e hwPin, ICUC efiIcuStart(driver, icucfg); if (driver->state == ICU_READY) { icuStartCapture(driver); + icuEnableNotifications(driver); } else { // we would be here for example if same pin is used for multiple input capture purposes firmwareError(CUSTOM_ERR_ICU_STATE, "ICU unexpected state [%s]", hwPortname(hwPin)); @@ -123,6 +136,7 @@ static ICUDriver *turnOnTriggerInputPin(const char *msg, brain_pin_e hwPin, ICUC static void turnOffTriggerInputPin(brain_pin_e hwPin) { ICUDriver *driver = getInputCaptureDriver("trigger_off", hwPin); if (driver != NULL) { + icuDisableNotifications(driver); icuStopCapture(driver); icuStop(driver); scheduleMsg(logger, "turnOffTriggerInputPin %s", hwPortname(hwPin));