diff --git a/.gitmodules b/.gitmodules index 2707dec..6ffe0a4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ -[submodule "Unity"] - path = Unity - url = https://github.com/ThrowTheSwitch/Unity.git [submodule "mod"] path = mod - url = git@github.com:SunDevilRocketry/mod.git + url = https://github.com/SunDevilRocketry/mod.git [submodule "lib"] path = lib - url = git@github.com:SunDevilRocketry/lib.git + url = https://github.com/SunDevilRocketry/lib.git +[submodule "test"] + path = test + url = https://github.com/SunDevilRocketry/test.git diff --git a/Unity b/Unity deleted file mode 160000 index 3852926..0000000 --- a/Unity +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3852926c00f210905db5feb7a9fa5d5dbf7963ea diff --git a/app/hotfire/rev4/main.c b/app/hotfire/rev4/main.c index 4fd6b1a..696a2b0 100644 --- a/app/hotfire/rev4/main.c +++ b/app/hotfire/rev4/main.c @@ -24,7 +24,7 @@ #include "main.h" #include "init.h" #include "sdr_pin_defines_L0002.h" -#include "sdr_error.h" +#include "error_sdr.h" #include "valve_control.h" /* Low-level modules */ diff --git a/app/hotfire/rev5/Makefile b/app/hotfire/rev5/Makefile index 9362d6b..e1431d4 100644 --- a/app/hotfire/rev5/Makefile +++ b/app/hotfire/rev5/Makefile @@ -61,10 +61,12 @@ protocol.c \ data_logger.c \ terminal.c \ $(INIT_DIR)/init.c \ -$(UTIL_DIR)/sdr_error.c \ $(MOD_DIR)/commands/commands.c \ +$(MOD_DIR)/common/common.c \ +$(MOD_DIR)/error_sdr/error_sdr.c \ $(MOD_DIR)/ignition/ignition.c \ $(MOD_DIR)/led/led.c \ +$(MOD_DIR)/math_sdr/math_sdr.c \ $(MOD_DIR)/power/power.c \ $(MOD_DIR)/flash/flash.c \ $(MOD_DIR)/loadcell/loadcell.c \ @@ -175,10 +177,13 @@ C_INCLUDES = \ -I$(LIB_DIR)/Drivers/CMSIS/Device/ST/STM32H7xx/Include \ -I$(LIB_DIR)/Drivers/CMSIS/Include \ -I$(MOD_DIR)/commands \ +-I$(MOD_DIR)/common \ +-I$(MOD_DIR)/error_sdr \ -I$(MOD_DIR)/ignition \ -I$(MOD_DIR)/flash \ -I$(MOD_DIR)/led \ -I$(MOD_DIR)/loadcell \ +-I$(MOD_DIR)/math_sdr \ -I$(MOD_DIR)/power \ -I$(MOD_DIR)/pressure \ -I$(MOD_DIR)/rs485 \ diff --git a/app/hotfire/rev5/disarm.c b/app/hotfire/rev5/disarm.c index 7d64511..c11c9a2 100644 --- a/app/hotfire/rev5/disarm.c +++ b/app/hotfire/rev5/disarm.c @@ -23,7 +23,7 @@ #include "valve_control.h" #include "pressure.h" #include "sensor.h" -#include "sdr_error.h" +#include "error_sdr.h" #include "led.h" /*------------------------------------------------------------------------------ diff --git a/app/hotfire/rev5/main.c b/app/hotfire/rev5/main.c index 968ad1b..63213ba 100644 --- a/app/hotfire/rev5/main.c +++ b/app/hotfire/rev5/main.c @@ -24,7 +24,7 @@ #include "main.h" #include "init.h" #include "sdr_pin_defines_L0002.h" -#include "sdr_error.h" +#include "error_sdr.h" #include "valve_control.h" #include "terminal.h" @@ -67,6 +67,7 @@ volatile bool lox_purge_flag = false; /* LOX tank purge */ volatile bool kbottle_closed_flag = false; /* KBottle is closed */ volatile bool tanks_safe_flag = false; /* Tanks are safe */ volatile bool telreq_wait_flag = false; /* Controller busy */ +volatile uint32_t tdelta, previous_time; /* Sensor timing */ /* Sensor data */ SENSOR_DATA_PING_PONG sensor_ping_pong_buffer = {0}; @@ -156,6 +157,10 @@ flash_status = FLASH_OK; thermo_status = THERMO_OK; terminal_status = TERMINAL_OK; +/* Sensor */ +tdelta = 0; +previous_time = 0; + /*------------------------------------------------------------------------------ External Hardware Initializations @@ -216,20 +221,20 @@ if ( vc_connect() != VC_OK ) Error_Handler( ERROR_VC_OFFLINE_ERROR ); } -/* Enable the main valve stepper motor drivers */ +// /* Enable the main valve stepper motor drivers */ if ( vc_enable_main_valves() != VC_OK ) { Error_Handler( ERROR_VC_INIT_ERROR ); } -/* Calibrate the main propellant valves */ +// /* Calibrate the main propellant valves */ if ( vc_calibrate_main_valves() != VC_OK ) { Error_Handler( ERROR_VC_INIT_ERROR ); } -HAL_Delay( VALVE_CALIBRATION_TIME ); /* Wait for calibration to finish */ + HAL_Delay( VALVE_CALIBRATION_TIME ); /* Wait for calibration to finish */ -/* Reset solenoid positions */ +// /* Reset solenoid positions */ if ( vc_reset_solenoids() != VC_OK ) { Error_Handler( ERROR_VC_INIT_ERROR ); @@ -336,4 +341,5 @@ while (1) /******************************************************************************* * END OF FILE * -*******************************************************************************/ \ No newline at end of file + +*******************************************************************************/ diff --git a/app/hotfire/rev5/terminal.c b/app/hotfire/rev5/terminal.c index ab5192c..25050e9 100644 --- a/app/hotfire/rev5/terminal.c +++ b/app/hotfire/rev5/terminal.c @@ -25,7 +25,7 @@ #include "main.h" #include "sdr_pin_defines_L0002.h" #include "init.h" -#include "sdr_error.h" +#include "error_sdr.h" #include "terminal.h" /* Low-level modules */ diff --git a/app/ping/rev5/main.h b/app/ping/rev5/main.h index 591bcd8..1f6f436 100644 --- a/app/ping/rev5/main.h +++ b/app/ping/rev5/main.h @@ -24,7 +24,7 @@ extern "C" { Standard Includes ------------------------------------------------------------------------------*/ #include "stm32h7xx_hal.h" -#include "sdr_error.h" +#include "error_sdr.h" /*------------------------------------------------------------------------------ diff --git a/app/terminal/rev5/Makefile b/app/terminal/rev5/Makefile index 7cae405..c955d18 100644 --- a/app/terminal/rev5/Makefile +++ b/app/terminal/rev5/Makefile @@ -47,13 +47,15 @@ UTIL_DIR = $(LIB_DIR)/util C_SOURCES = \ main.c \ $(INIT_DIR)/init.c \ -$(UTIL_DIR)/sdr_error.c \ +$(MOD_DIR)/common/common.c \ +$(MOD_DIR)/error_sdr/error_sdr.c \ $(MOD_DIR)/commands/commands.c \ $(MOD_DIR)/ignition/ignition.c \ $(MOD_DIR)/led/led.c \ $(MOD_DIR)/power/power.c \ $(MOD_DIR)/flash/flash.c \ $(MOD_DIR)/loadcell/loadcell.c \ +$(MOD_DIR)/math_sdr/math_sdr.c \ $(MOD_DIR)/pressure/pressure.c \ $(MOD_DIR)/rs485/rs485.c \ $(MOD_DIR)/sensor/sensor.c \ @@ -160,10 +162,13 @@ C_INCLUDES = \ -I$(LIB_DIR)/Drivers/CMSIS/Device/ST/STM32H7xx/Include \ -I$(LIB_DIR)/Drivers/CMSIS/Include \ -I$(MOD_DIR)/commands \ +-I$(MOD_DIR)/common \ +-I$(MOD_DIR)/error_sdr \ -I$(MOD_DIR)/ignition \ -I$(MOD_DIR)/flash \ -I$(MOD_DIR)/led \ -I$(MOD_DIR)/loadcell \ +-I$(MOD_DIR)/math_sdr \ -I$(MOD_DIR)/power \ -I$(MOD_DIR)/pressure \ -I$(MOD_DIR)/rs485 \ diff --git a/app/terminal/rev5/main.c b/app/terminal/rev5/main.c index fb9fb12..e168837 100644 --- a/app/terminal/rev5/main.c +++ b/app/terminal/rev5/main.c @@ -24,7 +24,7 @@ #include "main.h" #include "sdr_pin_defines_L0002.h" #include "init.h" -#include "sdr_error.h" +#include "error_sdr.h" /* Low-level modules */ #include "commands.h" @@ -54,6 +54,9 @@ UART_HandleTypeDef huart1; /* USB UART handler struct */ UART_HandleTypeDef huart2; /* Valve controller UART handle */ UART_HandleTypeDef huart4; /* Wireless interface UART handle */ +/* Sensor */ +volatile uint32_t tdelta, previous_time; + /*------------------------------------------------------------------------------ Application entry point @@ -89,6 +92,9 @@ THERMO_STATUS thermo_status; /* Thermocouple status code */ USB_STATUS usb_status; /* Status of USB operations */ VALVE_STATUS valve_status; /* Valve API return codes */ +/* Sensor */ +tdelta, previous_time = 0; + /*------------------------------------------------------------------------------ MCU Initialization diff --git a/init/rev5/config/Src/stm32h7xx_hal_msp.c b/init/rev5/config/Src/stm32h7xx_hal_msp.c index b2d7ee1..b8fc678 100644 --- a/init/rev5/config/Src/stm32h7xx_hal_msp.c +++ b/init/rev5/config/Src/stm32h7xx_hal_msp.c @@ -14,7 +14,7 @@ Standard Includes ------------------------------------------------------------------------------*/ #include "main.h" -#include "sdr_error.h" +#include "error_sdr.h" /*------------------------------------------------------------------------------ diff --git a/init/rev5/init.c b/init/rev5/init.c index f19bce6..7f749e3 100644 --- a/init/rev5/init.c +++ b/init/rev5/init.c @@ -20,7 +20,7 @@ #include "sdr_pin_defines_L0002.h" #include "main.h" #include "init.h" -#include "sdr_error.h" +#include "error_sdr.h" /*------------------------------------------------------------------------------ diff --git a/lib b/lib index e1b5252..acc1e39 160000 --- a/lib +++ b/lib @@ -1 +1 @@ -Subproject commit e1b5252e5a92fbad1d18617da64b8e0dec4d4cd7 +Subproject commit acc1e396e16f88800653915d3912b6846e70f5d7 diff --git a/mod b/mod index d6d443e..d31010a 160000 --- a/mod +++ b/mod @@ -1 +1 @@ -Subproject commit d6d443ec5538f4876a3983c4b0f6f93e670f31bb +Subproject commit d31010a5a72b99a7bfbde6dfdb3dcbf4640a83b4 diff --git a/test b/test new file mode 160000 index 0000000..abd31c2 --- /dev/null +++ b/test @@ -0,0 +1 @@ +Subproject commit abd31c2fddfef2504cc3642575403cd8ed55b2df diff --git a/test/mock/lib/Drivers/STM32H7xx_HAL_Driver/Src/mock_stm32h7xx_hal_uart.c b/test/mock/lib/Drivers/STM32H7xx_HAL_Driver/Src/mock_stm32h7xx_hal_uart.c deleted file mode 100644 index ae4b975..0000000 --- a/test/mock/lib/Drivers/STM32H7xx_HAL_Driver/Src/mock_stm32h7xx_hal_uart.c +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* -* -* FILE: -* mock_stm32h7xx_hal_uart.c -* -* DESCRIPTION: -* Contains mock/stub functions for functions in stm32h7xx_hal_uart.c -* -*******************************************************************************/ - - -/*------------------------------------------------------------------------------ - Standard Includes -------------------------------------------------------------------------------*/ -#include - - -/*------------------------------------------------------------------------------ - Project Includes -------------------------------------------------------------------------------*/ -#include "stm32h7xx_hal.h" -#include "stm32h7xx_hal_conf.h" - - -/*------------------------------------------------------------------------------ - Global Variables -------------------------------------------------------------------------------*/ - -/* MOCK return values */ -static HAL_StatusTypeDef return_val__HAL_UART_Transmit = 0; - - -/*------------------------------------------------------------------------------ - Internal function prototypes -------------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------------ - API Functions -------------------------------------------------------------------------------*/ - - -/******************************************************************************* -* * -* PROCEDURE: * -* HAL_UART_Transmit * -* * -* DESCRIPTION: * -* Send an amount of data in blocking mode * -* * -*******************************************************************************/ -HAL_StatusTypeDef HAL_UART_Transmit - ( - UART_HandleTypeDef* huart, - const uint8_t* pData, - uint16_t Size , - uint32_t Timeout - ) -{ -return return_val__HAL_UART_Transmit; -} /* HAL_UART_Transmit*/ - - -/******************************************************************************* -* END OF FILE * -*******************************************************************************/ diff --git a/test/mock/terminal/rev4/main.h b/test/mock/terminal/rev4/main.h deleted file mode 100644 index 4be9bbc..0000000 --- a/test/mock/terminal/rev4/main.h +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* -* -* FILE: -* main.h -* -* DESCRIPTION: -* Processes commands recieved from a host PC, provides fine control over -* engine controller hardware resources -* -*******************************************************************************/ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MAIN_H -#define __MAIN_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*------------------------------------------------------------------------------ - Macros -------------------------------------------------------------------------------*/ - -/* General MCU HAL related macros */ -#define HAL_DEFAULT_TIMEOUT ( 1 ) /* Default timeout for polling - operations */ -#define DEF_BUFFER_SIZE ( 16 ) /* Default size of buffer arrays */ - -/*------------------------------------------------------------------------------ - MCU Pin Assignments -------------------------------------------------------------------------------*/ - -/*-------------------------------- Pins --------------------------------------*/ - -/* LED */ -#define STATUS_B_PIN GPIO_PIN_12 -#define STATUS_G_PIN GPIO_PIN_11 -#define STATUS_R_PIN GPIO_PIN_10 - -/* Ignition */ -#define FIRE_PIN GPIO_PIN_6 -#define E_CONT_PIN GPIO_PIN_7 -#define NOZ_CONT_PIN GPIO_PIN_8 -#define SP_CONT_PIN GPIO_PIN_9 - -/* Power */ -#define PWR_SRC_PIN GPIO_PIN_0 - -/* External Flash */ -#define FLASH_SS_PIN GPIO_PIN_12 -#define FLASH_SCK_PIN GPIO_PIN_10 -#define FLASH_MISO_PIN GPIO_PIN_14 -#define FLASH_MOSI_PIN GPIO_PIN_15 -#define FLASH_WP_PIN GPIO_PIN_12 -#define FLASH_HOLD_PIN GPIO_PIN_13 - -/* Pressure transducers */ -#define PRESSURE_GAIN0_PIN GPIO_PIN_0 -#define PRESSURE_GAIN1_PIN GPIO_PIN_1 -#define PRESSURE_GAIN2_PIN GPIO_PIN_3 -#define PRESSURE_GAIN3_PIN GPIO_PIN_4 -#define PRESSURE_GAIN4_PIN GPIO_PIN_5 -#define PRESSURE_GAIN5_PIN GPIO_PIN_6 -#define PRESSURE_GAIN6_PIN GPIO_PIN_7 -#define PRESSURE_GAIN7_PIN GPIO_PIN_8 -#define PRESSURE_GAIN_ALL_PINS ( (uint16_t) 0x01FB ) -#define PRESSURE_MUXA_PIN GPIO_PIN_9 -#define PRESSURE_MUXB_PIN GPIO_PIN_10 -#define PRESSURE_MUXC_PIN GPIO_PIN_11 -#define PRESSURE_MUX_ALL_PINS ( (uint16_t) 0x0E00 ) - -/*-------------------------------- Ports--------------------------------------*/ - -/* LED */ -#define STATUS_GPIO_PORT GPIOE - -/* Ignition */ -#define FIRE_GPIO_PORT GPIOE -#define E_CONT_GPIO_PORT GPIOE -#define NOZ_CONT_GPIO_PORT GPIOE -#define SP_CONT_GPIO_PORT GPIOE - -/* Power */ -#define PWR_SRC_GPIO_PORT GPIOE - -/* External Flash */ -#define FLASH_SS_GPIO_PORT GPIOB -#define FLASH_SCK_GPIO_PORT GPIOB -#define FLASH_MISO_GPIO_PORT GPIOB -#define FLASH_MOSI_GPIO_PORT GPIOB -#define FLASH_WP_GPIO_PORT GPIOD -#define FLASH_HOLD_GPIO_PORT GPIOD - -/* Pressure transducers */ -#define PRESSURE_GPIO_PORT GPIOD - - -/*------------------------------------------------------------------------------ - Exported functions prototypes -------------------------------------------------------------------------------*/ -void Error_Handler(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __MAIN_H */ diff --git a/test/mock/terminal/rev4/mod/led/led.h b/test/mock/terminal/rev4/mod/led/led.h deleted file mode 100644 index 1093489..0000000 --- a/test/mock/terminal/rev4/mod/led/led.h +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* -* -* FILE: -* led.h -* -* DESCRIPTION: -* Contains API functions to set the behavior of the on-board rgb led -* -*******************************************************************************/ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef LED_H -#define LED_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*------------------------------------------------------------------------------ - Typdefs -------------------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------------------ - Macros -------------------------------------------------------------------------------*/ - - -/*------------------------------------------------------------------------------ - Function Prototypes -------------------------------------------------------------------------------*/ - -/* Display Red to indicate software exception */ -void led_error_assert - ( - void - ); - -/* Sets the RGB LED to blue to be triggered during debugging */ -void led_debug_assert - ( - void - ); - -/* Reset the led */ -void led_reset - ( - void - ); - -/* Flash Red to indicate that the code hit a block of code not meant to be run - without blocking the program from running */ -void led_error_flash - ( - void - ); - -/* Flash the RGB led */ -void led_flash - ( - void - ); - - -#endif /* LED_H */ diff --git a/test/mock/terminal/rev4/mod/pressure/mock_pressure.c b/test/mock/terminal/rev4/mod/pressure/mock_pressure.c deleted file mode 100644 index 35142b9..0000000 --- a/test/mock/terminal/rev4/mod/pressure/mock_pressure.c +++ /dev/null @@ -1,241 +0,0 @@ -/******************************************************************************* -* -* FILE: -* mock_pressure.c -* -* DESCRIPTION: -* Contains mock/stub functions for functions in pressure.c -* -*******************************************************************************/ - - -/*------------------------------------------------------------------------------ - Standard Includes -------------------------------------------------------------------------------*/ -#include - -/*------------------------------------------------------------------------------ - Project Includes -------------------------------------------------------------------------------*/ -#include "pressure.h" - -/*------------------------------------------------------------------------------ - Global Variables -------------------------------------------------------------------------------*/ - -/* MOCK return values */ -static uint32_t return_val__pressure_get_pt_reading = 0; -static PRESSURE_STATUS return_val__pressure_poll_pts = 0; -static uint8_t return_val__pressure_get_gain = 0; -static uint16_t return_val__mux_map = 0; -static PRESSURE_STATUS return_val__sample_adc_poll = 0; -static uint16_t return_val__amplifier_gain_map = 0; - -/* Amplifier gain settings */ -static uint8_t pt_gains[] = { 0, 0, 0, 0, 0, 0, 0, 0 } ; - - -/*------------------------------------------------------------------------------ - Internal function prototypes -------------------------------------------------------------------------------*/ - -/* PT number to GPIO pin butmask mapping */ -static inline uint16_t mux_map - ( - PRESSURE_PT_NUM pt_num - ); - -/* Sample ADC in polling mode */ -static PRESSURE_STATUS sample_adc_poll - ( - uint16_t num_samples, - uint32_t* psample_buffer - ); - -/* Mapping from PT number to amplifer gain GPIO pin bitmask */ -static uint16_t amplifier_gain_map - ( - uint8_t gain_setting - ); - - -/*------------------------------------------------------------------------------ - API Functions -------------------------------------------------------------------------------*/ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_get_pt_reading * -* * -* DESCRIPTION: * -* Get a single pressure transducer reading * -* * -*******************************************************************************/ -uint32_t pressure_get_pt_reading - ( - PRESSURE_PT_NUM pt_num - ) -{ -return return_val__pressure_get_pt_reading; -} /* pressure_get_pt_reading */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_poll_pts * -* * -* DESCRIPTION: * -* Get readings from all pressure transducers * -* * -*******************************************************************************/ -PRESSURE_STATUS pressure_poll_pts - ( - uint32_t* pPT_readings /* array of size NUM_PTS */ - ) -{ -return return_val__pressure_poll_pts; -} /* pressure_poll_pts */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_set_gain * -* * -* DESCRIPTION: * -* Set the amplifier gain for a single pressure transducer * -* * -*******************************************************************************/ -void pressure_set_gain - ( - PRESSURE_PT_NUM pt_num, - uint8_t gain - ) -{ - -} /* pressure_set_gain */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_set_all_gains * -* * -* DESCRIPTION: * -* Set the amplifier gain for all pressure transducers * -* * -*******************************************************************************/ -void pressure_set_all_gains - ( - uint8_t gains[] - ) -{ - -} /* pressure_set_gains */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_get_gain * -* * -* DESCRIPTION: * -* Get the gain for a single pressure transducer * -* * -*******************************************************************************/ -uint8_t pressure_get_gain - ( - PRESSURE_PT_NUM pt_num - ) -{ -return return_val__pressure_get_gain; -} /* pressure_get_gain */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* pressure_get_all_gains * -* * -* DESCRIPTION: * -* Get the gain for all pressure transducers * -* * -*******************************************************************************/ -void pressure_get_all_gains - ( - uint8_t* pgains - ) -{ - -} /* pressure_get_all_gains */ - - -/*------------------------------------------------------------------------------ - Internal procedures -------------------------------------------------------------------------------*/ - - -/******************************************************************************* -* * -* PROCEDURE: * -* amplifer_gain_map * -* * -* DESCRIPTION: * -* Mapping from pressure transducer number to amplifer gain GPIO pin * -* bitmask. ex. gain setting 128 -> PRESSURE_GAIN7_PIN * -* * -*******************************************************************************/ -static uint16_t amplifier_gain_map - ( - uint8_t gain_setting - ) -{ -return return_val__amplifier_gain_map; -} /* amplifier_gain_map */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* mux_map * -* * -* DESCRIPTION: * -* Mapping from pressure transducer number to mutliplexor GPIO pin * -* bitmask. ex. PTNUM5 -> 101 -> GPIO_PIN_C | GPIO_PIN_A * -* * -*******************************************************************************/ -static inline uint16_t mux_map - ( - PRESSURE_PT_NUM pt_num - ) -{ -return return_val__mux_map; -} /* mux_map */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* sample_adc_poll * -* * -* DESCRIPTION: * -* Sample the pressure transducer ADC a specified number of times in * -* polling mode * -* * -*******************************************************************************/ -static PRESSURE_STATUS sample_adc_poll - ( - uint16_t num_samples, - uint32_t* psample_buffer - ) -{ -return return_val__sample_adc_poll; -} /* sample_adc_poll */ - - -/******************************************************************************* -* END OF FILE * -*******************************************************************************/ diff --git a/test/terminal/rev4/mod/sensor/Makefile b/test/terminal/rev4/mod/sensor/Makefile deleted file mode 100644 index 944c0b9..0000000 --- a/test/terminal/rev4/mod/sensor/Makefile +++ /dev/null @@ -1,134 +0,0 @@ -################################################################ -# -# sensor.c unit tests (based on gcc) -# -################################################################ - - -################################################################ -# target -################################################################ -TARGET = test_sensor - - -################################################################ -# build variables -################################################################ - -# Debug build? -DEBUG = 1 -# Optimization -OPT = -Og - - -################################################################ -# paths -################################################################ - -# build folder -BUILD_DIR = build - -# base directory -ROOT_DIR = ../../../../.. - -# terminal directory -TERMINAL_DIR = $(ROOT_DIR)/terminal/rev4 - -# terminal mocked directory -MOCK_DIR = $(ROOT_DIR)/unit_tests/mock/terminal/rev4 - -# library directory -LIB_DIR = $(ROOT_DIR)/lib - - -################################################################ -# source -################################################################ - -# C sources -C_SOURCES = \ -test_sensor.c \ -$(ROOT_DIR)/Unity/src/unity.c \ -$(MOCK_DIR)/mod/pressure/mock_pressure.c \ -$(ROOT_DIR)/unit_tests/mock/lib/Drivers/STM32H7xx_HAL_Driver/Src/mock_stm32h7xx_hal_uart.c - - -################################################################ -# Compiler -################################################################ -CC = gcc - - -################################################################ -# C flags -################################################################ - -# C Includes -C_INCLUDES = \ --I. \ --I$(TERMINAL_DIR) \ --I$(TERMINAL_DIR)/config/Inc \ --I$(LIB_DIR)/Drivers/STM32H7xx_HAL_Driver/Inc \ --I$(LIB_DIR)/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy \ --I$(LIB_DIR)/Drivers/CMSIS/Device/ST/STM32H7xx/Include \ --I$(LIB_DIR)/Drivers/CMSIS/Include \ --I$(TERMINAL_DIR)/mod/commands/ \ --I$(TERMINAL_DIR)/mod/ignition/ \ --I$(TERMINAL_DIR)/mod/led/ \ --I$(TERMINAL_DIR)/mod/power/ \ --I$(TERMINAL_DIR)/mod/flash/ \ --I$(TERMINAL_DIR)/mod/pressure/ \ --I$(TERMINAL_DIR)/mod/sensor/ \ --I$(ROOT_DIR)/Unity/src/ \ --I$(MOCK_DIR) - -# Preprocessor definitions -C_DEFS = \ --DUSE_HAL_DRIVER \ --DSTM32H750xx \ --DUNIT_TEST - -CFLAGS = $(C_INCLUDES) $(C_DEFS) $(OPT) -Wall -g - -# Disable some warnings -CFLAGS += -Wno-pointer-to-int-cast -CFLAGS += -Wno-int-to-pointer-cast -CFLAGS += -Wno-unused-function -CFLAGS += -Wno-unused-variable - -# build all -all: $(BUILD_DIR)/$(TARGET) - - -################################################################ -# Build the application -################################################################ - -# Setup the path for c files -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) -vpath %.c $(sort $(dir $(C_SOURCES))) - -$(BUILD_DIR)/%.o: %.c $(BUILD_DIR) - $(CC) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/$(TARGET): $(OBJECTS) - $(CC) $(OBJECTS) -o $@ - -$(BUILD_DIR): - mkdir $@ - -test: - echo "$(BUILD_DIR)" - - -################################################################ -# clean up -################################################################ - -clean: - -rm -fR $(BUILD_DIR) - - -################################################################ -# EOF -################################################################ diff --git a/test/terminal/rev4/mod/sensor/run_test.py b/test/terminal/rev4/mod/sensor/run_test.py deleted file mode 100644 index c5adda2..0000000 --- a/test/terminal/rev4/mod/sensor/run_test.py +++ /dev/null @@ -1,3 +0,0 @@ -import subprocess - -subprocess.run(["build/test_sensor"]) diff --git a/test/terminal/rev4/mod/sensor/test_cases/readings_to_bytes.txt b/test/terminal/rev4/mod/sensor/test_cases/readings_to_bytes.txt deleted file mode 100644 index d25b927..0000000 --- a/test/terminal/rev4/mod/sensor/test_cases/readings_to_bytes.txt +++ /dev/null @@ -1,2 +0,0 @@ -{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}, -{{236,236,236,236,236,236,236,236,236,236},{0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec,0x00,0x00,0x00,0xec}} diff --git a/test/terminal/rev4/mod/sensor/test_sensor.c b/test/terminal/rev4/mod/sensor/test_sensor.c deleted file mode 100644 index 772985d..0000000 --- a/test/terminal/rev4/mod/sensor/test_sensor.c +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************* -* -* FILE: -* test_sensor.c -* -* DESCRIPTION: -* Unit tests for functions in the sensor module -* -*******************************************************************************/ - -/*------------------------------------------------------------------------------ -Standard Includes -------------------------------------------------------------------------------*/ -#include -#include - - -/*------------------------------------------------------------------------------ -Project Includes -------------------------------------------------------------------------------*/ -#include "unity.h" -#include "main.h" - -/* CMSIS/HAL */ -#include "stm32h7xx_hal.h" -#include "stm32h7xx_hal_conf.h" - -/* File under test */ -#include "sensor.c" - - -/*------------------------------------------------------------------------------ -Macros -------------------------------------------------------------------------------*/ -#define NUM_TESTS_readings_to_bytes ( 2 ) - - -/*------------------------------------------------------------------------------ -Global Variables -------------------------------------------------------------------------------*/ -UART_HandleTypeDef huart1; /* USB UART handler struct */ - - -/*------------------------------------------------------------------------------ -Function Prototypes -------------------------------------------------------------------------------*/ - -/* Code to run prior to any test */ -void setUp - ( - void - ); - -/* Code to run after tests */ -void tearDown - ( - void - ); - -/* tests the reading_to_bytes function in sensor.c */ -void test_readings_to_bytes - ( - void - ); - - -/*------------------------------------------------------------------------------ -Types -------------------------------------------------------------------------------*/ - -/* readings_to_bytes test data type */ -typedef struct - { - uint32_t Src_buffer[ NUM_SENSORS ]; - uint8_t Dst_buffer[ 4*NUM_SENSORS ]; - } readings_to_bytes__test_type; - - -/*------------------------------------------------------------------------------ -Procedures -------------------------------------------------------------------------------*/ - - -/******************************************************************************* -* * -* PROCEDURE: * -* setUp * -* * -* DESCRIPTION: * -* Code to run prior to any test * -* * -*******************************************************************************/ -void setUp - ( - void - ) -{ -} /* setUp */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* tearDown * -* * -* DESCRIPTION: * -* Code to run after tests * -* * -*******************************************************************************/ -void tearDown - ( - void - ) -{ -} /* tearDown */ - - -/******************************************************************************* -* * -* PROCEDURE: * -* test_readings_to_bytes * -* * -* DESCRIPTION: * -* tests the reading_to_bytes function in sensor.c * -* * -*******************************************************************************/ -void test_readings_to_bytes - ( - void - ) -{ -/*------------------------------------------------------------------------------ -Local Variables -------------------------------------------------------------------------------*/ -uint8_t Dst_buffer[ 4*NUM_SENSORS ]; -uint32_t Src_buffer[ NUM_SENSORS ]; -uint8_t return_val[ 4*NUM_SENSORS ]; - -/*------------------------------------------------------------------------------ -Initializations -------------------------------------------------------------------------------*/ -readings_to_bytes__test_type test_data[] = -{ -#include "test_cases/readings_to_bytes.txt" -}; - -/*------------------------------------------------------------------------------ -Run Tests -------------------------------------------------------------------------------*/ -for ( int test_num = 0; test_num < NUM_TESTS_readings_to_bytes; ++test_num ) - { - /* Initialize input/output */ - memcpy( &Src_buffer[0], &( test_data[test_num].Src_buffer[0] ), sizeof( Src_buffer ) ); - memcpy( &Dst_buffer[0], &( test_data[test_num].Dst_buffer[0] ), sizeof( Dst_buffer ) ); - memset( &return_val[0], 0 , sizeof( return_val ) ); - - /* Call the fut */ - readings_to_bytes( &return_val[0], &Src_buffer[0] ); - - /* Verify correct output */ - TEST_ASSERT_EQUAL_UINT8_ARRAY( Dst_buffer, return_val, 4*NUM_SENSORS ); - } - -} /* test_readings_to_bytes */ - - -/*------------------------------------------------------------------------------ -Run Tests -------------------------------------------------------------------------------*/ -int main - ( - void - ) -{ -UNITY_BEGIN(); -RUN_TEST( test_readings_to_bytes ); -return UNITY_END(); -} /* main */ - - -/******************************************************************************* -* END OF FILE * -*******************************************************************************/