File tree Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Expand file tree Collapse file tree 2 files changed +36
-5
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,25 @@ fn main() -> ! {
40
40
41
41
let clocks = rcc
42
42
. cfgr
43
- // needed for RNG
43
+ // Needed for RNG.
44
44
. clk48_source ( {
45
- if cfg ! ( any(
45
+ # [ cfg( any(
46
46
feature = "stm32l476" ,
47
47
feature = "stm32l486" ,
48
48
feature = "stm32l496" ,
49
49
feature = "stm32l4a6"
50
- ) ) {
50
+ ) ) ]
51
+ {
51
52
Clk48Source :: Hsi48
52
- } else {
53
+ }
54
+
55
+ #[ cfg( not( any(
56
+ feature = "stm32l476" ,
57
+ feature = "stm32l486" ,
58
+ feature = "stm32l496" ,
59
+ feature = "stm32l4a6"
60
+ ) ) ) ]
61
+ {
53
62
Clk48Source :: Msi
54
63
}
55
64
} )
Original file line number Diff line number Diff line change 6
6
extern crate panic_semihosting;
7
7
8
8
use cortex_m_rt:: entry;
9
+ use stm32l4xx_hal:: rcc:: Clk48Source ;
9
10
use stm32l4xx_hal:: usb:: { Peripheral , UsbBus } ;
10
11
use stm32l4xx_hal:: { prelude:: * , stm32} ;
11
12
use usb_device:: prelude:: * ;
@@ -43,7 +44,28 @@ fn main() -> ! {
43
44
44
45
let _clocks = rcc
45
46
. cfgr
46
- . hsi48 ( true )
47
+ // Needed for USB.
48
+ . clk48_source ( {
49
+ #[ cfg( any(
50
+ feature = "stm32l476" ,
51
+ feature = "stm32l486" ,
52
+ feature = "stm32l496" ,
53
+ feature = "stm32l4a6"
54
+ ) ) ]
55
+ {
56
+ Clk48Source :: Hsi48
57
+ }
58
+
59
+ #[ cfg( not( any(
60
+ feature = "stm32l476" ,
61
+ feature = "stm32l486" ,
62
+ feature = "stm32l496" ,
63
+ feature = "stm32l4a6"
64
+ ) ) ) ]
65
+ {
66
+ Clk48Source :: Msi
67
+ }
68
+ } )
47
69
. sysclk ( 80 . MHz ( ) )
48
70
. freeze ( & mut flash. acr , & mut pwr) ;
49
71
You can’t perform that action at this time.
0 commit comments