PER Firmware
Loading...
Searching...
No Matches
main.h
Go to the documentation of this file.
1
9#ifndef MAIN_H
10#define MAIN_H
11
12#include "phal_G4/adc/adc.h"
13#include "phal_G4/gpio/gpio.h"
14#include "adbms.h"
15
16// Status LEDs
17// ! silk screen flip: HB and ERR are flipped
18#define HEARTBEAT_LED_PORT (GPIOC)
19#define HEARTBEAT_LED_PIN (9)
20#define ERROR_LED_PORT (GPIOC)
21#define ERROR_LED_PIN (8)
22#define CONNECTION_LED_PORT (GPIOC)
23#define CONNECTION_LED_PIN (7)
24
25// SPI1 for BMS
26#define SPI1_SCK_PORT (GPIOA)
27#define SPI1_MISO_PORT (GPIOA)
28#define SPI1_MOSI_PORT (GPIOA)
29#define SPI1_SCK_PIN (5)
30#define SPI1_MISO_PIN (6)
31#define SPI1_MOSI_PIN (7)
32#define SPI1_CS_PORT (GPIOA)
33#define SPI1_CS_PIN (4)
34
35// SPI2 for BMS
36#define SPI2_SCK_PORT (GPIOB)
37#define SPI2_SCK_PIN (13)
38#define SPI2_MISO_PORT (GPIOB)
39#define SPI2_MISO_PIN (14)
40#define SPI2_MOSI_PORT (GPIOB)
41#define SPI2_MOSI_PIN (15)
42#define SPI2_CS_PORT (GPIOC)
43#define SPI2_CS_PIN (6)
44
45// BMS status LEDs
46#define BMS_STATUS_IND_1_PORT (GPIOC)
47#define BMS_STATUS_IND_1_PIN (5)
48#define BMS_STATUS_IND_2_PORT (GPIOB)
49#define BMS_STATUS_IND_2_PIN (0)
50#define BMS_STATUS_IND_3_PORT (GPIOB)
51#define BMS_STATUS_IND_3_PIN (1)
52#define BMS_STATUS_IND_4_PORT (GPIOB)
53#define BMS_STATUS_IND_4_PIN (2)
54#define BMS_STATUS_IND_5_PORT (GPIOB)
55#define BMS_STATUS_IND_5_PIN (10)
56
57// Analog current and voltage sense
58#define ISENSE_GPIO_PORT (GPIOC)
59#define ISENSE_GPIO_PIN (0)
60#define ISENSE_ADC_CHANNEL (6)
61#define VBATT_GPIO_PORT (GPIOC)
62#define VBATT_GPIO_PIN (1)
63#define VBATT_ADC_CHANNEL (7)
64
65// Input status pins
66#define CHARGER_CONNECTED_PORT (GPIOA)
67#define CHARGER_CONNECTED_PIN (0)
68#define NOT_PRECHARGE_COMPLETE_PORT (GPIOA)
69#define NOT_PRECHARGE_COMPLETE_PIN (2)
70#define IMD_STATUS_PORT (GPIOC)
71#define IMD_STATUS_PIN (11)
72
73// IMD PWM reading
74#define IMD_PWM_LS_PORT (GPIOC)
75#define IMD_PWM_LS_PIN (12)
76#define IMD_PWM_LS_TIM (TIM5)
77
78// BMS SDC control
79#define BMS_SDC_CTRL_PORT (GPIOA)
80#define BMS_SDC_CTRL_PIN (1)
81
82typedef struct {
83 uint16_t isense_raw;
84 uint16_t vbatt_raw;
87
89
90extern adbms_bms_t g_bms;
91
92#endif // MAIN_H
adbms_bms_t g_bms
Definition main.c:166
PHAL_ADC_Handle_t adc_handle
Definition main.c:108
volatile adc1_dma_buffer_t adc1_dma_buffer
Definition main.c:97
Primary logic and interface for ADBMS battery management system driver.
G4 ADC public API. DMA-only, DMA-first conversions.
G4 GPIO public API.
Runtime handle for one ADC instance.
Definition adc.h:56
Top-level ADBMS driver state, device handle, and pack-level statistics.
Definition adbms.h:41
Definition main.h:82
uint16_t vbatt_raw
Definition main.h:84
uint16_t isense_raw
Definition main.h:83