Skip to content

Commit 788aedb

Browse files
Rtc v2 (#136)
Add support for the onboard real-time clock (RTC)
1 parent d290818 commit 788aedb

File tree

5 files changed

+447
-0
lines changed

5 files changed

+447
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Support for 16-bit words with SPI ([#107](https://github.com/stm32-rs/stm32f3xx-hal/pull/107))
1313
- SPI support for reclock after initialization ([#98](https://github.com/stm32-rs/stm32f3xx-hal/pull/98))
1414
- Support for `stm32f302x6` and `stm32f302x8` devices ([#132](https://github.com/stm32-rs/stm32f3xx-hal/pull/132))
15+
- Support for the onboard real-time clock (RTC) ([#136](https://github.com/stm32-rs/stm32f3xx-hal/pull/136))
1516

1617
## [v0.5.0] - 2020-07-21
1718

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ embedded-dma = "0.1"
2222
embedded-hal = "0.2"
2323
nb = "0.1"
2424
stm32f3 = "0.11"
25+
rtcc = "0.2"
2526

2627
[dependencies.bare-metal]
2728
version = "0.2"

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ pub mod pwm;
131131
#[cfg(feature = "device-selected")]
132132
pub mod rcc;
133133
#[cfg(feature = "device-selected")]
134+
pub mod rtc;
135+
#[cfg(feature = "device-selected")]
134136
pub mod serial;
135137
#[cfg(feature = "device-selected")]
136138
pub mod spi;

src/rcc.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ impl RccExt for RCC {
2020
ahb: AHB { _0: () },
2121
apb1: APB1 { _0: () },
2222
apb2: APB2 { _0: () },
23+
bdcr: BDCR { _0: () },
2324
cfgr: CFGR {
2425
hse: None,
2526
hclk: None,
@@ -48,6 +49,8 @@ pub struct Rcc {
4849
pub apb1: APB1,
4950
/// Advanced Peripheral Bus 2 (APB2) registers
5051
pub apb2: APB2,
52+
/// RCC Backup Domain
53+
pub bdcr: BDCR,
5154
/// Clock configuration
5255
pub cfgr: CFGR,
5356
}
@@ -190,6 +193,18 @@ mod usb_clocking {
190193
}
191194
}
192195

196+
/// Backup Domain Control register (RCC_BDCR)
197+
pub struct BDCR {
198+
_0: (),
199+
}
200+
201+
impl BDCR {
202+
pub(crate) fn bdcr(&mut self) -> &rcc::BDCR {
203+
// NOTE(unsafe) this proxy grants exclusive access to this register
204+
unsafe { &(*RCC::ptr()).bdcr }
205+
}
206+
}
207+
193208
/// Clock configuration
194209
///
195210
/// An instance of this struct is aquired from the [Rcc](../struct.Rcc.html) struct.

0 commit comments

Comments
 (0)