better ICU error handling
This commit is contained in:
parent
f56b9adcd8
commit
d94b6d74e7
|
@ -266,7 +266,7 @@ void initMapDecoder(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
#if HAL_USE_ICU || defined(__DOXYGEN__)
|
||||
if (engineConfiguration->hasFrequencyReportingMapSensor) {
|
||||
digital_input_s* digitalMapInput = addWaveAnalyzerDriver("map freq", CONFIGB(frequencyReportingMapInputPin));
|
||||
startInputDriver(digitalMapInput, true);
|
||||
startInputDriver("MAP", digitalMapInput, true);
|
||||
|
||||
digitalMapInput->widthListeners.registerCallback((VoidInt) digitalMapWidthCallback, NULL);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ static void waIcuPeriodCallback(WaveReader *reader) {
|
|||
static void setWaveModeSilent(int index, int mode) {
|
||||
WaveReader *reader = &readers[index];
|
||||
|
||||
startInputDriver(reader->hw, mode);
|
||||
startInputDriver("wave", reader->hw, mode);
|
||||
}
|
||||
|
||||
//static int getEventCounter(int index) {
|
||||
|
@ -135,7 +135,7 @@ static void initWave(const char *name, int index) {
|
|||
}
|
||||
|
||||
print("wave%d input on %s\r\n", index, hwPortname(brainPin));
|
||||
startInputDriver(reader->hw, mode);
|
||||
startInputDriver("wave", reader->hw, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ void removeWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin) {
|
|||
}
|
||||
}
|
||||
|
||||
void startInputDriver(/*nullable*/digital_input_s *hw, bool isActiveHigh) {
|
||||
void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw, bool isActiveHigh) {
|
||||
if (hw == NULL) {
|
||||
// we can get NULL driver if user somehow has invalid pin in his configuration
|
||||
warning(CUSTOM_ERR_INVALID_INPUT_ICU_PIN, "s_not input pin");
|
||||
|
@ -275,7 +275,7 @@ void startInputDriver(/*nullable*/digital_input_s *hw, bool isActiveHigh) {
|
|||
icuStop(driver);
|
||||
}
|
||||
wave_icucfg.channel = getInputCaptureChannel(hw->brainPin);
|
||||
efiIcuStart(driver, &wave_icucfg);
|
||||
efiIcuStart(msg, driver, &wave_icucfg);
|
||||
efiAssertVoid(CUSTOM_ERR_6672, driver != NULL, "di: driver is NULL");
|
||||
efiAssertVoid(CUSTOM_ERR_6673, driver->state == ICU_READY, "di: driver not ready");
|
||||
icuStartCapture(driver); // this would change state from READY to WAITING
|
||||
|
|
|
@ -26,7 +26,7 @@ typedef struct {
|
|||
void turnOnCapturePin(const char *msg, brain_pin_e brainPin);
|
||||
|
||||
digital_input_s *addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin);
|
||||
void startInputDriver(/*nullable*/digital_input_s *hw, bool isActiveHigh);
|
||||
void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw, bool isActiveHigh);
|
||||
void removeWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin);
|
||||
|
||||
//Nullable
|
||||
|
|
|
@ -78,10 +78,13 @@ iomode_t getInputMode(pin_input_mode_e mode) {
|
|||
}
|
||||
|
||||
#if HAL_USE_ICU || defined(__DOXYGEN__)
|
||||
void efiIcuStart(ICUDriver *icup, const ICUConfig *config) {
|
||||
efiAssertVoid(CUSTOM_ERR_6679, (icup->state == ICU_STOP) || (icup->state == ICU_READY),
|
||||
"input already used?");
|
||||
|
||||
void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config) {
|
||||
if (icup->state != ICU_STOP && icup->state != ICU_READY) {
|
||||
static char icuError[30];
|
||||
sprintf(icuError, "ICU already used %s", msg);
|
||||
firmwareError(CUSTOM_ERR_6679, icuError);
|
||||
return;
|
||||
}
|
||||
icuStart(icup, config);
|
||||
}
|
||||
#endif /* HAL_USE_ICU */
|
||||
|
|
|
@ -58,7 +58,7 @@ bool efiReadPin(brain_pin_e pin);
|
|||
|
||||
iomode_t getInputMode(pin_input_mode_e mode);
|
||||
#if HAL_USE_ICU || defined(__DOXYGEN__)
|
||||
void efiIcuStart(ICUDriver *icup, const ICUConfig *config);
|
||||
void efiIcuStart(const char *msg, ICUDriver *icup, const ICUConfig *config);
|
||||
#endif /* HAL_USE_ICU */
|
||||
#endif /* EFI_GPIO_HARDWARE */
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ static ICUDriver *turnOnTriggerInputPin(const char *msg, brain_pin_e hwPin, ICUC
|
|||
// bool needPeriodCallback = !CONFIG(useOnlyRisingEdgeForTrigger) || !TRIGGER_SHAPE(useRiseEdge);
|
||||
// shaft_icucfg.period_cb = needPeriodCallback ? shaft_icu_period_callback : NULL;
|
||||
|
||||
efiIcuStart(driver, icucfg);
|
||||
efiIcuStart(msg, driver, icucfg);
|
||||
if (driver->state == ICU_READY) {
|
||||
efiAssert(CUSTOM_ERR_ASSERT, driver != NULL, "ti: driver is NULL", NULL);
|
||||
efiAssert(CUSTOM_ERR_ASSERT, driver->state == ICU_READY, "ti: driver not ready", NULL);
|
||||
|
|
|
@ -74,7 +74,7 @@ void startVSSPins(void) {
|
|||
if (!hasVehicleSpeedSensor())
|
||||
return;
|
||||
digital_input_s* vehicleSpeedInput = addWaveAnalyzerDriver("VSS", CONFIGB(vehicleSpeedSensorInputPin));
|
||||
startInputDriver(vehicleSpeedInput, true);
|
||||
startInputDriver("VSS", vehicleSpeedInput, true);
|
||||
vehicleSpeedInput->widthListeners.registerCallback((VoidInt) vsAnaWidthCallback, NULL);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue