refactoring

This commit is contained in:
rusefi 2017-07-10 22:05:40 -04:00
parent e3384235b0
commit 80f3ee1d93
1 changed files with 7 additions and 12 deletions

View File

@ -36,16 +36,13 @@ public:
*/ */
void initPin(const char *msg, brain_pin_e brainPin); void initPin(const char *msg, brain_pin_e brainPin);
/** /**
* disassosiates pin from this output and un-registers it in pin repository * dissociates pin from this output and un-registers it in pin repository
*/ */
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin); void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin);
bool isInitialized(); bool isInitialized();
bool isPinAssigned();
void setValue(int logicValue); void setValue(int logicValue);
void setDefaultPinState(pin_output_mode_e *defaultState);
bool getLogicValue(); bool getLogicValue();
@ -54,12 +51,16 @@ public:
uint8_t pin; uint8_t pin;
#endif /* EFI_GPIO_HARDWARE */ #endif /* EFI_GPIO_HARDWARE */
int8_t currentLogicValue; 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 * 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 * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering
*/ */
private:
// todo: inline this method?
void setDefaultPinState(pin_output_mode_e *defaultState);
// 4 byte pointer is a bit of a memory waste here
pin_output_mode_e *modePtr;
}; };
@ -155,12 +156,6 @@ public:
#define getElectricalValue(logicalValue, mode) \ #define getElectricalValue(logicalValue, mode) \
(logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode)) (logicalValue ? getElectricalValue1(mode) : getElectricalValue0(mode))
#if EFI_PROD_CODE
#define isPinAssigned(output) ((output)->port != GPIO_NULL)
#else /* EFI_PROD_CODE */
#define isPinAssigned(output) (true)
#endif /* EFI_PROD_CODE */
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__) #if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
ioportmask_t getHwPin(brain_pin_e brainPin); ioportmask_t getHwPin(brain_pin_e brainPin);