File tree 6 files changed +64
-2
lines changed
6 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
8
8
## [ Unreleased]
9
9
10
+ ### Changed
11
+
12
+ - [ breaking-change] Updated synopsys-usb-otg dependency to v0.2.0.
13
+
10
14
### Added
11
15
12
16
- Reexport PAC as ` pac ` for consistency with other crates, consider ` stm32 ` virtually deprecated
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ cortex-m-rt = "0.6.10"
31
31
nb = " 0.1.2"
32
32
rand_core = " 0.5.1"
33
33
stm32f4 = " 0.11"
34
- synopsys-usb-otg = { version = " 0.1 .0" , features = [" cortex-m" ], optional = true }
34
+ synopsys-usb-otg = { version = " 0.2 .0" , features = [" cortex-m" ], optional = true }
35
35
36
36
[dependencies .bare-metal ]
37
37
version = " 0.2.5"
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ fn main() -> ! {
18
18
19
19
let rcc = dp. RCC . constrain ( ) ;
20
20
21
- rcc. cfgr
21
+ let clocks = rcc
22
+ . cfgr
22
23
. use_hse ( 25 . mhz ( ) )
23
24
. sysclk ( 48 . mhz ( ) )
24
25
. require_pll48clk ( )
@@ -32,6 +33,7 @@ fn main() -> ! {
32
33
usb_pwrclk : dp. OTG_FS_PWRCLK ,
33
34
pin_dm : gpioa. pa11 . into_alternate_af10 ( ) ,
34
35
pin_dp : gpioa. pa12 . into_alternate_af10 ( ) ,
36
+ hclk : clocks. hclk ( ) ,
35
37
} ;
36
38
37
39
let usb_bus = UsbBus :: new ( usb, unsafe { & mut EP_MEMORY } ) ;
Original file line number Diff line number Diff line change @@ -100,13 +100,18 @@ pub mod i2c;
100
100
feature = "stm32f405" ,
101
101
feature = "stm32f407" ,
102
102
feature = "stm32f411" ,
103
+ feature = "stm32f412" ,
104
+ feature = "stm32f413" ,
103
105
feature = "stm32f415" ,
104
106
feature = "stm32f417" ,
107
+ feature = "stm32f423" ,
105
108
feature = "stm32f427" ,
106
109
feature = "stm32f429" ,
107
110
feature = "stm32f437" ,
108
111
feature = "stm32f439" ,
109
112
feature = "stm32f446" ,
113
+ feature = "stm32f469" ,
114
+ feature = "stm32f479" ,
110
115
)
111
116
) ) ]
112
117
pub mod otg_fs;
@@ -122,6 +127,8 @@ pub mod otg_fs;
122
127
feature = "stm32f437" ,
123
128
feature = "stm32f439" ,
124
129
feature = "stm32f446" ,
130
+ feature = "stm32f469" ,
131
+ feature = "stm32f479" ,
125
132
)
126
133
) ) ]
127
134
pub mod otg_hs;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ use crate::gpio::{
9
9
gpioa:: { PA11 , PA12 } ,
10
10
Alternate , AF10 ,
11
11
} ;
12
+ use crate :: time:: Hertz ;
12
13
13
14
pub use synopsys_usb_otg:: UsbBus ;
14
15
use synopsys_usb_otg:: UsbPeripheral ;
@@ -19,6 +20,7 @@ pub struct USB {
19
20
pub usb_pwrclk : stm32:: OTG_FS_PWRCLK ,
20
21
pub pin_dm : PA11 < Alternate < AF10 > > ,
21
22
pub pin_dp : PA12 < Alternate < AF10 > > ,
23
+ pub hclk : Hertz ,
22
24
}
23
25
24
26
unsafe impl Sync for USB { }
@@ -29,6 +31,29 @@ unsafe impl UsbPeripheral for USB {
29
31
const HIGH_SPEED : bool = false ;
30
32
const FIFO_DEPTH_WORDS : usize = 320 ;
31
33
34
+ #[ cfg( any(
35
+ feature = "stm32f401" ,
36
+ feature = "stm32f405" ,
37
+ feature = "stm32f407" ,
38
+ feature = "stm32f411" ,
39
+ feature = "stm32f415" ,
40
+ feature = "stm32f417" ,
41
+ feature = "stm32f427" ,
42
+ feature = "stm32f429" ,
43
+ feature = "stm32f437" ,
44
+ feature = "stm32f439" ,
45
+ ) ) ]
46
+ const ENDPOINT_COUNT : usize = 4 ;
47
+ #[ cfg( any(
48
+ feature = "stm32f412" ,
49
+ feature = "stm32f413" ,
50
+ feature = "stm32f423" ,
51
+ feature = "stm32f446" ,
52
+ feature = "stm32f469" ,
53
+ feature = "stm32f479" ,
54
+ ) ) ]
55
+ const ENDPOINT_COUNT : usize = 6 ;
56
+
32
57
fn enable ( ) {
33
58
let rcc = unsafe { & * stm32:: RCC :: ptr ( ) } ;
34
59
@@ -41,6 +66,10 @@ unsafe impl UsbPeripheral for USB {
41
66
rcc. ahb2rstr . modify ( |_, w| w. otgfsrst ( ) . clear_bit ( ) ) ;
42
67
} ) ;
43
68
}
69
+
70
+ fn ahb_frequency_hz ( & self ) -> u32 {
71
+ self . hclk . 0
72
+ }
44
73
}
45
74
46
75
pub type UsbBusType = UsbBus < USB > ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use crate::gpio::{
12
12
gpiob:: { PB14 , PB15 } ,
13
13
Alternate , AF12 ,
14
14
} ;
15
+ use crate :: time:: Hertz ;
15
16
16
17
pub use synopsys_usb_otg:: UsbBus ;
17
18
use synopsys_usb_otg:: UsbPeripheral ;
@@ -22,6 +23,7 @@ pub struct USB {
22
23
pub usb_pwrclk : stm32:: OTG_HS_PWRCLK ,
23
24
pub pin_dm : PB14 < Alternate < AF12 > > ,
24
25
pub pin_dp : PB15 < Alternate < AF12 > > ,
26
+ pub hclk : Hertz ,
25
27
}
26
28
27
29
unsafe impl Sync for USB { }
@@ -32,6 +34,20 @@ unsafe impl UsbPeripheral for USB {
32
34
const HIGH_SPEED : bool = true ;
33
35
const FIFO_DEPTH_WORDS : usize = 1024 ;
34
36
37
+ #[ cfg( any(
38
+ feature = "stm32f405" ,
39
+ feature = "stm32f407" ,
40
+ feature = "stm32f415" ,
41
+ feature = "stm32f417" ,
42
+ feature = "stm32f427" ,
43
+ feature = "stm32f429" ,
44
+ feature = "stm32f437" ,
45
+ feature = "stm32f439" ,
46
+ ) ) ]
47
+ const ENDPOINT_COUNT : usize = 6 ;
48
+ #[ cfg( any( feature = "stm32f446" , feature = "stm32f469" , feature = "stm32f479" ) ) ]
49
+ const ENDPOINT_COUNT : usize = 9 ;
50
+
35
51
fn enable ( ) {
36
52
let rcc = unsafe { & * stm32:: RCC :: ptr ( ) } ;
37
53
@@ -44,6 +60,10 @@ unsafe impl UsbPeripheral for USB {
44
60
rcc. ahb1rstr . modify ( |_, w| w. otghsrst ( ) . clear_bit ( ) ) ;
45
61
} ) ;
46
62
}
63
+
64
+ fn ahb_frequency_hz ( & self ) -> u32 {
65
+ self . hclk . 0
66
+ }
47
67
}
48
68
49
69
pub type UsbBusType = UsbBus < USB > ;
You can’t perform that action at this time.
0 commit comments