Skip to content

Commit a4456ae

Browse files
committed
src/rcc/enable.rs: fix some issues for stm32l4+
1 parent b14db75 commit a4456ae

File tree

1 file changed

+82
-9
lines changed

1 file changed

+82
-9
lines changed

src/rcc/enable.rs

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,12 @@ bus! {
108108
GPIOD => (AHB2, gpioden, gpiodsmen, gpiodrst), // 3
109109
GPIOE => (AHB2, gpioeen, gpioesmen, gpioerst), // 4
110110
GPIOH => (AHB2, gpiohen, gpiohsmen, gpiohrst), // 7
111-
ADC1 => (AHB2, adcen, adcfssmen, adcrst), // 13
112111
AES => (AHB2, aesen, aessmen, aesrst), // 16
113112
RNG => (AHB2, rngen, rngsmen, rngrst), // 18
114113

115114
TIM2 => (APB1R1, tim2en, tim2smen, tim2rst), // 0
116115
TIM6 => (APB1R1, tim6en, tim6smen, tim6rst), // 4
117116
TIM7 => (APB1R1, tim7en, tim7smen, tim7rst), // 5
118-
LCD => (APB1R1, lcden, lcdsmen, lcdrst), // 9
119117
WWDG => (APB1R1, wwdgen, wwdgsmen,), // 11
120118
SPI2 => (APB1R1, spi2en, spi2smen, spi2rst), // 14
121119
SPI3 => (APB1R1, spi3en, sp3smen, spi3rst), // 15 // TODO: fix typo
@@ -130,10 +128,9 @@ bus! {
130128
LPTIM1 => (APB1R1, lptim1en, lptim1smen, lptim1rst), // 31
131129

132130
LPUART1 => (APB1R2, lpuart1en, lpuart1smen, lpuart1rst), // 0
133-
SWPMI1 => (APB1R2, swpmi1en, swpmi1smen, swpmi1rst), // 2
134131
LPTIM2 => (APB1R2, lptim2en, lptim2smen, lptim2rst), // 5
132+
135133
SYSCFG => (APB2, syscfgen, syscfgsmen, syscfgrst), // 0
136-
FIREWALL => (APB2, firewallen,,), // 7
137134
TIM1 => (APB2, tim1en, tim1smen, tim1rst), // 11
138135
SPI1 => (APB2, spi1en, spi1smen, spi1rst), // 12
139136
USART1 => (APB2, usart1en, usart1smen, usart1rst), // 14
@@ -142,6 +139,45 @@ bus! {
142139
SAI1 => (APB2, sai1en, sai1smen, sai1rst), // 21
143140
}
144141

142+
// L4x1, L4x2, L4x3, L4x5 or L4x6
143+
#[cfg(not(any(
144+
// feature = "stm32l4p5",
145+
// feature = "stm32l4q5",
146+
// feature = "stm32l4r5",
147+
// feature = "stm32l4s5",
148+
// feature = "stm32l4r7",
149+
// feature = "stm32l4s7",
150+
feature = "stm32l4r9",
151+
feature = "stm32l4s9",
152+
)))]
153+
bus! {
154+
ADC1 => (AHB2, adcen, adcfssmen, adcrst), // 13
155+
156+
LCD => (APB1R1, lcden, lcdsmen, lcdrst), // 9
157+
158+
SWPMI1 => (APB1R2, swpmi1en, swpmi1smen, swpmi1rst), // 2
159+
160+
FIREWALL => (APB2, firewallen,,), // 7
161+
}
162+
163+
// L4+
164+
#[cfg(any(
165+
// feature = "stm32l4p5",
166+
// feature = "stm32l4q5",
167+
// feature = "stm32l4r5",
168+
// feature = "stm32l4s5",
169+
// feature = "stm32l4r7",
170+
// feature = "stm32l4s7",
171+
feature = "stm32l4r9",
172+
feature = "stm32l4s9",
173+
))]
174+
bus! {
175+
ADC => (AHB2, adcen, adcfssmen, adcrst), // 13
176+
177+
FIREWALL => (APB2, fwen,,), // 7
178+
LTCD => (APB2, ltdcen, ltdcsmen, ltdcrst), // 26
179+
}
180+
145181
// L4x5 or L4x6
146182
#[cfg(any(
147183
feature = "stm32l475",
@@ -215,9 +251,19 @@ bus! {
215251
SDMMC => (APB2, sdmmcen, sdmmcsmen, sdmmcrst), // 10
216252
}
217253

218-
// L4x1, L4x2, L4x5, or L4x6 (L4+ assumed)
219-
220-
#[cfg(not(any(feature = "stm32l433", feature = "stm32l443")))]
254+
// L4x1, L4x2, L4x5, or L4x6
255+
#[cfg(not(any(
256+
feature = "stm32l433",
257+
feature = "stm32l443",
258+
// feature = "stm32l4p5",
259+
// feature = "stm32l4q5",
260+
// feature = "stm32l4r5",
261+
// feature = "stm32l4s5",
262+
// feature = "stm32l4r7",
263+
// feature = "stm32l4s7",
264+
feature = "stm32l4r9",
265+
feature = "stm32l4s9",
266+
)))]
221267
bus! {
222268
ADC2 => (AHB2, adcen, adcfssmen, adcrst), // 13
223269
QUADSPI => (AHB3, qspien, qspismen, qspirst), // 8
@@ -291,13 +337,40 @@ bus! {
291337
GPIOI => (AHB2, gpioien, gpioismen, gpioirst), // 8
292338
OTG_FS_GLOBAL => (AHB2, otgfsen, otgfssmen, otgfsrst), // 12 // TODO: absent in x5
293339
DCMI => (AHB2, dcmien, dcmismen, dcmirst), // 14
294-
HASH => (AHB2, hash1en, hash1smen, hash1rst), // 17
295340

296-
CAN2 => (APB1R1, can2en, can2smen, can2rst), // 26
297341
DAC => (APB1R1, dac1en, dac1smen, dac1rst), // 29
298342

299343
I2C4 => (APB1R2, i2c4en, i2c4smen, i2c4rst), // 1
344+
}
345+
346+
#[cfg(any(
347+
feature = "stm32l476",
348+
feature = "stm32l486",
349+
feature = "stm32l496",
350+
feature = "stm32l4a6",
351+
))]
352+
bus! {
353+
CAN2 => (APB1R1, can2en, can2smen, can2rst), // 26
354+
355+
HASH => (AHB2, hash1en, hash1smen, hash1rst), // 17
300356

301357
SDMMC1 => (APB2, sdmmcen, sdmmcsmen, sdmmcrst), // 10
302358
DFSDM1 => (APB2, dfsdmen, dfsdmsmen, dfsdmrst), // 24
303359
}
360+
361+
#[cfg(any(
362+
// feature = "stm32l4p5",
363+
// feature = "stm32l4q5",
364+
// feature = "stm32l4r5",
365+
// feature = "stm32l4s5",
366+
// feature = "stm32l4r7",
367+
// feature = "stm32l4s7",
368+
feature = "stm32l4r9",
369+
feature = "stm32l4s9",
370+
))]
371+
bus! {
372+
HASH => (AHB2, hashen, hashsmen, hashrst), // 17
373+
SDMMC1 => (AHB2, sdmmc1en, sdmmc1smen, sdmmc1rst), // 22
374+
375+
DFSDM1 => (APB2, dfsdm1en, dfsdm1smen, dfsdm1rst), // 24
376+
}

0 commit comments

Comments
 (0)