File tree Expand file tree Collapse file tree 7 files changed +347
-317
lines changed Expand file tree Collapse file tree 7 files changed +347
-317
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
30
30
- Allow different lengths of buffers in hal_1 SpiBus impl [ #566 ]
31
31
- Clean SPI write impls [ #774 ]
32
32
- move ` ptr() ` to ` Ptr ` trait [ #773 ]
33
- - make ` I2sFreq ` trait similar to ` BusClock ` [ #796 ]
33
+ - make ` I2sFreq ` trait similar to ` BusClock ` , refactor ` rcc::Pll ` [ #796 ] [ # 798 ]
34
34
- ` steal ` UART peripheral on ` Rx::new ` [ #768 ]
35
35
36
36
[ #248 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/248
@@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
52
52
[ #783 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/783
53
53
[ #785 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/785
54
54
[ #796 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/796
55
+ [ #798 ] : https://github.com/stm32-rs/stm32f4xx-hal/pull/798
55
56
56
57
## [ v0.21.0] - 2024-05-30
57
58
Original file line number Diff line number Diff line change @@ -167,6 +167,7 @@ gpio-f401 = [
167
167
" tim9" ,
168
168
" tim10" ,
169
169
" tim11" ,
170
+ " rcc_shared_m"
170
171
]
171
172
gpio-f410 = [
172
173
" dac" ,
@@ -230,6 +231,7 @@ gpio-f412 = [
230
231
" tim13" ,
231
232
" tim14" ,
232
233
" usart3" ,
234
+ " rcc_i2s_apb" ,
233
235
]
234
236
gpio-f413 = [
235
237
" gpiod" ,
@@ -275,6 +277,7 @@ gpio-f413 = [
275
277
" uart8" ,
276
278
" uart9" ,
277
279
" uart10" ,
280
+ " rcc_i2s_apb" ,
278
281
]
279
282
gpio-f417 = [
280
283
" gpiod" ,
@@ -313,6 +316,7 @@ gpio-f417 = [
313
316
" usart3" ,
314
317
" uart4" ,
315
318
" uart5" ,
319
+ " rcc_shared_m"
316
320
]
317
321
gpio-f427 = [
318
322
" gpiod" ,
@@ -360,6 +364,7 @@ gpio-f427 = [
360
364
" uart5" ,
361
365
" uart7" ,
362
366
" uart8" ,
367
+ " rcc_shared_m"
363
368
]
364
369
gpio-f446 = [
365
370
" gpiod" ,
@@ -401,6 +406,7 @@ gpio-f446 = [
401
406
" usart3" ,
402
407
" uart4" ,
403
408
" uart5" ,
409
+ " rcc_i2s_apb" ,
404
410
]
405
411
gpio-f469 = [
406
412
" gpiod" ,
@@ -451,6 +457,7 @@ gpio-f469 = [
451
457
" uart5" ,
452
458
" uart7" ,
453
459
" uart8" ,
460
+ " rcc_shared_m"
454
461
]
455
462
456
463
# # Support monotonic timers and other stuff that can be used by [RTICv1 framework](https://crates.io/crates/cortex-m-rtic)
@@ -490,8 +497,12 @@ fsmc_lcd = ["dep:display-interface", "dep:display-interface-04"]
490
497
# # SDIO peripheral support. See [sdio-host](https://crates.io/crates/sdio-host)
491
498
sdio-host = [" dep:sdio-host" ]
492
499
500
+ # Next features are for internal use only!!!
501
+
493
502
dfsdm = []
494
503
sai = []
504
+ rcc_shared_m = []
505
+ rcc_i2s_apb = []
495
506
496
507
adc2 = []
497
508
adc3 = []
Original file line number Diff line number Diff line change @@ -143,7 +143,6 @@ impl<I2C: Instance> I2c<I2C> {
143
143
impl < I2C : Instance > I2c < I2C > {
144
144
fn i2c_init ( & self , mode : impl Into < Mode > ) {
145
145
let mode = mode. into ( ) ;
146
- use core:: cmp;
147
146
148
147
// Make sure the I2C unit is disabled so we can configure it
149
148
self . i2c . cr1 ( ) . modify ( |_, w| w. pe ( ) . clear_bit ( ) ) ;
@@ -167,21 +166,21 @@ impl<I2C: Instance> I2c<I2C> {
167
166
match mode {
168
167
Mode :: Standard { frequency } => {
169
168
presc = 3 ;
170
- scll = cmp :: max ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 1 , 255 ) as u8 ;
169
+ scll = crate :: max_u32 ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 1 , 255 ) as u8 ;
171
170
sclh = scll - 4 ;
172
171
sdadel = 2 ;
173
172
scldel = 4 ;
174
173
}
175
174
Mode :: Fast { frequency } => {
176
175
presc = 1 ;
177
- scll = cmp :: max ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 1 , 255 ) as u8 ;
176
+ scll = crate :: max_u32 ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 1 , 255 ) as u8 ;
178
177
sclh = scll - 6 ;
179
178
sdadel = 2 ;
180
179
scldel = 3 ;
181
180
}
182
181
Mode :: FastPlus { frequency } => {
183
182
presc = 0 ;
184
- scll = cmp :: max ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 4 , 255 ) as u8 ;
183
+ scll = crate :: max_u32 ( ( ( ( FREQ >> presc) >> 1 ) / frequency. raw ( ) ) - 4 , 255 ) as u8 ;
185
184
sclh = scll - 2 ;
186
185
sdadel = 0 ;
187
186
scldel = 2 ;
Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ where
56
56
57
57
impl I2sFreq for rcc:: APB1 {
58
58
fn try_i2s_freq ( clocks : & Clocks ) -> Option < Hertz > {
59
- #[ cfg( not( any ( feature = "gpio-f412" , feature = "gpio-f413" , feature = "gpio-f446" ) ) ) ]
59
+ #[ cfg( not( feature = "rcc_i2s_apb" ) ) ]
60
60
{
61
61
clocks. i2s_clk ( )
62
62
}
63
- #[ cfg( any ( feature = "gpio-f412" , feature = "gpio-f413" , feature = "gpio-f446" ) ) ]
63
+ #[ cfg( feature = "rcc_i2s_apb" ) ]
64
64
{
65
65
clocks. i2s_apb1_clk ( )
66
66
}
@@ -69,11 +69,11 @@ impl I2sFreq for rcc::APB1 {
69
69
70
70
impl I2sFreq for rcc:: APB2 {
71
71
fn try_i2s_freq ( clocks : & Clocks ) -> Option < Hertz > {
72
- #[ cfg( not( any ( feature = "gpio-f412" , feature = "gpio-f413" , feature = "gpio-f446" ) ) ) ]
72
+ #[ cfg( not( feature = "rcc_i2s_apb" ) ) ]
73
73
{
74
74
clocks. i2s_clk ( )
75
75
}
76
- #[ cfg( any ( feature = "gpio-f412" , feature = "gpio-f413" , feature = "gpio-f446" ) ) ]
76
+ #[ cfg( feature = "rcc_i2s_apb" ) ]
77
77
{
78
78
clocks. i2s_apb2_clk ( )
79
79
}
Original file line number Diff line number Diff line change @@ -227,3 +227,20 @@ pub trait Steal {
227
227
/// no stolen instances are passed to such software.
228
228
unsafe fn steal ( ) -> Self ;
229
229
}
230
+
231
+ #[ allow( unused) ]
232
+ const fn max_u32 ( first : u32 , second : u32 ) -> u32 {
233
+ if second > first {
234
+ second
235
+ } else {
236
+ first
237
+ }
238
+ }
239
+
240
+ const fn min_u32 ( first : u32 , second : u32 ) -> u32 {
241
+ if second < first {
242
+ second
243
+ } else {
244
+ first
245
+ }
246
+ }
You can’t perform that action at this time.
0 commit comments