1+ #pragma once
2+
3+ /*----------------------------------------------------------------------------
4+ * STM32 pins number
5+ *----------------------------------------------------------------------------*/
6+ #define PA0 PIN_A0
7+ #define PA1 PIN_A1
8+ #define PA2 PIN_A2
9+ #define PA3 PIN_A3
10+ #define PA4 PIN_A4
11+ #define PA5 PIN_A5
12+ #define PA6 PIN_A6
13+ #define PA7 PIN_A7
14+ #define PA8 8
15+ #define PA9 9
16+ #define PA10 10
17+ #define PA11 11
18+ #define PA12 12
19+ #define PA13 13
20+ #define PA14 14
21+ #define PA15 15
22+ #define PB0 PIN_A8
23+ #define PB1 PIN_A9
24+ #define PB2 PIN_A10
25+ #define PB3 19
26+ #define PB4 20
27+ #define PB5 21
28+ #define PB6 22
29+ #define PB7 23
30+ #define PB8 24
31+ #define PB9 25
32+ #define PB10 26
33+ #define PB11 PIN_A11
34+ #define PB12 PIN_A12
35+ #define PB13 29
36+ #define PB14 PIN_A13
37+ #define PB15 PIN_A14
38+ #define PC4 PIN_A15
39+ #define PC6 33
40+ #define PC10 34
41+ #define PC11 35
42+ #define PC13 36
43+ #define PC14 37
44+ #define PC15 38
45+ #define PF0 PIN_A16
46+ #define PF1 PIN_A17
47+ #define PG10 41
48+
49+ // Alternate pins number
50+ #define PA0_ALT1 (PA0 | ALT1)
51+ #define PA1_ALT1 (PA1 | ALT1)
52+ #define PA2_ALT1 (PA2 | ALT1)
53+ #define PA3_ALT1 (PA3 | ALT1)
54+ #define PA4_ALT1 (PA4 | ALT1)
55+ #define PA6_ALT1 (PA6 | ALT1)
56+ #define PA7_ALT1 (PA7 | ALT1)
57+ #define PA7_ALT2 (PA7 | ALT2)
58+ #define PA7_ALT3 (PA7 | ALT3)
59+ #define PA9_ALT1 (PA9 | ALT1)
60+ #define PA10_ALT1 (PA10 | ALT1)
61+ #define PA11_ALT1 (PA11 | ALT1)
62+ #define PA11_ALT2 (PA11 | ALT2)
63+ #define PA12_ALT1 (PA12 | ALT1)
64+ #define PA12_ALT2 (PA12 | ALT2)
65+ #define PA13_ALT1 (PA13 | ALT1)
66+ #define PA15_ALT1 (PA15 | ALT1)
67+ #define PB0_ALT1 (PB0 | ALT1)
68+ #define PB0_ALT2 (PB0 | ALT2)
69+ #define PB1_ALT1 (PB1 | ALT1)
70+ #define PB1_ALT2 (PB1 | ALT2)
71+ #define PB3_ALT1 (PB3 | ALT1)
72+ #define PB4_ALT1 (PB4 | ALT1)
73+ #define PB4_ALT2 (PB4 | ALT2)
74+ #define PB5_ALT1 (PB5 | ALT1)
75+ #define PB5_ALT2 (PB5 | ALT2)
76+ #define PB6_ALT1 (PB6 | ALT1)
77+ #define PB6_ALT2 (PB6 | ALT2)
78+ #define PB7_ALT1 (PB7 | ALT1)
79+ #define PB7_ALT2 (PB7 | ALT2)
80+ #define PB8_ALT1 (PB8 | ALT1)
81+ #define PB8_ALT2 (PB8 | ALT2)
82+ #define PB9_ALT1 (PB9 | ALT1)
83+ #define PB9_ALT2 (PB9 | ALT2)
84+ #define PB9_ALT3 (PB9 | ALT3)
85+ #define PB11_ALT1 (PB11 | ALT1)
86+ #define PB13_ALT1 (PB13 | ALT1)
87+ #define PB14_ALT1 (PB14 | ALT1)
88+ #define PB15_ALT1 (PB15 | ALT1)
89+ #define PB15_ALT2 (PB15 | ALT2)
90+ #define PC6_ALT1 (PC6 | ALT1)
91+ #define PC10_ALT1 (PC10 | ALT1)
92+ #define PC11_ALT1 (PC11 | ALT1)
93+ #define PC13_ALT1 (PC13 | ALT1)
94+
95+ #define NUM_DIGITAL_PINS 42
96+ #define NUM_ANALOG_INPUTS 18
97+
98+
99+
100+ /* Alias */
101+ #define A_PHASE_UL PB15
102+ #define A_PHASE_UH PA10
103+ #define A_PHASE_VL PB14
104+ #define A_PHASE_VH PA9
105+ #define A_PHASE_WL PB13
106+ #define A_PHASE_WH PA8
107+
108+ #define PIN_SS_DRIVER PC14 //Gate driver chip select
109+ #define PIN_NFAULT PC15 //Gate driver fault pin
110+
111+ #define A_VBUS PB0 //Pin to sense supply voltage, connected to COMP4
112+ #define BRAKE_RESISTOR PB1 //Brake resistor control, also connected to output of COMP4
113+ #define BRAKE_AF 3 //Alternate function 8
114+ #define BRAKE_DAC DAC3 //DAC3
115+ #define BRAKE_DAC_CHAN DAC_CHANNEL_2 //Channel 2
116+ #define BRAKE_COMP COMP4 //Comparator 4
117+ #define BRAKE_COMP_PLUS COMP_INPUT_PLUS_IO1
118+ #define BRAKE_COMP_MINUS COMP_INPUT_MINUS_DAC1_CH2
119+
120+ #define VBUS_MUL_FACTOR 23 //Multiply the adc voltage read by this value to get the supply voltage
121+
122+ //BEMF inputs are connected to comparators with a 10k resistor to phase, 1k to 3.3v and 1k to gnd, so it's offset slightly above ground
123+
124+ #define A_CURRU PA2 //Current sense connected to phase U
125+ #define A_BEMFU PA0 //BEMF connected to comparator 3 for phase U
126+
127+ #define A_CURRV PA7 //Current sense connected to phase V
128+ #define A_BEMFV PA1 //BEMF connected to comparator 4 for phase V
129+
130+ #define A_CURRW PC4 //Current sense connected to phase W
131+ #define A_BEMFW PA3 //BEMF connected to comparator 1 for phase W
132+
133+ #define A_POTENTIOMETER PB2
134+ #define A_TEMPERATURE PB12
135+
136+ //Voltage divider based on CMFA104J4250HANT and 100k resistor
137+ #define NTC_B_CONSTANT 4250 //B = ln(R/R0)/(1/T-1/T0)
138+ #define NTC_T0 (273.15f+25)//Kelvin
139+ #ifndef NTC_DIVIDER_BALANCE
140+ #define NTC_DIVIDER_BALANCE (22.f/100.f) //R1 (value of the other resistance in the voltage divider) over R0 (resistance of NTC at T0)
141+ #endif
142+
143+ #define CAN_RX PB8
144+ #define CAN_TX PB9
145+ #define CAN_PWR PC13 //Pin must be high to turn on CAN transceiver
146+
147+ #define SWDIO PA13
148+ #define SWCLK PA14
149+
150+ #define ENCODER_A PA6 //TIM3_CH1 @ J5
151+ #define ENCODER_B PA4 //TIM3_CH2 @ J5
152+ #define ENCODER_Z PB3 //TIM3_ETR @ J5
153+
154+ // On-board LED pin number
155+ #ifndef LED_BUILTIN
156+ #define LED_BUILTIN PB6 //Drive low to turn on
157+ #endif
158+
159+ //Magnetic angle sensor gets dedicated SPI
160+ #define PIN_MISO_MAG_ANGLE PC11 //SPI3_MISO
161+ #define PIN_CLK_MAG_ANGLE PC10 //SPI3_CLK
162+ #define PIN_SS_MAG_ANGLE PC6 //GPIO
163+ /**
164+ * Not actually connected to MOSI, but Arduino needs this since it doesn't expect RX-only SPI
165+ * Call pinmap_pinout(digitalPinToPinName(PIN_SPI_MOSI), PinMap_SPI_MOSI); to reset the pin to the other SPI if needed
166+ */
167+
168+ #define PIN_MOSI_MAG_ANGLE PB5_ALT1
169+
170+ // SPI definitions
171+ #ifndef PIN_SPI_SS
172+ #define PIN_SPI_SS PNUM_NOT_DEFINED
173+ #endif
174+ #ifndef PIN_SPI_SS1
175+ #define PIN_SPI_SS1 PNUM_NOT_DEFINED
176+ #endif
177+ #ifndef PIN_SPI_SS2
178+ #define PIN_SPI_SS2 PNUM_NOT_DEFINED
179+ #endif
180+ #ifndef PIN_SPI_SS3
181+ #define PIN_SPI_SS3 PNUM_NOT_DEFINED
182+ #endif
183+ #ifndef PIN_SPI_MOSI
184+ #define PIN_SPI_MOSI PB5 //SPI1_MOSI @ J6
185+ #endif
186+ #ifndef PIN_SPI_MISO
187+ #define PIN_SPI_MISO PB4 //SPI1_MISO @ J6
188+ #endif
189+ #ifndef PIN_SPI_SCK
190+ #define PIN_SPI_SCK PA5 //SPI1_SCK @ J6
191+ #endif
192+
193+ //Qwiic-standard I2C on J1
194+ // I2C definitions
195+ #ifndef PIN_WIRE_SDA
196+ #define PIN_WIRE_SDA PB7
197+ #endif
198+ #ifndef PIN_WIRE_SCL
199+ #define PIN_WIRE_SCL PA15
200+ #endif
201+
202+ // Timer Definitions
203+ // Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin
204+ #ifndef TIMER_TONE
205+ #define TIMER_TONE TIM6
206+ #endif
207+ #ifndef TIMER_SERVO
208+ #define TIMER_SERVO TIM7
209+ #endif
210+
211+ // UART Definitions
212+ #define SERIAL_UART_INSTANCE 0
213+
214+ //LPUART1 on J7
215+ // Default pin used for 'Serial' instance (ex: ST-Link)
216+ // Mandatory for Firmata
217+ #ifndef PIN_SERIAL_RX
218+ #define PIN_SERIAL_RX PB10
219+ #endif
220+ #ifndef PIN_SERIAL_TX
221+ #define PIN_SERIAL_TX PB11
222+ #endif
223+
224+ /* HAL configuration */
225+ #define HSE_VALUE (8000000UL)
226+
227+ /* Extra HAL modules */
228+ #if !defined(HAL_DAC_MODULE_DISABLED )
229+ #define HAL_DAC_MODULE_ENABLED
230+ #endif
231+ #if !defined(HAL_FDCAN_MODULE_DISABLED )
232+ #define HAL_FDCAN_MODULE_ENABLED
233+ #endif
0 commit comments