looks like this part of refactoring is good?

This commit is contained in:
rusefi 2019-11-12 23:38:02 -05:00
parent c9b994ba0d
commit e33798c214
8 changed files with 11 additions and 13 deletions

View File

@ -117,7 +117,7 @@ static void initWave(const char *name, int index) {
if (reader->hw != NULL) { if (reader->hw != NULL) {
reader->hw->setWidthCallback((VoidInt)(void*) waAnaWidthCallback, (void*) reader); reader->hw->setWidthCallback((VoidInt)(void*) waAnaWidthCallback, (void*) reader);
reader->hw->setPeridoCallback((VoidInt)(void*) waIcuPeriodCallback, (void*) reader); reader->hw->setPeriodCallback((VoidInt)(void*) waIcuPeriodCallback, (void*) reader);
} }
print("wave%d input on %s\r\n", index, hwPortname(brainPin)); print("wave%d input on %s\r\n", index, hwPortname(brainPin));

View File

@ -11,6 +11,6 @@ void digital_input_s::setWidthCallback(VoidInt handler, void *arg) {
widthListeners.registerCallback(handler, arg); widthListeners.registerCallback(handler, arg);
} }
void digital_input_s::setPeridoCallback(VoidInt handler, void *arg) { void digital_input_s::setPeriodCallback(VoidInt handler, void *arg) {
periodListeners.registerCallback(handler, arg); periodListeners.registerCallback(handler, arg);
} }

View File

@ -23,5 +23,5 @@ typedef struct {
// Width/Period names are historically inherited from ICU implementation, todo: migrate to better names, high/low? rise/hall? // Width/Period names are historically inherited from ICU implementation, todo: migrate to better names, high/low? rise/hall?
void setWidthCallback(VoidInt handler, void *arg); void setWidthCallback(VoidInt handler, void *arg);
void setPeridoCallback(VoidInt handler, void *arg); void setPeriodCallback(VoidInt handler, void *arg);
} digital_input_s; } digital_input_s;

View File

@ -23,23 +23,23 @@
static ioportmask_t ext_used = 0; static ioportmask_t ext_used = 0;
// EXT is not able to give you the front direction but you could read the pin in the callback. // EXT is not able to give you the front direction but you could read the pin in the callback.
int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) { void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palcallback_t cb, void *cb_data) {
/* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL /* paranoid check, in case of GPIO_UNASSIGNED getHwPort will return NULL
* and we will fail on next check */ * and we will fail on next check */
if (brainPin == GPIO_UNASSIGNED) if (brainPin == GPIO_UNASSIGNED)
return -1; return;
ioportid_t port = getHwPort(msg, brainPin); ioportid_t port = getHwPort(msg, brainPin);
if (port == NULL) if (port == NULL)
return -1; return;
int index = getHwPin(msg, brainPin); int index = getHwPin(msg, brainPin);
/* is this index already used? */ /* is this index already used? */
if (ext_used & PAL_PORT_BIT(index)) { if (ext_used & PAL_PORT_BIT(index)) {
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin); firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %d: exti index already used", msg, brainPin);
return -1; return;
} }
ioline_t line = PAL_LINE(port, index); ioline_t line = PAL_LINE(port, index);
@ -48,8 +48,6 @@ int efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, palca
/* mark used */ /* mark used */
ext_used |= PAL_PORT_BIT(index); ext_used |= PAL_PORT_BIT(index);
return 0;
} }
void efiExtiDisablePin(brain_pin_e brainPin) void efiExtiDisablePin(brain_pin_e brainPin)

View File

@ -8,6 +8,6 @@
#include "digital_input.h" #include "digital_input.h"
#if HAL_USE_PAL #if HAL_USE_PAL
int efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data); void efiExtiEnablePin(const char *msg, brain_pin_e pin, uint32_t mode, palcallback_t cb, void *cb_data);
void efiExtiDisablePin(brain_pin_e brainPin); void efiExtiDisablePin(brain_pin_e brainPin);
#endif /* HAL_USE_PAL */ #endif /* HAL_USE_PAL */

View File

@ -233,7 +233,7 @@ digital_input_s * addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin) {
/** /**
* turns pin off and returns digital_input_s back into registeredIcus pool * turns pin off and returns digital_input_s back into registeredIcus pool
*/ */
void removeWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin) { void stopDigitalCapture(const char *msg, brain_pin_e brainPin) {
if (brainPin == GPIO_UNASSIGNED) { if (brainPin == GPIO_UNASSIGNED) {
return; return;
} }

View File

@ -20,7 +20,7 @@ void turnOffCapturePin(brain_pin_e brainPin);
digital_input_s *addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin); digital_input_s *addWaveAnalyzerDriver(const char *msg, brain_pin_e brainPin);
void startInputDriver(const char *msg, /*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); void stopDigitalCapture(const char *msg, brain_pin_e brainPin);
//Nullable //Nullable
ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin); ICUDriver * getInputCaptureDriver(const char *msg, brain_pin_e hwPin);

View File

@ -67,7 +67,7 @@ bool hasVehicleSpeedSensor() {
} }
void stopVSSPins(void) { void stopVSSPins(void) {
removeWaveAnalyzerDriver("VSS", activeConfiguration.bc.vehicleSpeedSensorInputPin); stopDigitalCapture("VSS", activeConfiguration.bc.vehicleSpeedSensorInputPin);
} }
void startVSSPins(void) { void startVSSPins(void) {