diff --git a/firmware/.cproject b/firmware/.cproject
index c1e3b3ec83..3ef9eb3431 100644
--- a/firmware/.cproject
+++ b/firmware/.cproject
@@ -43,7 +43,7 @@
-
+
@@ -249,7 +249,7 @@
-
+
@@ -335,7 +335,7 @@
-
+
diff --git a/firmware/.project b/firmware/.project
index 819b1879aa..2043416a43 100644
--- a/firmware/.project
+++ b/firmware/.project
@@ -1,6 +1,6 @@
- firmware.newc
+ firmware
diff --git a/firmware/Makefile b/firmware/Makefile
index 2d8c55faf9..4bc6638b65 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -122,7 +122,7 @@ CSRC = $(PORTSRC) \
$(CONSOLEUTILSRC) \
$(HALSRC) \
$(EMULATIONSRC) \
- $(HW_LAYERSRC) \
+ $(HW_LAYER_EMS) \
$(CONTROLLERSSRC) \
$(CONTROLLERS_ALGO_SRC) \
$(CONTROLLERS_CORE_SRC) \
@@ -143,7 +143,7 @@ CPPSRC = $(CHCPPSRC) \
$(CONTROLLERS_ALGO_SRC_CPP) \
$(SYSTEMSRC_CPP) \
$(ENGINES_SRC_CPP) \
- $(HW_LAYER_SRC_CPP) \
+ $(HW_LAYER_EMS_CPP) \
$(TUNERSTUDIO_SRC_CPP) \
$(CONSOLE_SRC_CPP) \
$(CONTROLLERS_SENSORS_SRC_CPP) \
diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp
index 4c6411cf1f..312f0a3deb 100644
--- a/firmware/hw_layer/can_hw.cpp
+++ b/firmware/hw_layer/can_hw.cpp
@@ -11,12 +11,16 @@
#include "main.h"
#include "can_hw.h"
-#include "pin_repository.h"
#include "string.h"
+
+#if EFI_PROD_CODE
+
+#include "pin_repository.h"
#include "engine_state.h"
#include "can_header.h"
#include "engine_configuration.h"
#include "vehicle_speed.h"
+#endif /* EFI_PROD_CODE */
#if EFI_CAN_SUPPORT || defined(__DOXYGEN__)
@@ -100,6 +104,8 @@ static void sendMessage() {
sendMessage2(8);
}
+#if EFI_PROD_CODE
+
static void canDashboardBMW(void) {
//BMW Dashboard
commonTxInit(CAN_BMW_E46_SPEED);
@@ -237,9 +243,15 @@ static void canInfo(void) {
scheduleMsg(&logger, "CAN rx count %d/tx ok %d/tx not ok %d", canReadCounter, can_write_ok, can_write_not_ok);
}
+#endif /* EFI_PROD_CODE */
+
+
void initCan(void) {
+#if EFI_PROD_CODE
if (!engineConfiguration->isCanEnabled)
return;
+#endif /* EFI_PROD_CODE */
+
initLogging(&logger, "CAN driver");
#if STM32_CAN_USE_CAN2
@@ -251,12 +263,15 @@ void initCan(void) {
#endif
canStart(&EFI_CAN_DEVICE, &canConfig);
+#if EFI_PROD_CODE
+
chThdCreateStatic(canTreadStack, sizeof(canTreadStack), NORMALPRIO, (tfunc_t) canThread, NULL);
mySetPadMode2("CAN TX", boardConfiguration->canTxPin, PAL_MODE_ALTERNATE(EFI_CAN_TX_AF));
mySetPadMode2("CAN RX", boardConfiguration->canRxPin, PAL_MODE_ALTERNATE(EFI_CAN_RX_AF));
addConsoleAction("caninfo", canInfo);
+#endif /* EFI_PROD_CODE */
}
#endif /* EFI_CAN_SUPPORT */
diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp
index 44a20d8f0a..36b3ed8101 100644
--- a/firmware/hw_layer/hardware.cpp
+++ b/firmware/hw_layer/hardware.cpp
@@ -262,7 +262,7 @@ void initHardware(Logging *logger, Engine *engine) {
initOutputPins();
#if EFI_MAX_31855
- initMax31855(boardConfiguration);
+ initMax31855(getSpiDevice(boardConfiguration->max31855spiDevice), boardConfiguration->max31855_cs);
#endif /* EFI_MAX_31855 */
diff --git a/firmware/hw_layer/hw_layer.mk b/firmware/hw_layer/hw_layer.mk
index e509ae6844..8c27f6e2b7 100644
--- a/firmware/hw_layer/hw_layer.mk
+++ b/firmware/hw_layer/hw_layer.mk
@@ -1,8 +1,7 @@
-HW_LAYERSRC = $(PROJECT_DIR)/hw_layer/pin_repository.c \
+HW_LAYER_EMS = $(PROJECT_DIR)/hw_layer/pin_repository.c \
$(PROJECT_DIR)/hw_layer/io_pins.c \
$(PROJECT_DIR)/hw_layer/mcp3208.c \
- $(PROJECT_DIR)/hw_layer/max31855.c \
$(PROJECT_DIR)/hw_layer/lcd/lcd_HD44780.c \
$(PROJECT_DIR)/hw_layer/microsecond_timer.c \
$(PROJECT_DIR)/hw_layer/serial_over_usb/usbcfg.c \
@@ -14,7 +13,7 @@ HW_LAYERSRC = $(PROJECT_DIR)/hw_layer/pin_repository.c \
$(PROJECT_DIR)/hw_layer/gpio_helper.c \
$(PROJECT_DIR)/hw_layer/wave_analyzer_hw.c
-HW_LAYER_SRC_CPP = $(PROJECT_DIR)/hw_layer/hardware.cpp \
+HW_LAYER_EMS_CPP = $(PROJECT_DIR)/hw_layer/hardware.cpp \
$(PROJECT_DIR)/hw_layer/can_hw.cpp \
$(PROJECT_DIR)/hw_layer/adc_inputs.cpp \
$(PROJECT_DIR)/hw_layer/board_test.cpp \
@@ -22,6 +21,10 @@ HW_LAYER_SRC_CPP = $(PROJECT_DIR)/hw_layer/hardware.cpp \
$(PROJECT_DIR)/hw_layer/trigger_input.cpp \
$(PROJECT_DIR)/hw_layer/HIP9011.cpp \
$(PROJECT_DIR)/hw_layer/vehicle_speed.cpp \
+ $(PROJECT_DIR)/hw_layer/max31855.cpp \
$(PROJECT_DIR)/hw_layer/stepper.cpp \
$(PROJECT_DIR)/hw_layer/stm32f4/mpu_util.cpp
+
+HW_LAYER_EGT_CPP = $(PROJECT_DIR)/hw_layer/can_hw.cpp \
+ $(PROJECT_DIR)/hw_layer/max31855.cpp
\ No newline at end of file
diff --git a/firmware/hw_layer/max31855.c b/firmware/hw_layer/max31855.cpp
similarity index 88%
rename from firmware/hw_layer/max31855.c
rename to firmware/hw_layer/max31855.cpp
index ac5383ed8c..0c85db40f7 100644
--- a/firmware/hw_layer/max31855.c
+++ b/firmware/hw_layer/max31855.cpp
@@ -1,5 +1,5 @@
/**
- * @file max31855.c
+ * @file max31855.cpp
* @brief MAX31855 Thermocouple-to-Digital Converter driver
*
*
@@ -13,12 +13,15 @@
*/
#include "max31855.h"
-#include "pin_repository.h"
-#include "settings.h"
-#include "hardware.h"
// that's for swap
#include "tunerstudio_algo.h"
+#if EFI_PROD_CODE
+#include "hardware.h"
+#include "settings.h"
+#include "pin_repository.h"
+#endif /* EFI_PROD_CODE */
+
#if EFI_MAX_31855
#define EGT_ERROR_VALUE -1000
@@ -29,7 +32,10 @@ static Logging logger;
static SPIConfig spiConfig[MAX31855_CS_COUNT];
-static void showEgtInfo(board_configuration_s *boardConfiguration) {
+EXTERN_ENGINE;
+
+static void showEgtInfo(void) {
+#if EFI_PROD_CODE
printSpiState(&logger, boardConfiguration);
scheduleMsg(&logger, "EGT spi: %d", boardConfiguration->max31855spiDevice);
@@ -37,10 +43,9 @@ static void showEgtInfo(board_configuration_s *boardConfiguration) {
for (int i = 0; i < MAX31855_CS_COUNT; i++) {
if (boardConfiguration->max31855_cs[i] != GPIO_UNASSIGNED) {
scheduleMsg(&logger, "%d ETG @ %s", i, hwPortname(boardConfiguration->max31855_cs[i]));
-
}
-
}
+#endif
}
// bits D17 and D3 are always expected to be zero
@@ -135,22 +140,21 @@ static void egtRead(void) {
}
}
-void initMax31855(board_configuration_s *boardConfiguration) {
+void initMax31855(SPIDriver *drv, egt_cs_array_t max31855_cs) {
initLogging(&logger, "EGT");
- driver = getSpiDevice(boardConfiguration->max31855spiDevice);
+ driver = drv;
-
- addConsoleActionP("egtinfo", (VoidPtr) showEgtInfo, boardConfiguration);
+ addConsoleAction("egtinfo", (Void) showEgtInfo);
addConsoleAction("egtread", (Void) egtRead);
turnOnSpi(SPI_DEVICE_3);
for (int i = 0; i < MAX31855_CS_COUNT; i++) {
- if (boardConfiguration->max31855_cs[i] != GPIO_UNASSIGNED) {
+ if (max31855_cs[i] != GPIO_UNASSIGNED) {
- initSpiCs(&spiConfig[i], boardConfiguration->max31855_cs[i]);
+ initSpiCs(&spiConfig[i], max31855_cs[i]);
spiConfig[i].cr1 = SPI_BaudRatePrescaler_8;
}
diff --git a/firmware/hw_layer/max31855.h b/firmware/hw_layer/max31855.h
index 853514f035..6d50d28dea 100644
--- a/firmware/hw_layer/max31855.h
+++ b/firmware/hw_layer/max31855.h
@@ -16,7 +16,7 @@ extern "C"
{
#endif /* __cplusplus */
-void initMax31855(board_configuration_s *boardConfiguration);
+void initMax31855(SPIDriver *drv, egt_cs_array_t max31855_cs);
uint16_t getEgtValue(int egtChannel);
#ifdef __cplusplus