Skip to content

Commit 526cf1c

Browse files
committed
Add support for Calypso test mode
1 parent 8390dc0 commit 526cf1c

10 files changed

Lines changed: 722 additions & 515 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
9595
"Core/Src/analyzer.c"
9696
"Core/Src/can_handler.c"
9797
"Core/Src/can_messages_tx.c"
98+
"Core/Src/can_messages_rx.c"
9899
"Core/Src/charging.c"
99100
"Core/Src/compute.c"
100101
"Core/Src/hv_plate.c"

Core/Inc/analyzer.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "app_threadx.h"
55
#include "datastructs.h"
6+
#include "can_messages_rx.h"
67

78
/**
89
* @brief Get the chip data for the given chip
@@ -54,6 +55,22 @@ void calc_cell_resistances(analyzer_t *analyzer, acc_data_t *acc_data,
5455
*/
5556
void update_chip_status(analyzer_t *analyzer, acc_data_t *acc_data);
5657

58+
#if (TEST_MODE_ENABLED)
59+
/**
60+
* @brief Updates Alpha cell data from a test CAN frame.
61+
*/
62+
void update_emulated_alpha_cell_data(
63+
analyzer_t *analyzer,
64+
const shepherd_bms_emulated_alpha_cell_data_t *cell_data);
65+
66+
/**
67+
* @brief Updates Beta cell data from a test CAN frame.
68+
*/
69+
void update_emulated_beta_cell_data(
70+
analyzer_t *analyzer,
71+
const shepherd_bms_emulated_beta_cell_data_t *cell_data);
72+
#endif // TEST_MODE_ENABLED
73+
5774
void vAnalyzer(ULONG thread_input);
5875

5976
#endif

Core/Inc/bms_config.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#ifndef BMS_CONFIG_H
22
#define BMS_CONFIG_H
33

4-
#define DEBUG_MODE_ENABLED true
4+
/* Test mode feature flag. */
5+
#ifndef TEST_MODE_ENABLED
6+
#define TEST_MODE_ENABLED false
7+
#endif // TEST_MODE_ENABLED
8+
9+
/* Debug mode feature flag. */
10+
#ifndef DEBUG_MODE
11+
#define DEBUG_MODE true
12+
#endif // DEBUG_MODE
13+
14+
#define DEBUG_MODE_ENABLED \
15+
((DEBUG_MODE) && (TEST_MODE_ENABLED == false))
516
#define DEBUG_STATS
617

718
// Hardware definition

Core/Inc/can_handler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "u_tx_can.h"
55
#include "app_threadx.h"
6+
#include "bms_config.h"
67

78
/**
89
* @brief Callback to be called when a message is received on CAN line 1.
@@ -79,6 +80,11 @@
7980
#define FAULT_TIMER_CANID 0x6F9
8081
#define FAULT_TIMER_SIZE 4
8182

83+
#if (TEST_MODE_ENABLED)
84+
#define CALYPSO_ALPHA_CELL_DATA_CANID 0x451
85+
#define CALYPSO_BETA_CELL_DATA_CANID 0x452
86+
#endif // TEST_MODE_ENABLED
87+
8288
void can_receive_callback(FDCAN_HandleTypeDef *hcan, uint32_t RxFifo0ITs);
8389

8490
/**

0 commit comments

Comments
 (0)