refactoring - reducing complexity
This commit is contained in:
parent
64fa965c5a
commit
ab0068fb97
|
@ -28,30 +28,5 @@
|
||||||
#include "gpio_helper.h"
|
#include "gpio_helper.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the hardware output pin while also assigning it a logical name
|
|
||||||
*/
|
|
||||||
void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber, iomode_t mode) {
|
|
||||||
if (outputPin->port != NULL && (outputPin->port != port || outputPin->pin != pinNumber)) {
|
|
||||||
/**
|
|
||||||
* here we check if another physical pin is already assigned to this logical output
|
|
||||||
*/
|
|
||||||
// todo: need to clear '&outputs' in io_pins.c
|
|
||||||
warning(CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin);
|
|
||||||
engine->withError = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
outputPin->currentLogicValue = INITIAL_PIN_STATE;
|
|
||||||
outputPin->port = port;
|
|
||||||
outputPin->pin = pinNumber;
|
|
||||||
|
|
||||||
mySetPadMode(msg, port, pinNumber, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void initOutputPin(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber) {
|
|
||||||
initOutputPinExt(msg, outputPin, port, pinNumber, PAL_MODE_OUTPUT_PUSHPULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* GPIO_HELPER_C_ */
|
#endif /* GPIO_HELPER_C_ */
|
||||||
|
|
|
@ -28,7 +28,6 @@ HW_LAYER_EMS_CPP = $(HW_LAYER_EGT_CPP) \
|
||||||
$(PROJECT_DIR)/hw_layer/stepper.cpp \
|
$(PROJECT_DIR)/hw_layer/stepper.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/servo.cpp \
|
$(PROJECT_DIR)/hw_layer/servo.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
|
$(PROJECT_DIR)/hw_layer/io_pins.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/gpio_helper.cpp \
|
|
||||||
$(PROJECT_DIR)/hw_layer/stm32f4/mpu_util.cpp \
|
$(PROJECT_DIR)/hw_layer/stm32f4/mpu_util.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/rtc_helper.cpp \
|
$(PROJECT_DIR)/hw_layer/rtc_helper.cpp \
|
||||||
$(PROJECT_DIR)/hw_layer/accelerometer.cpp
|
$(PROJECT_DIR)/hw_layer/accelerometer.cpp
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
#include "console_io.h"
|
#include "console_io.h"
|
||||||
|
|
||||||
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
#include "main_trigger_callback.h"
|
#include "main_trigger_callback.h"
|
||||||
#endif /* EFI_ENGINE_CONTROL */
|
#endif /* EFI_ENGINE_CONTROL */
|
||||||
|
@ -153,6 +155,31 @@ void initOutputPins(void) {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the hardware output pin while also assigning it a logical name
|
||||||
|
*/
|
||||||
|
void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber, iomode_t mode) {
|
||||||
|
if (outputPin->port != NULL && (outputPin->port != port || outputPin->pin != pinNumber)) {
|
||||||
|
/**
|
||||||
|
* here we check if another physical pin is already assigned to this logical output
|
||||||
|
*/
|
||||||
|
// todo: need to clear '&outputs' in io_pins.c
|
||||||
|
warning(CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin);
|
||||||
|
engine->withError = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
outputPin->currentLogicValue = INITIAL_PIN_STATE;
|
||||||
|
outputPin->port = port;
|
||||||
|
outputPin->pin = pinNumber;
|
||||||
|
|
||||||
|
mySetPadMode(msg, port, pinNumber, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initOutputPin(const char *msg, OutputPin *outputPin, ioportid_t port, uint32_t pinNumber) {
|
||||||
|
initOutputPinExt(msg, outputPin, port, pinNumber, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if EFI_GPIO
|
#if EFI_GPIO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue