auto-sync

This commit is contained in:
rusEfi 2015-01-07 16:05:17 -06:00
parent 3186ff017f
commit be30fedb74
7 changed files with 26 additions and 29 deletions

View File

@ -42,7 +42,6 @@ extern WaveChart waveChart;
static Logging logger; static Logging logger;
extern OutputPin outputs[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT];
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
void initSignalExecutor(void) { void initSignalExecutor(void) {
initLogging(&logger, "s exec"); initLogging(&logger, "s exec");

View File

@ -57,7 +57,6 @@
#include "lcd_controller.h" #include "lcd_controller.h"
extern OutputPin outputs[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT];
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
extern bool hasFirmwareErrorFlag; extern bool hasFirmwareErrorFlag;
persistent_config_container_s persistentState CCM_OPTIONAL; persistent_config_container_s persistentState CCM_OPTIONAL;

View File

@ -10,10 +10,10 @@
#include "efiGpio.h" #include "efiGpio.h"
#include "io_pins.h" #include "io_pins.h"
pin_output_mode_e OUTPUT_MODE_DEFAULT = OM_DEFAULT;
// todo: clean this mess, this should become 'static'/private // todo: clean this mess, this should become 'static'/private
OutputPin outputs[IO_PIN_COUNT]; OutputPin outputs[IO_PIN_COUNT];
pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
int getOutputPinValue(io_pin_e pin) { int getOutputPinValue(io_pin_e pin) {
return getLogicPinValue(&outputs[pin]); return getLogicPinValue(&outputs[pin]);
@ -89,14 +89,21 @@ const char *getPinName(io_pin_e io_pin) {
} }
} }
OutputPin::OutputPin() {
modePtr = &OUTPUT_MODE_DEFAULT;
}
void OutputPin::setValue(int logicValue) {
doSetOutputPinValue2(this, logicValue);
}
extern uint32_t dbgStart;
extern uint32_t dbgDurr;
/** /**
* @brief Sets the value according to current electrical settings * @brief Sets the value according to current electrical settings
* *
* This method costs about 85 ticks * This method costs about 85 ticks
*/ */
extern uint32_t dbgStart;
extern uint32_t dbgDurr;
void setOutputPinValue(io_pin_e pin, int logicValue) { void setOutputPinValue(io_pin_e pin, int logicValue) {
doSetOutputPinValue(pin, logicValue); doSetOutputPinValue(pin, logicValue);
} }

View File

@ -13,17 +13,21 @@
/** /**
* @brief Single output pin reference and state * @brief Single output pin reference and state
*/ */
typedef struct { class OutputPin {
public:
OutputPin();
void setValue(int logicValue);
#if EFI_PROD_CODE #if EFI_PROD_CODE
GPIO_TypeDef *port; GPIO_TypeDef *port;
int pin; int pin;
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
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
*/ */
int currentLogicValue; int currentLogicValue;
} OutputPin; };
/** /**
* it's a macro to be sure that stack is not used * it's a macro to be sure that stack is not used
@ -85,25 +89,24 @@ const char *getPinName(io_pin_e io_pin);
#endif #endif
#if EFI_PROD_CODE #if EFI_PROD_CODE
#define doSetOutputPinValue(pin, logicValue) { \ #define doSetOutputPinValue2(output, logicValue) { \
if (outputs[(pin)].port != GPIO_NULL) { \ if (output->port != GPIO_NULL) { \
efiAssertVoid(pinDefaultState[pin]!=NULL, "pin mode not initialized"); \ efiAssertVoid(output->modePtr!=NULL, "pin mode not initialized"); \
pin_output_mode_e mode = *pinDefaultState[pin]; \ pin_output_mode_e mode = *output->modePtr; \
efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \ efiAssertVoid(mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \
OutputPin *output = &outputs[pin]; \
int eValue = getElectricalValue(logicValue, mode); \ int eValue = getElectricalValue(logicValue, mode); \
setPinValue(output, eValue, logicValue); \ setPinValue(output, eValue, logicValue); \
} \ } \
} }
#else #else
#define doSetOutputPinValue(pin, logicValue) { \ #define doSetOutputPinValue2(output, logicValue) { \
pin_output_mode_e mode = OM_DEFAULT; \ pin_output_mode_e mode = OM_DEFAULT; \
OutputPin *output = &outputs[pin]; \
int eValue = getElectricalValue(logicValue, mode); \ int eValue = getElectricalValue(logicValue, mode); \
setPinValue(output, eValue, logicValue); \ setPinValue(output, eValue, logicValue); \
} }
#endif #endif
#define doSetOutputPinValue(pin, logicValue) doSetOutputPinValue2((&outputs[pin]), logicValue)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -25,7 +25,6 @@ extern board_configuration_s *boardConfiguration;
static Logging logger; static Logging logger;
extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT];
extern OutputPin outputs[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT];
#if defined(STM32F4XX) #if defined(STM32F4XX)
@ -45,8 +44,8 @@ void setDefaultPinState(io_pin_e pin, pin_output_mode_e *outputMode) {
#if EFI_GPIO #if EFI_GPIO
pin_output_mode_e mode = *outputMode; pin_output_mode_e mode = *outputMode;
assertOMode(mode); assertOMode(mode);
pinDefaultState[pin] = outputMode; outputs[(int)pin].modePtr = outputMode;
setOutputPinValue(pin, FALSE); // initial state outputs[(int)pin].setValue(false); // initial state
#endif #endif
} }

View File

@ -24,14 +24,4 @@ void initPwmGenerator(void);
void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, io_pin_e ioPin, void startSimplePwmExt(PwmConfig *state, const char *msg, brain_pin_e brainPin, io_pin_e ioPin,
float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback); float frequency, float dutyCycle, pwm_gen_callback *stateChangeCallback);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PWM_GENERATOR_H_ */ #endif /* PWM_GENERATOR_H_ */

View File

@ -255,7 +255,7 @@ void firmwareError(const char *fmt, ...) {
} }
} }
static char UNUSED_RAM_SIZE[6000]; static char UNUSED_RAM_SIZE[5000];
static char UNUSED_CCM_SIZE[9000] CCM_OPTIONAL; static char UNUSED_CCM_SIZE[9000] CCM_OPTIONAL;