From 8fa9bf07a4fc8ea96e9c198e817744ff3a77420b Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 21 Apr 2017 13:53:47 -0400 Subject: [PATCH] refactoring - reducing GPIO complexity --- firmware/controllers/system/efiGpio.h | 27 --------------------------- firmware/hw_layer/io_pins.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h index c036bd9bba..991186271e 100644 --- a/firmware/controllers/system/efiGpio.h +++ b/firmware/controllers/system/efiGpio.h @@ -12,8 +12,6 @@ #include "io_pins.h" #include "main.h" -#define INITIAL_PIN_STATE -1 - void initPrimaryPins(void); void initOutputPins(void); @@ -23,31 +21,6 @@ void turnAllPinsOff(void); #define turnAllPinsOff() {} #endif /* EFI_GPIO */ - -/** - * @brief Single output pin reference and state - */ -class OutputPin { -public: - OutputPin(); - bool isInitialized(); - void setValue(int logicValue); - void setDefaultPinState(pin_output_mode_e *defaultState); - bool getLogicValue(); - void unregister(); -#if EFI_PROD_CODE || defined(__DOXYGEN__) - ioportid_t port; - uint8_t pin; -#endif /* EFI_PROD_CODE */ - int8_t currentLogicValue; - // 4 byte pointer is a bit of a memory waste here - pin_output_mode_e *modePtr; - /** - * we track current pin status so that we do not touch the actual hardware if we want to write new pin bit - * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering - */ -}; - class NamedOutputPin : public OutputPin { public: NamedOutputPin(); diff --git a/firmware/hw_layer/io_pins.h b/firmware/hw_layer/io_pins.h index 03cd9d0f16..a7a094e747 100644 --- a/firmware/hw_layer/io_pins.h +++ b/firmware/hw_layer/io_pins.h @@ -12,6 +12,7 @@ #include "rusefi_enums.h" #include "main.h" +#define INITIAL_PIN_STATE -1 #define GPIO_NULL NULL // mode >= 0 is always true since that's an unsigned @@ -51,5 +52,31 @@ // LED_HUGE_19, // LED_HUGE_20, +#ifdef __cplusplus + +/** + * @brief Single output pin reference and state + */ +class OutputPin { +public: + OutputPin(); + bool isInitialized(); + void setValue(int logicValue); + void setDefaultPinState(pin_output_mode_e *defaultState); + bool getLogicValue(); + void unregister(); +#if EFI_PROD_CODE || defined(__DOXYGEN__) + ioportid_t port; + uint8_t pin; +#endif /* EFI_PROD_CODE */ + int8_t currentLogicValue; + // 4 byte pointer is a bit of a memory waste here + pin_output_mode_e *modePtr; + /** + * we track current pin status so that we do not touch the actual hardware if we want to write new pin bit + * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering + */ +}; +#endif /* __cplusplus */ #endif /* IO_PINS_H_ */