Fixed ICU.

This commit is contained in:
Fabien Poussin 2017-03-23 00:46:05 +01:00
parent 4a93fc550f
commit 270d3a263d
2 changed files with 19 additions and 5 deletions

View File

@ -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) {

View File

@ -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));