Midnight Sun Firmware
Loading...
Searching...
No Matches
bms_hw_defs.h
1#pragma once
2
3/************************************************************************************************
4 * @file bms_hw_defs.h
5 *
6 * @brief Header file for BMS hardware definitions
7 *
8 * @date 2025-01-12
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13
14/* Inter-component Headers */
15
16/* Intra-component Headers */
17
24/************************************************************************************************
25 * BMS CAN definitions
26 ************************************************************************************************/
27
29#define BMS_CAN_RX \
30 { .port = GPIO_PORT_B, .pin = 8 }
31
33#define BMS_CAN_TX \
34 { .port = GPIO_PORT_B, .pin = 9 }
35
36/************************************************************************************************
37 * Current sense I2C definitions
38 ************************************************************************************************/
39
41#define CURRENT_SENSE_I2C_PORT I2C_PORT_1
42
44#define CURRENT_SENSE_I2C_SDA_GPIO \
45 { .port = GPIO_PORT_B, .pin = 11 }
46
48#define CURRENT_SENSE_I2C_SCL_GPIO \
49 { .port = GPIO_PORT_B, .pin = 10 }
50
52#define CURRENT_SENSE_MAX17261_I2C_ADDR (0x36U)
53
54/************************************************************************************************
55 * AFEs (LTC6811) SPI definitions
56 ************************************************************************************************/
57
59#define LTC_AFE_SPI_PORT SPI_PORT_2
60
62#define LTC_AFE_SPI_BAUDRATE SPI_BAUDRATE_1_25MHZ
63
65#define LTC_AFE_SPI_SDO_GPIO \
66 { .port = GPIO_PORT_B, .pin = 15 }
67
69#define LTC_AFE_SPI_SDI_GPIO \
70 { .port = GPIO_PORT_B, .pin = 14 }
71
73#define LTC_AFE_SPI_SCK_GPIO \
74 { .port = GPIO_PORT_B, .pin = 13 }
75
77#define LTC_AFE_SPI_CS_GPIO \
78 { .port = GPIO_PORT_B, .pin = 12 }
79
80/************************************************************************************************
81 * Motor Controller SPI definitions
82 ************************************************************************************************/
83
85#define MCP2515_SPI_PORT SPI_PORT_3
86
88#define MCP2515_SPI_SDO_GPIO \
89 { .port = GPIO_PORT_B, .pin = 5 }
90
92#define MCP2515_SPI_SDI_GPIO \
93 { .port = GPIO_PORT_B, .pin = 4 }
94
96#define MCP2515_SPI_SCK_GPIO \
97 { .port = GPIO_PORT_B, .pin = 3 }
98
100#define MCP2515_SPI_CS_GPIO \
101 { .port = GPIO_PORT_A, .pin = 15 }
102
103/************************************************************************************************
104 * Relays/Contactor definitions
105 ************************************************************************************************/
106
108#define BMS_PRECHARGE_STATUS_GPIO \
109 { .port = GPIO_PORT_A, .pin = 3 }
110
112#define BMS_PRECHARGE_RELAY_ENABLE_GPIO \
113 { .port = GPIO_PORT_A, .pin = 9 }
114
116#define BMS_PRECHARGE_RELAY_SENSE_GPIO \
117 { .port = GPIO_PORT_A, .pin = 10 }
118
120#define BMS_POS_RELAY_ENABLE_GPIO \
121 { .port = GPIO_PORT_A, .pin = 4 }
122
124#define BMS_POS_RELAY_SENSE_GPIO \
125 { .port = GPIO_PORT_A, .pin = 15 }
126
128#define BMS_NEG_RELAY_ENABLE_GPIO \
129 { .port = GPIO_PORT_A, .pin = 13 }
130
132#define BMS_NEG_RELAY_SENSE_GPIO \
133 { .port = GPIO_PORT_A, .pin = 12 }
134
136#define BMS_SOLAR_RELAY_ENABLE_GPIO \
137 { .port = GPIO_PORT_C, .pin = 13 }
138
140#define BMS_SOLAR_RELAY_SENSE_GPIO \
141 { .port = GPIO_PORT_A, .pin = 6 }
142
143/************************************************************************************************
144 * Killswitch definitions
145 ************************************************************************************************/
146
148#define BMS_KILLSWITCH_SENSE_GPIO \
149 { .port = GPIO_PORT_A, .pin = 11 }
150
151/************************************************************************************************
152 * Aux sense definitions
153 ************************************************************************************************/
154
156#define BMS_AUX_BATT_VOLTAGE_ADC \
157 { .port = GPIO_PORT_A, .pin = 5 }
158
159/************************************************************************************************
160 * Fan definitions
161 ************************************************************************************************/
162
164#define BMS_FAN_SENSE_1_GPIO \
165 { .port = GPIO_PORT_B, .pin = 0 }
166
168#define BMS_FAN_SENSE_2_GPIO \
169 { .port = GPIO_PORT_B, .pin = 1 }
170
172#define BMS_FAN_PWM_GPIO \
173 { .port = GPIO_PORT_A, .pin = 8 }
174
175/************************************************************************************************
176 * Battery pack definitions
177 ************************************************************************************************/
178
180#define NUM_SERIES_MODULES 9U
181
183#define NUM_SERIES_CELLS_IN_MODULE 4U
184
186#define NUM_SERIES_CELLS (NUM_SERIES_CELLS_IN_MODULE * NUM_SERIES_MODULES)
187
189#define NUM_PARALLEL_CELLS 8U
190
192#define CELL_CAPACITY_MAH 4850U
193
195#define PACK_CAPACITY_MAH (CELL_CAPACITY_MAH * NUM_PARALLEL_CELLS)
196