File tree 4 files changed +19
-12
lines changed
4 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
20
20
21
21
- Add CAN bus abstraction based on the [ bxcan] crate.
22
22
- Add PWM output generation based on the timers.
23
+ - Added ` impl From<KiloHertz> for Hertz `
24
+ - Added ` impl From<MegaHertz> for Hertz `
25
+ - Added ` impl From<KiloHertz> for MegaHertz `
26
+ - Added ` impl From<Hertz> for IwdgTimeout `
23
27
24
28
[ bxcan ] : https://crates.io/crates/bxcan
25
29
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ pub enum HSEBypassMode {
58
58
feature = "stm32f072" ,
59
59
feature = "stm32f078" ,
60
60
) ) ]
61
+ #[ allow( clippy:: upper_case_acronyms) ]
61
62
pub enum USBClockSource {
62
63
#[ cfg( feature = "stm32f070" ) ]
63
64
/// USB peripheral's tranceiver is disabled
@@ -89,6 +90,7 @@ mod inner {
89
90
) ) ]
90
91
pub ( super ) const RCC_PLLSRC_PREDIV1_SUPPORT : bool = false ;
91
92
93
+ #[ allow( clippy:: upper_case_acronyms) ]
92
94
pub ( super ) enum SysClkSource {
93
95
HSI ,
94
96
/// High-speed external clock(freq,bypassed)
@@ -205,6 +207,7 @@ mod inner {
205
207
) ) ]
206
208
pub ( super ) const RCC_PLLSRC_PREDIV1_SUPPORT : bool = false ;
207
209
210
+ #[ allow( clippy:: upper_case_acronyms) ]
208
211
pub ( super ) enum SysClkSource {
209
212
HSI ,
210
213
/// High-speed external clock(freq,bypassed)
Original file line number Diff line number Diff line change @@ -44,20 +44,20 @@ impl U32Ext for u32 {
44
44
}
45
45
}
46
46
47
- impl Into < Hertz > for KiloHertz {
48
- fn into ( self ) -> Hertz {
49
- Hertz ( self . 0 * 1_000 )
47
+ impl From < KiloHertz > for Hertz {
48
+ fn from ( khz : KiloHertz ) -> Self {
49
+ Hertz ( khz . 0 * 1_000 )
50
50
}
51
51
}
52
52
53
- impl Into < Hertz > for MegaHertz {
54
- fn into ( self ) -> Hertz {
55
- Hertz ( self . 0 * 1_000_000 )
53
+ impl From < MegaHertz > for Hertz {
54
+ fn from ( mhz : MegaHertz ) -> Self {
55
+ Hertz ( mhz . 0 * 1_000_000 )
56
56
}
57
57
}
58
58
59
- impl Into < KiloHertz > for MegaHertz {
60
- fn into ( self ) -> KiloHertz {
61
- KiloHertz ( self . 0 * 1_000 )
59
+ impl From < MegaHertz > for KiloHertz {
60
+ fn from ( mhz : MegaHertz ) -> Self {
61
+ KiloHertz ( mhz . 0 * 1_000 )
62
62
}
63
63
}
Original file line number Diff line number Diff line change @@ -66,13 +66,13 @@ pub struct IwdgTimeout {
66
66
reload : u16 ,
67
67
}
68
68
69
- impl Into < IwdgTimeout > for Hertz {
69
+ impl From < Hertz > for IwdgTimeout {
70
70
/// This converts the value so it's usable by the IWDG
71
71
/// Due to conversion losses, the specified frequency is a maximum
72
72
///
73
73
/// It can also only represent values < 10000 Hertz
74
- fn into ( self ) -> IwdgTimeout {
75
- let mut time = 40_000 / 4 / self . 0 ;
74
+ fn from ( hz : Hertz ) -> Self {
75
+ let mut time = 40_000 / 4 / hz . 0 ;
76
76
let mut psc = 0 ;
77
77
let mut reload = 0 ;
78
78
while psc < 7 {
You can’t perform that action at this time.
0 commit comments