diff --git a/firmware/Makefile b/firmware/Makefile index 63f8956..d12df37 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -14,6 +14,8 @@ ifeq ($(USE_OPT),) USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -fsingle-precision-constant endif +USE_OPT += -DWB_PROD=1 + # C specific options here (added to USE_OPT). ifeq ($(USE_COPT),) USE_COPT = @@ -163,6 +165,7 @@ CPPSRC = $(ALLCPPSRC) \ console/binary/tunerstudio_io_serial.cpp \ console/binary/tunerstudio_commands.cpp \ sampling_thread.cpp \ + heater_control.cpp \ main.cpp # List ASM source files here. diff --git a/firmware/boards/port.h b/firmware/boards/port.h index 4bf2f45..370ded2 100644 --- a/firmware/boards/port.h +++ b/firmware/boards/port.h @@ -1,6 +1,8 @@ #pragma once -#include "hal.h" +#include +#include + #include "port_shared.h" #include "wideband_config.h" diff --git a/firmware/boards/port_shared.h b/firmware/boards/port_shared.h index 19c16f0..862faa9 100644 --- a/firmware/boards/port_shared.h +++ b/firmware/boards/port_shared.h @@ -1,4 +1,9 @@ -#include "ch.h" +#pragma once + +#if WB_PROD + #include "hal.h" const CANConfig& GetCanConfig(); + +#endif // WB_PROD diff --git a/firmware/wideband.mk b/firmware/wideband.mk index 023ded1..eb7c74b 100644 --- a/firmware/wideband.mk +++ b/firmware/wideband.mk @@ -1,3 +1,2 @@ WIDEBANDSRC = \ $(FIRMWARE_DIR)/sampling.cpp \ - $(FIRMWARE_DIR)/heater_control.cpp \ diff --git a/test/Makefile b/test/Makefile index be0afc1..1f9b685 100644 --- a/test/Makefile +++ b/test/Makefile @@ -37,6 +37,7 @@ INCDIR += \ $(PROJECT_DIR)/googletest/googletest/include \ $(RUSEFI_LIB_INC) \ $(FIRMWARE_DIR) \ + $(FIRMWARE_DIR)/boards \ # User may want to pass in a forced value for SANITIZE ifeq ($(SANITIZE),) @@ -63,6 +64,8 @@ ifeq ($(USE_OPT),) USE_OPT += -Werror=missing-field-initializers endif +USE_OPT += -DWB_PROD=0 + # C specific options here (added to USE_OPT). ifeq ($(USE_COPT),) USE_COPT = -std=gnu99 -fgnu89-inline @@ -70,7 +73,7 @@ endif # C++ specific options here (added to USE_OPT). ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -std=gnu++2a -fno-rtti -fno-use-cxa-atexit + USE_CPPOPT = -std=c++17 -fno-rtti -fno-use-cxa-atexit endif # Enable address sanitizer for C++ files, but not on Windows since x86_64-w64-mingw32-g++ doesn't support it. @@ -137,7 +140,7 @@ BIN = $(CP) -O binary CWARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wmissing-prototypes -Wold-style-definition # Define C++ warning options here -CPPWARN = -Wall -Wextra -Werror -pedantic -Wno-error=sign-compare +CPPWARN = -Wall -Wextra -Werror -Wno-error=sign-compare # # Compiler settings diff --git a/test/io_pins.h b/test/io_pins.h new file mode 100644 index 0000000..9bd00b8 --- /dev/null +++ b/test/io_pins.h @@ -0,0 +1,3 @@ +#pragma once + +// Nothing here - stub file since tests have no IO diff --git a/test/tests/test_sampler.cpp b/test/tests/test_sampler.cpp index fd420e3..ee48f30 100644 --- a/test/tests/test_sampler.cpp +++ b/test/tests/test_sampler.cpp @@ -1,6 +1,18 @@ #include #include "sampling.h" +#include "port.h" + +SensorType GetSensorType() +{ + return SensorType::LSU49; +} + +int GetESRSupplyR() +{ + // Nernst AC injection resistor value + return 22000; +} TEST(Sampler, Basic) { diff --git a/test/wideband_board_config.h b/test/wideband_board_config.h new file mode 100644 index 0000000..6a7e71c --- /dev/null +++ b/test/wideband_board_config.h @@ -0,0 +1,19 @@ +#pragma once + +// Fundamental board constants +#define VCC_VOLTS (3.3f) +#define HALF_VCC (VCC_VOLTS / 2) +#define ADC_MAX_COUNT (4095) +#define ADC_OVERSAMPLE 24 + +// ******************************* +// Nernst voltage & ESR sense +// ******************************* +#define NERNST_INPUT_GAIN (1 / 2.7f) + +#define AFR_CHANNELS 1 + +// ******************************* +// Nernst voltage & ESR sense +// ******************************* +#define VM_RESISTOR_VALUE (10)