Skip to content

Commit 75e1d0d

Browse files
authored
Merge pull request #249 from TheZoq2/doc_improvements
More documentation links
2 parents 25e734f + e77e6f0 commit 75e1d0d

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

src/gpio.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
//!
33
//! The GPIO pins are organised into groups of 16 pins which can be accessed through the
44
//! `gpioa`, `gpiob`... modules. To get access to the pins, you first need to convert them into a
5-
//! HAL designed struct from the `pac` struct using the `spilit` function.
5+
//! HAL designed struct from the `pac` struct using the [split](trait.GpioExt.html#tymethod.split) function.
66
//! ```rust
77
//! // Acquire the GPIOC peripheral
88
//! // NOTE: `dp` is the device peripherals from the `PAC` crate
99
//! let mut gpioa = dp.GPIOA.split(&mut rcc.apb2);
1010
//! ```
1111
//!
12+
//! See the documentation for [rcc::APB2](../rcc/struct.APB2.html) for details about the input parameter to
13+
//! `split`.
14+
//!
1215
//! This gives you a struct containing two control registers `crl` and `crh`, and all the pins
1316
//! `px0..px15`. These structs are what you use to interract with the pins to change their modes,
1417
//! or their inputs or outputs. For example, to set `pa5` high, you would call

src/rcc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ impl RccExt for RCC {
3636
}
3737

3838
/// Constrained RCC peripheral
39+
///
40+
/// Aquired by calling the [constrain](../trait.RccExt.html#tymethod.constrain) method
41+
/// on the Rcc struct from the `PAC`
42+
///
43+
/// ```rust
44+
/// let dp = pac::Peripherals::take().unwrap();
45+
/// let mut rcc = dp.RCC.constrain();
46+
/// ```
3947
pub struct Rcc {
4048
/// AMBA High-performance Bus (AHB) registers
4149
pub ahb: AHB,

src/rtc.rs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
/*!
22
Real time clock
3-
4-
A continuously running clock that counts seconds. It is part of the backup domain which means
5-
that the counter is not affected by system resets or standby mode. If Vbat is connected, it is
6-
not reset even if the rest of the device is powered off. This allows it to be used to wake the
7-
CPU when it is in low power mode.
8-
9-
Since it is part of the backup domain, write access to it must be enabled before the RTC can be
10-
used. See `backup_domain` for more details.
11-
12-
See examples/rtc.rs and examples/blinky_rtc.rs for usage examples.
133
*/
14-
154
use crate::pac::{RCC, RTC};
165

176
use crate::backup_domain::BackupDomain;
@@ -23,8 +12,22 @@ use core::convert::Infallible;
2312
const LSE_HERTZ: u32 = 32_768;
2413

2514
/**
26-
Interface to the real time clock
15+
Real time clock
16+
17+
A continuously running clock that counts seconds¹. It is part of the backup domain which means
18+
that the counter is not affected by system resets or standby mode. If Vbat is connected, it is
19+
not reset even if the rest of the device is powered off. This allows it to be used to wake the
20+
CPU when it is in low power mode.
21+
22+
23+
See [examples/rtc.rs] and [examples/blinky_rtc.rs] for usage examples.
24+
25+
1: Unless configured to another frequency using [select_frequency](struct.Rtc.html#method.select_frequency)
26+
27+
[examples/rtc.rs]: https://github.com/stm32-rs/stm32f1xx-hal/blob/v0.6.1/examples/rtc.rs
28+
[examples/blinky_rtc.rs]: https://github.com/stm32-rs/stm32f1xx-hal/blob/v0.6.1/examples/blinky_rtc.rs
2729
*/
30+
2831
pub struct Rtc {
2932
regs: RTC,
3033
}
@@ -33,6 +36,12 @@ impl Rtc {
3336
/**
3437
Initialises the RTC. The `BackupDomain` struct is created by
3538
`Rcc.bkp.constrain()`.
39+
40+
The frequency is set to 1 Hz.
41+
42+
Since the RTC is part of the backup domain, The RTC counter is not reset by normal resets or
43+
power cycles where (VBAT) still has power. Use [set_time](#method.set_time) if you want to
44+
reset the counter.
3645
*/
3746
pub fn rtc(regs: RTC, bkp: &mut BackupDomain) -> Self {
3847
let mut result = Rtc { regs };
@@ -123,15 +132,17 @@ impl Rtc {
123132
self.clear_alarm_flag();
124133
}
125134

126-
/// Enables the RTCALARM interrupt
135+
/// Enables the RTC interrupt to trigger when the counter reaches the alarm value. In addition,
136+
/// if the EXTI controller has been set up correctly, this function also enables the RTCALARM
137+
/// interrupt.
127138
pub fn listen_alarm(&mut self) {
128139
// Enable alarm interrupt
129140
self.perform_write(|s| {
130141
s.regs.crh.modify(|_, w| w.alrie().set_bit());
131142
})
132143
}
133144

134-
/// Disables the RTCALARM interrupt
145+
/// Stops the RTC alarm from triggering the RTC and RTCALARM interrupts
135146
pub fn unlisten_alarm(&mut self) {
136147
// Disable alarm interrupt
137148
self.perform_write(|s| {
@@ -147,7 +158,7 @@ impl Rtc {
147158
self.regs.cnth.read().bits() << 16 | self.regs.cntl.read().bits()
148159
}
149160

150-
/// Enables the RTC second interrupt
161+
/// Enables triggering the RTC interrupt every time the RTC counter is increased
151162
pub fn listen_seconds(&mut self) {
152163
self.perform_write(|s| s.regs.crh.modify(|_, w| w.secie().set_bit()))
153164
}

0 commit comments

Comments
 (0)