-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rtc module #93
Add rtc module #93
Changes from all commits
c113526
5a7723a
b24c4f9
9175483
7cf3829
476a92c
44fe6fc
fb505ec
1422683
98c3f24
c629df9
1533749
144588e
4c6d8d6
91f831b
4777f6d
158632a
ad355d6
348e4a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,16 @@ impl RccExt for RCC { | |
ahb: AHB { _0: () }, | ||
apb1: APB1 { _0: () }, | ||
apb2: APB2 { _0: () }, | ||
bdcr: BDCR { _0: () }, | ||
cfgr: CFGR { | ||
hse: None, | ||
hclk: None, | ||
pclk1: None, | ||
pclk2: None, | ||
sysclk: None, | ||
}, | ||
cr: CR { _0: () }, | ||
csr: CSR { _0: () }, | ||
} | ||
} | ||
} | ||
|
@@ -39,8 +42,14 @@ pub struct Rcc { | |
pub apb1: APB1, | ||
/// Advanced Peripheral Bus 2 (APB2) registers | ||
pub apb2: APB2, | ||
/// RCC Backup Domain | ||
pub bdcr: BDCR, | ||
/// Clock configuration | ||
pub cfgr: CFGR, | ||
/// RCC Clock Control register | ||
pub cr: CR, | ||
/// RCC Control/Status register | ||
pub csr: CSR, | ||
} | ||
|
||
/// AMBA High-performance Bus (AHB) registers | ||
|
@@ -157,7 +166,20 @@ mod usb_clocking { | |
} | ||
} | ||
|
||
/// Backup Domain Control register (RCC_BDCR) | ||
pub struct BDCR { | ||
_0: (), | ||
} | ||
|
||
impl BDCR { | ||
pub(crate) fn bdcr(&mut self) -> &rcc::BDCR { | ||
// NOTE(unsafe) this proxy grants exclusive access to this register | ||
unsafe { &(*RCC::ptr()).bdcr } | ||
} | ||
} | ||
|
||
/// Clock configuration | ||
#[derive(Clone, Copy)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We must not allow cloning of the |
||
pub struct CFGR { | ||
hse: Option<u32>, | ||
hclk: Option<u32>, | ||
|
@@ -580,6 +602,30 @@ impl CFGR { | |
} | ||
} | ||
|
||
/// RCC Clock Control register (RCC_CR) | ||
pub struct CR { | ||
_0: (), | ||
} | ||
|
||
impl CR { | ||
pub(crate) fn cr(&mut self) -> &rcc::CR { | ||
// NOTE(unsafe) this proxy grants exclusive access to this register | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not true. If you look at |
||
unsafe { &(*RCC::ptr()).cr } | ||
} | ||
} | ||
|
||
/// RCC Control/Status register | ||
pub struct CSR { | ||
_0: (), | ||
} | ||
|
||
impl CSR { | ||
pub(crate) fn csr(&mut self) -> &rcc::CSR { | ||
// NOTE(unsafe) this proxy grants exclusive access to this register | ||
unsafe { &(*RCC::ptr()).csr } | ||
} | ||
} | ||
|
||
/// Frozen clock frequencies | ||
/// | ||
/// The existence of this value indicates that the clock configuration can no longer be changed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since specifying versions in Cargo.toml defaults to the caret operator (https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html), this is the same as
"^0.2.0"
, which actually allows any patch version (i.e.0.2.x
). Therefore, it is less confusing to just specifyrtcc = "0.2"
here. We use this pattern for the other dependencies too.