From 00f56ab39961fd7ce62672a11e3cb511ea618287 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 12 Jul 2015 22:03:34 -0400 Subject: [PATCH] auto-sync --- ...ngine_configuration_generated_structures.h | 18 ++++++++++--- firmware/controllers/algo/rusefi_generated.h | 5 +++- firmware/hw_layer/HIP9011.cpp | 3 ++- firmware/hw_layer/io_pins.cpp | 1 + firmware/hw_layer/stm32f4/mpu_util.cpp | 27 ++++++++++++++----- firmware/hw_layer/stm32f4/mpu_util.h | 10 ++++--- firmware/integration/rusefi_config.txt | 5 +++- firmware/rusefi.cpp | 2 +- 8 files changed, 54 insertions(+), 17 deletions(-) diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 0b0999f5a2..7afe2b936b 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Fri Jul 03 10:52:21 EDT 2015 +// this section was generated by config_definition.jar on Sun Jul 12 21:31:55 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -1222,7 +1222,19 @@ typedef struct { /** * offset 1748 */ - int unused3[102]; + int spi2SckMode; + /** + * offset 1752 + */ + int spi2MosiMode; + /** + * offset 1756 + */ + int spi2MisoMode; + /** + * offset 1760 + */ + int unused3[99]; /** * offset 2156 */ @@ -1433,4 +1445,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Fri Jul 03 10:52:21 EDT 2015 +// this section was generated by config_definition.jar on Sun Jul 12 21:31:55 EDT 2015 diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index ce99f4eccf..45e78ba508 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -641,7 +641,10 @@ #define baroCorrRpmBins_offset_hex 684 #define baroCorrTable_offset 1684 #define baroCorrTable_offset_hex 694 -#define unused3_offset 1748 +#define spi2SckMode_offset 1748 +#define spi2MosiMode_offset 1752 +#define spi2MisoMode_offset 1756 +#define unused3_offset 1760 #define targetVBatt_offset 2156 #define alternatorOffAboveTps_offset 2160 #define alternatorOffAboveTps_offset_hex 870 diff --git a/firmware/hw_layer/HIP9011.cpp b/firmware/hw_layer/HIP9011.cpp index 512b81da16..29616d9b9d 100644 --- a/firmware/hw_layer/HIP9011.cpp +++ b/firmware/hw_layer/HIP9011.cpp @@ -43,6 +43,7 @@ static NamedOutputPin intHold("HIP"); static OutputPin hipCs; extern pin_output_mode_e DEFAULT_OUTPUT; +extern pin_output_mode_e OPENDRAIN_OUTPUT; extern uint32_t lastExecutionCount; @@ -418,7 +419,7 @@ void initHip9011(Logging *sharedLogger) { outputPinRegisterExt2("hip int/hold", &intHold, boardConfiguration->hip9011IntHoldPin, &boardConfiguration->hip9011IntHoldPinMode); - outputPinRegisterExt2("hip CS", &hipCs, boardConfiguration->hip9011CsPin, &DEFAULT_OUTPUT); + outputPinRegisterExt2("hip CS", &hipCs, boardConfiguration->hip9011CsPin, &OPENDRAIN_OUTPUT); scheduleMsg(logger, "Starting HIP9011/TPIC8101 driver"); spiStart(driver, &spicfg); diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp index adc10cea88..f87d443a1c 100644 --- a/firmware/hw_layer/io_pins.cpp +++ b/firmware/hw_layer/io_pins.cpp @@ -36,6 +36,7 @@ static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOF}; #endif pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT; +pin_output_mode_e OPENDRAIN_OUTPUT = OM_OPENDRAIN; static void outputPinRegisterExt(const char *msg, OutputPin *output, GPIO_TypeDef *port, uint32_t pin, pin_output_mode_e *outputMode) { diff --git a/firmware/hw_layer/stm32f4/mpu_util.cpp b/firmware/hw_layer/stm32f4/mpu_util.cpp index 722fe4512b..55d3a343a4 100644 --- a/firmware/hw_layer/stm32f4/mpu_util.cpp +++ b/firmware/hw_layer/stm32f4/mpu_util.cpp @@ -270,11 +270,15 @@ void turnOnSpi(spi_device_e device) { return; // already initialized isSpiInitialized[device] = true; if (device == SPI_DEVICE_1) { +// todo: introduce a nice structure with all fields for same SPI #if STM32_SPI_USE_SPI1 // scheduleMsg(&logging, "Turning on SPI1 pins"); initSpiModule(&SPID1, getSckPin(device), getMisoPin(device), - getMosiPin(device)); + getMosiPin(device), + 0, + 0, + 0); #endif /* STM32_SPI_USE_SPI1 */ } if (device == SPI_DEVICE_2) { @@ -282,7 +286,10 @@ void turnOnSpi(spi_device_e device) { // scheduleMsg(&logging, "Turning on SPI2 pins"); initSpiModule(&SPID2, getSckPin(device), getMisoPin(device), - getMosiPin(device)); + getMosiPin(device), + 0, + 0, + 0); #endif /* STM32_SPI_USE_SPI2 */ } if (device == SPI_DEVICE_3) { @@ -290,18 +297,24 @@ void turnOnSpi(spi_device_e device) { // scheduleMsg(&logging, "Turning on SPI3 pins"); initSpiModule(&SPID3, getSckPin(device), getMisoPin(device), - getMosiPin(device)); + getMosiPin(device), + 0, + 0, + 0); #endif /* STM32_SPI_USE_SPI3 */ } } void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, - brain_pin_e mosi) { + brain_pin_e mosi, + int sckMode, + int mosiMode, + int misoMode) { - mySetPadMode2("SPI clock", sck, PAL_MODE_ALTERNATE(getSpiAf(driver))); + mySetPadMode2("SPI clock", sck, PAL_MODE_ALTERNATE(getSpiAf(driver)) + sckMode); - mySetPadMode2("SPI master out", mosi, PAL_MODE_ALTERNATE(getSpiAf(driver))); - mySetPadMode2("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver))); + mySetPadMode2("SPI master out", mosi, PAL_MODE_ALTERNATE(getSpiAf(driver)) + mosiMode); + mySetPadMode2("SPI master in ", miso, PAL_MODE_ALTERNATE(getSpiAf(driver)) + misoMode); } void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin) { diff --git a/firmware/hw_layer/stm32f4/mpu_util.h b/firmware/hw_layer/stm32f4/mpu_util.h index d8c9bd2ba0..ae06abf999 100644 --- a/firmware/hw_layer/stm32f4/mpu_util.h +++ b/firmware/hw_layer/stm32f4/mpu_util.h @@ -57,12 +57,16 @@ void DebugMonitorVector(void); void UsageFaultVector(void); void BusFaultVector(void); void HardFaultVector(void); -void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, - brain_pin_e mosi); -void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* MPU_UTIL_H_ */ + +void initSpiModule(SPIDriver *driver, brain_pin_e sck, brain_pin_e miso, + brain_pin_e mosi, + int sckMode, + int mosiMode, + int misoMode); +void initSpiCs(SPIConfig *spiConfig, brain_pin_e csPin); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4bbc814d7f..0d51272b80 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -561,7 +561,10 @@ float[BARO_CORR_SIZE] baroCorrPressureBins;;"kPa", 1, 0, 0.0, 200, float[BARO_CORR_SIZE] baroCorrRpmBins;;"RPM", 1, 0, 0.0, 18000, 2 baro_corr_table_t baroCorrTable; - int[102] unused3; + int spi2SckMode; + int spi2MosiMode; + int spi2MisoMode; + int[99] unused3; float targetVBatt;;"Volts", 1, 0, 0,30, 1 float alternatorOffAboveTps;Turn off alternator output above specified TPS;"%", 1, 0, 0, 200, 2 diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index fc004487fb..06385899b1 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -291,5 +291,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20150711; + return 20150712; }