diff --git a/firmware/config/stm32f0egt/mpu_util.h b/firmware/config/stm32f0egt/mpu_util.h deleted file mode 100644 index 878eb44b0e..0000000000 --- a/firmware/config/stm32f0egt/mpu_util.h +++ /dev/null @@ -1,3 +0,0 @@ - - -#define baseHardwareInit() {} \ No newline at end of file diff --git a/firmware/emulation/hw_layer/poten.h b/firmware/emulation/hw_layer/poten.h index 5979cd4624..fbf0874367 100644 --- a/firmware/emulation/hw_layer/poten.h +++ b/firmware/emulation/hw_layer/poten.h @@ -10,6 +10,9 @@ #define POTEN_H_ #include "main.h" + +#if HAL_USE_SPI || defined(__DOXYGEN__) + #include "engine_configuration.h" typedef struct { @@ -21,4 +24,6 @@ typedef struct { void initPotentiometers(board_configuration_s *boardConfiguration); void setPotResistance(Mcp42010Driver *driver, int channel, int resistance); +#endif + #endif /* POTEN_H_ */ diff --git a/firmware/emulation/wave_analyzer.h b/firmware/emulation/wave_analyzer.h index 27cf7fcc02..3c3880676d 100644 --- a/firmware/emulation/wave_analyzer.h +++ b/firmware/emulation/wave_analyzer.h @@ -10,6 +10,9 @@ #define WAVE_ANALYZER_H_ #include "main.h" + +#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__) + #include "datalogging.h" #include "wave_analyzer_hw.h" @@ -57,5 +60,7 @@ public: void initWaveAnalyzer(void); void printWave(Logging *logging); +#endif + #endif /* WAVE_ANALYZER_H_ */ diff --git a/firmware/hw_layer/AdcConfiguration.h b/firmware/hw_layer/AdcConfiguration.h index b0a1848b35..bfdedeac1e 100644 --- a/firmware/hw_layer/AdcConfiguration.h +++ b/firmware/hw_layer/AdcConfiguration.h @@ -7,6 +7,8 @@ #ifndef ADCCONFIGURATION_H_ #define ADCCONFIGURATION_H_ +#if HAL_USE_ADC || defined(__DOXYGEN__) + class AdcConfiguration { public: AdcConfiguration(ADCConversionGroup* hwConfig); @@ -31,5 +33,6 @@ private: adc_channel_e hardwareIndexByIndernalAdcIndex[20]; }; +#endif /* HAL_USE_ADC */ #endif /* ADCCONFIGURATION_H_ */ diff --git a/firmware/hw_layer/HIP9011.cpp b/firmware/hw_layer/HIP9011.cpp index 0671edaf71..bc7d880fc0 100644 --- a/firmware/hw_layer/HIP9011.cpp +++ b/firmware/hw_layer/HIP9011.cpp @@ -28,7 +28,7 @@ #include "rpm_calculator.h" #include "trigger_central.h" -#if EFI_HIP_9011 +#if EFI_HIP_9011 || defined(__DOXYGEN__) extern pin_output_mode_e DEFAULT_OUTPUT; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index a77cb6e8e6..aed1853cc5 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -7,6 +7,9 @@ */ #include "main.h" + +#if HAL_USE_ADC || defined(__DOXYGEN__) + #include "engine_configuration.h" #include "adc_inputs.h" #include "AdcConfiguration.h" @@ -546,3 +549,4 @@ void pokeAdcInputs() { printFullAdcReport(); } +#endif /* HAL_USE_ADC */ diff --git a/firmware/hw_layer/adc_inputs.h b/firmware/hw_layer/adc_inputs.h index be52af29b0..9b6e3244c1 100644 --- a/firmware/hw_layer/adc_inputs.h +++ b/firmware/hw_layer/adc_inputs.h @@ -10,6 +10,9 @@ #define ADC_INPUTS_H_ #include "main.h" + +#if HAL_USE_ADC || defined(__DOXYGEN__) + #include "adc_math.h" const char * getAdcMode(adc_channel_e hwChannel); @@ -55,4 +58,6 @@ typedef struct { // todo: migrate to adcToVoltageInputDividerCoefficient #define adcToVoltsDivided(adc) (adcToVolts(adc) * engineConfiguration->analogInputDividerCoefficient) +#endif /* HAL_USE_ADC */ + #endif /* ADC_INPUTS_H_ */ diff --git a/firmware/hw_layer/board_test.cpp b/firmware/hw_layer/board_test.cpp index 3cc0d7f3fe..a719bbac13 100644 --- a/firmware/hw_layer/board_test.cpp +++ b/firmware/hw_layer/board_test.cpp @@ -32,13 +32,15 @@ static volatile int stepCoutner = 0; static volatile brain_pin_e currentPin = GPIO_UNASSIGNED; -extern AdcConfiguration slowAdc; -extern AdcConfiguration fastAdc; - static bool isTimeForNextStep(int copy) { return copy != stepCoutner; } + +#if HAL_USE_ADC || defined(__DOXYGEN__) +extern AdcConfiguration slowAdc; +extern AdcConfiguration fastAdc; + static void processAdcPin(AdcConfiguration *adc, int index, const char *prefix) { adc_channel_e hwIndex = adc->getAdcHardwareIndexByInternalIndex(index); GPIO_TypeDef* port = getAdcChannelPort(hwIndex); @@ -60,7 +62,7 @@ static void processAdcPin(AdcConfiguration *adc, int index, const char *prefix) } } - +#endif static volatile int currentIndex = 0; static void waitForKey(void) { @@ -134,7 +136,9 @@ bool isBoardTestMode(void) { void printBoardTestState(void) { print("Current index=%d\r\n", currentIndex); print("'n' for next step and 'set X' to return to step X\r\n"); +#if HAL_USE_ADC || defined(__DOXYGEN__) print("ADC count: slow %d/fast %d\r\n", slowAdc.size(), fastAdc.size()); +#endif if (currentPin != GPIO_UNASSIGNED) { print("Blinking %s\r\n", hwPortname(currentPin)); @@ -150,11 +154,13 @@ void initBoardTest(void) { // this code is ugly as hell, I had no time to think. Todo: refactor +#if HAL_USE_ADC || defined(__DOXYGEN__) processAdcPin(&fastAdc, 0, "fast"); while (currentIndex < slowAdc.size()) { processAdcPin(&slowAdc, currentIndex, "slow"); currentIndex++; } +#endif currentIndex = 0; diff --git a/firmware/hw_layer/io_pins.c b/firmware/hw_layer/io_pins.c index ceceaa464d..bf7fbf8fb9 100644 --- a/firmware/hw_layer/io_pins.c +++ b/firmware/hw_layer/io_pins.c @@ -28,7 +28,11 @@ static Logging logger; extern pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; extern OutputPin outputs[IO_PIN_COUNT]; +#if defined(STM32F4XX) static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH }; +#else +static GPIO_TypeDef *PORTS[] = { GPIOA, GPIOB, GPIOC, GPIOD, GPIOF}; +#endif pin_output_mode_e DEFAULT_OUTPUT = OM_DEFAULT; @@ -111,8 +115,11 @@ static void getPinValue(const char *name) { void initOutputPins(void) { initLogging(&logger, "io_pins"); +#if EFI_WARNING_LED outputPinRegister("warning", LED_WARNING, LED_WARNING_PORT, LED_WARNING_PIN); outputPinRegister("is running status", LED_RUNNING, LED_RUNNING_STATUS_PORT, LED_RUNNING_STATUS_PIN); +#endif /* EFI_WARNING_LED */ + outputPinRegister("communication status 1", LED_COMMUNICATION_1, LED_COMMUNICATION_PORT, LED_COMMUNICATION_PIN); /** @@ -132,7 +139,9 @@ void initOutputPins(void) { // outputPinRegister("spi CS2", SPI_CS_2, SPI_CS2_PORT, SPI_CS2_PIN); // outputPinRegister("spi CS3", SPI_CS_3, SPI_CS3_PORT, SPI_CS3_PIN); // outputPinRegister("spi CS4", SPI_CS_4, SPI_CS4_PORT, SPI_CS4_PIN); +#if HAL_USE_SPI || defined(__DOXYGEN__) outputPinRegister("spi CS5", SPI_CS_SD_MODULE, SPI_SD_MODULE_PORT, SPI_SD_MODULE_PIN); +#endif // todo: should we move this code closer to the fuel pump logic? outputPinRegisterExt2("fuel pump relay", FUEL_PUMP_RELAY, boardConfiguration->fuelPumpPin, &DEFAULT_OUTPUT); diff --git a/firmware/hw_layer/mcp3208.c b/firmware/hw_layer/mcp3208.c index f71fecc497..a0f469e89d 100644 --- a/firmware/hw_layer/mcp3208.c +++ b/firmware/hw_layer/mcp3208.c @@ -6,11 +6,10 @@ * @author Andrey Belomutskiy, (c) 2012-2014 */ -#include -#include - -#include "mcp3208.h" #include "main.h" + +#if EFI_MCP_3208 || defined(__DOXYGEN__) +#include "mcp3208.h" #include "pin_repository.h" McpAdcState *hack; @@ -138,3 +137,4 @@ void init_adc_mcp3208(McpAdcState *state, SPIDriver *driver) { spiStart(driver, &spicfg); } +#endif /* EFI_MCP_3208 */ diff --git a/firmware/hw_layer/mcp3208.h b/firmware/hw_layer/mcp3208.h index ed0b68a0c9..d132a58cac 100644 --- a/firmware/hw_layer/mcp3208.h +++ b/firmware/hw_layer/mcp3208.h @@ -16,6 +16,10 @@ #ifndef MCP3208_H_ #define MCP3208_H_ +#include "main.h" + +#if EFI_MCP_3208 || defined(__DOXYGEN__) + #define MCP3208_CS_PORT GPIOD #define MCP3208_CS_PIN 11 @@ -37,4 +41,6 @@ void adc_in_out(McpAdcState *state); int getMcp3208adc(int channel); +#endif /* EFI_MCP_3208 */ + #endif /* MCP3208_H_ */ diff --git a/firmware/hw_layer/microsecond_timer.c b/firmware/hw_layer/microsecond_timer.c index 0d45fa8cdd..d9d508b7f6 100644 --- a/firmware/hw_layer/microsecond_timer.c +++ b/firmware/hw_layer/microsecond_timer.c @@ -18,7 +18,7 @@ // https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy.st.com%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fInterrupt%20on%20CEN%20bit%20setting%20in%20TIM7&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=474 -#if EFI_PROD_CODE +#if (EFI_PROD_CODE && HAL_USE_GPT) || defined(__DOXYGEN__) #define GPTDEVICE GPTD5 diff --git a/firmware/hw_layer/pin_repository.c b/firmware/hw_layer/pin_repository.c index 41a265c70f..c01a325ba2 100644 --- a/firmware/hw_layer/pin_repository.c +++ b/firmware/hw_layer/pin_repository.c @@ -35,12 +35,14 @@ char *portname(GPIO_TypeDef* GPIOx) { return "PC"; if (GPIOx == GPIOD) return "PD"; +#if defined(STM32F4XX) if (GPIOx == GPIOE) return "PE"; - if (GPIOx == GPIOF) - return "PF"; if (GPIOx == GPIOH) return "PH"; +#endif + if (GPIOx == GPIOF) + return "PF"; return "unknown"; } @@ -53,12 +55,14 @@ static int getPortIndex(GPIO_TypeDef* port) { return 2; if (port == GPIOD) return 3; +#if defined(STM32F4XX) if (port == GPIOE) return 4; - if (port == GPIOF) - return 5; if (port == GPIOH) return 6; +#endif + if (port == GPIOF) + return 5; firmwareError("portindex"); return -1; } diff --git a/firmware/hw_layer/stm32f0/mpu_util.cpp b/firmware/hw_layer/stm32f0/mpu_util.cpp new file mode 100644 index 0000000000..855361a404 --- /dev/null +++ b/firmware/hw_layer/stm32f0/mpu_util.cpp @@ -0,0 +1,14 @@ +/** + * @file mpu_util.cpp + * + * @date Dec 23, 2014 + * @author Andrey Belomutskiy, (c) 2012-2014 + */ + +#include "main.h" + +int getRemainingStack(Thread *otp) { + return 9999; +} + + diff --git a/firmware/hw_layer/stm32f0/mpu_util.h b/firmware/hw_layer/stm32f0/mpu_util.h new file mode 100644 index 0000000000..452a47c80e --- /dev/null +++ b/firmware/hw_layer/stm32f0/mpu_util.h @@ -0,0 +1,13 @@ +/** + * @file mpu_util.h + * + * @date Dec 23, 2014 + * @author Andrey Belomutskiy, (c) 2012-2014 + */ +#ifndef MPU_UTIL_H_ +#define MPU_UTIL_H_ + +#define baseHardwareInit() {} + + +#endif /* MPU_UTIL_H_ */ diff --git a/firmware/hw_layer/wave_analyzer_hw.c b/firmware/hw_layer/wave_analyzer_hw.c index af7761567c..6654ec0d2e 100644 --- a/firmware/hw_layer/wave_analyzer_hw.c +++ b/firmware/hw_layer/wave_analyzer_hw.c @@ -7,6 +7,9 @@ */ #include "wave_analyzer_hw.h" + +#if EFI_WAVE_ANALYZER || defined(__DOXYGEN__) + #include "eficonsole.h" #include "pin_repository.h" @@ -169,3 +172,5 @@ void setWaveReaderMode(WaveReaderHw *hw, bool mode) { } hw->started = TRUE; } + +#endif diff --git a/firmware/hw_layer/wave_analyzer_hw.h b/firmware/hw_layer/wave_analyzer_hw.h index a39d28d3bf..92e2c0cadb 100644 --- a/firmware/hw_layer/wave_analyzer_hw.h +++ b/firmware/hw_layer/wave_analyzer_hw.h @@ -9,6 +9,9 @@ #define WAVE_ANALYZER_HW_H_ #include "main.h" + +#if HAL_USE_ICU || defined(__DOXYGEN__) + #include "listener_array.h" typedef struct { @@ -36,4 +39,6 @@ ICUDriver * getInputCaptureDriver(brain_pin_e hwPin); } #endif /* __cplusplus */ +#endif + #endif /* WAVE_ANALYZER_HW_H_ */