PER Firmware
Loading...
Searching...
No Matches
main.h
Go to the documentation of this file.
1
8#ifndef MAIN_H
9#define MAIN_H
10
11#include "phal_G4/gpio/gpio.h"
12
13// Status indicators
14#define HEARTBEAT_LED_PORT (GPIOC)
15#define HEARTBEAT_LED_PIN (15)
16#define CONNECTION_LED_PORT (GPIOC)
17#define CONNECTION_LED_PIN (14)
18#define ERROR_LED_PORT (GPIOC)
19#define ERROR_LED_PIN (13)
20
21// Switch control lines
22#define CTRL1_PORT (GPIOA)
23#define CTRL1_PIN (9)
24#define CTRL3_PORT (GPIOC)
25#define CTRL3_PIN (9)
26#define CTRL4_PORT (GPIOA)
27#define CTRL4_PIN (10)
28#define CTRL5_PORT (GPIOC)
29#define CTRL5_PIN (8)
30#define CTRL6_PORT (GPIOB)
31#define CTRL6_PIN (15)
32#define CTRL7_PORT (GPIOC)
33#define CTRL7_PIN (6)
34#define CTRL8_PORT (GPIOC)
35#define CTRL8_PIN (7)
36#define CTRL9_PORT (GPIOC)
37#define CTRL9_PIN (10)
38#define CTRL10_PORT (GPIOC)
39#define CTRL10_PIN (11)
40#define CTRL11_PORT (GPIOB)
41#define CTRL11_PIN (14)
42#define CTRL12_PORT (GPIOC)
43#define CTRL12_PIN (12)
44#define CTRL13_PORT (GPIOD)
45#define CTRL13_PIN (2)
46#define CTRL14_PORT (GPIOC)
47#define CTRL14_PIN (5)
48#define CTRL15_PORT (GPIOB)
49#define CTRL15_PIN (1)
50#define CTRL16_PORT (GPIOB)
51#define CTRL16_PIN (2)
52#define CTRL17_PORT (GPIOB)
53#define CTRL17_PIN (10)
54#define CTRL18_PORT (GPIOC)
55#define CTRL18_PIN (3)
56#define CTRL19_PORT (GPIOC)
57#define CTRL19_PIN (2)
58#define CTRL20_PORT (GPIOC)
59#define CTRL20_PIN (0)
60#define CTRL21_PORT (GPIOB)
61#define CTRL21_PIN (11)
62
63// Analog inputs
64#define LVBATT_VS_PORT (GPIOA)
65#define LVBATT_VS_PIN (3)
66#define LVBATT_VS_ADC_CHANNEL (4)
67#define LVBATT_CS_PORT (GPIOB)
68#define LVBATT_CS_PIN (0)
69#define LVBATT_CS_ADC_CHANNEL (12)
70#define MUX1_OUT_PORT (GPIOC)
71#define MUX1_OUT_PIN (4)
72#define MUX1_OUT_ADC_CHANNEL (5)
73#define MUX2_OUT_PORT (GPIOA)
74#define MUX2_OUT_PIN (4)
75#define MUX2_OUT_ADC_CHANNEL (17)
76
77// Analog multiplexer controls
78#define MUX1_CTRL_A_PORT (GPIOA)
79#define MUX1_CTRL_A_PIN (5)
80#define MUX1_CTRL_B_PORT (GPIOA)
81#define MUX1_CTRL_B_PIN (6)
82#define MUX1_CTRL_C_PORT (GPIOA)
83#define MUX1_CTRL_C_PIN (7)
84#define MUX2_CTRL_A_PORT (GPIOC)
85#define MUX2_CTRL_A_PIN (1)
86#define MUX2_CTRL_B_PORT (GPIOB)
87#define MUX2_CTRL_B_PIN (4)
88#define MUX2_CTRL_C_PORT (GPIOA)
89#define MUX2_CTRL_C_PIN (15)
90#define MUX2_CTRL_D_PORT (GPIOB)
91#define MUX2_CTRL_D_PIN (5)
92
93typedef struct {
94 uint16_t lvbatt_vs;
97
98typedef struct {
99 uint16_t mux1_out;
100 uint16_t mux2_out;
102extern volatile raw_adc2_values_t raw_adc2_values;
103
104typedef struct {
105 uint16_t lvbatt_cs;
107extern volatile raw_adc3_values_t raw_adc3_values;
108
109static constexpr float ADC_VREF_V = 3.3f;
110static constexpr float ADC_MAX_COUNTS = 4095.0f;
111
112
113#endif // MAIN_H
volatile raw_adc2_values_t raw_adc2_values
Definition main.c:77
volatile raw_adc1_values_t raw_adc1_values
Definition main.c:61
static constexpr float ADC_VREF_V
Definition main.h:109
volatile raw_adc3_values_t raw_adc3_values
Definition main.c:94
static constexpr float ADC_MAX_COUNTS
Definition main.h:110
G4 GPIO public API.
Definition main.c:58
uint16_t lvbatt_vs
Definition main.h:94
Definition main.c:74
uint16_t mux1_out
Definition main.h:99
uint16_t mux2_out
Definition main.h:100
Definition main.c:91
uint16_t lvbatt_cs
Definition main.h:105