fix vss crash (#3130)
* don't deref null pointer * error on invalid * no logic analyzer * print out function in case of error
This commit is contained in:
parent
490d8c1f8e
commit
0422392ba9
|
@ -92,6 +92,4 @@ void setFordInline6(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
|||
|
||||
engineConfiguration->triggerInputPins[0] = GPIOA_8;
|
||||
engineConfiguration->triggerInputPins[1] = GPIOA_5;
|
||||
engineConfiguration->logicAnalyzerPins[0] = GPIOC_6;
|
||||
engineConfiguration->logicAnalyzerPins[1] = GPIOE_5;
|
||||
}
|
||||
|
|
|
@ -205,9 +205,8 @@ ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static void turnOnCapturePin(const char *msg, brain_pin_e brainPin) {
|
||||
ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
|
||||
if (driver != NULL) {
|
||||
static void turnOnCapturePin(const char *msg, ICUDriver* driver, brain_pin_e brainPin) {
|
||||
if (driver) {
|
||||
iomode_t mode = (iomode_t) PAL_MODE_ALTERNATE(getAlternateFunctions(driver));
|
||||
efiSetPadMode(msg, brainPin, mode);
|
||||
}
|
||||
|
@ -270,7 +269,7 @@ static void startInputDriver(const char *msg, /*nullable*/digital_input_s *hw) {
|
|||
digital_input_s* startDigitalCapture(const char *msg, brain_pin_e brainPin) {
|
||||
ICUDriver *driver = getInputCaptureDriver(msg, brainPin);
|
||||
if (!driver) {
|
||||
warning(CUSTOM_ERR_INVALID_INPUT_ICU_PIN, "w_not input pin");
|
||||
firmwareError(CUSTOM_ERR_INVALID_INPUT_ICU_PIN, "Invalid %s input pin: %s", msg, hwPortname(brainPin));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -280,7 +279,7 @@ digital_input_s* startDigitalCapture(const char *msg, brain_pin_e brainPin) {
|
|||
hw->started = false;
|
||||
hw->brainPin = brainPin;
|
||||
hw->driver = driver;
|
||||
turnOnCapturePin(msg, brainPin);
|
||||
turnOnCapturePin(msg, driver, brainPin);
|
||||
|
||||
startInputDriver(msg, hw);
|
||||
return hw;
|
||||
|
|
|
@ -93,7 +93,9 @@ void startVSSPins(void) {
|
|||
#elif HAL_USE_ICU
|
||||
digital_input_s* vehicleSpeedInput = startDigitalCapture("VSS", CONFIG(vehicleSpeedSensorInputPin));
|
||||
|
||||
vehicleSpeedInput->widthListeners.registerCallback((VoidInt) vsAnaWidthCallback, nullptr);
|
||||
if (vehicleSpeedInput) {
|
||||
vehicleSpeedInput->widthListeners.registerCallback((VoidInt) vsAnaWidthCallback, nullptr);
|
||||
}
|
||||
#else
|
||||
#error "HAL_USE_ICU or HAL_VSS_USE_PAL should be enabled to use EFI_VEHICLE_SPEED"
|
||||
#endif /* HAL_VSS_USE_PAL, HAL_USE_ICU */
|
||||
|
|
Loading…
Reference in New Issue