stub enough for tests to build?

This commit is contained in:
Matthew Kennedy 2023-08-09 13:24:21 -07:00
parent a84e35edb5
commit 5e1bf36caa
8 changed files with 51 additions and 5 deletions

View File

@ -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.

View File

@ -1,6 +1,8 @@
#pragma once
#include "hal.h"
#include <cstdint>
#include <cstddef>
#include "port_shared.h"
#include "wideband_config.h"

View File

@ -1,4 +1,9 @@
#include "ch.h"
#pragma once
#if WB_PROD
#include "hal.h"
const CANConfig& GetCanConfig();
#endif // WB_PROD

View File

@ -1,3 +1,2 @@
WIDEBANDSRC = \
$(FIRMWARE_DIR)/sampling.cpp \
$(FIRMWARE_DIR)/heater_control.cpp \

View File

@ -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

3
test/io_pins.h Normal file
View File

@ -0,0 +1,3 @@
#pragma once
// Nothing here - stub file since tests have no IO

View File

@ -1,6 +1,18 @@
#include <gtest/gtest.h>
#include "sampling.h"
#include "port.h"
SensorType GetSensorType()
{
return SensorType::LSU49;
}
int GetESRSupplyR()
{
// Nernst AC injection resistor value
return 22000;
}
TEST(Sampler, Basic)
{

View File

@ -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)