Skip to content

Commit ed8bf7f

Browse files
jonas-schievinkYatekii
authored andcommitted
.
1 parent 963915c commit ed8bf7f

File tree

21 files changed

+405
-409
lines changed

21 files changed

+405
-409
lines changed

nrf-hal-common/src/adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! API for the Analog to Digital converter
1+
//! API for the Analog to Digital converter.
22
33
use embedded_hal::adc::{Channel, OneShot};
44

@@ -63,7 +63,7 @@ pub struct AdcConfig {
6363
pub reference: Reference,
6464
}
6565

66-
// 0 volts reads as 0, VDD volts reads as 2^10
66+
// 0 volts reads as 0, VDD volts reads as 2^10.
6767
impl Default for AdcConfig {
6868
fn default() -> Self {
6969
Self {

nrf-hal-common/src/clocks.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! Configuration and control of the High and Low Frequency Clock
2-
//! sources
1+
//! Configuration and control of the High and Low Frequency Clock sources.
32
43
#[cfg(feature = "9160")]
54
use crate::pac::CLOCK_NS as CLOCK;
@@ -9,27 +8,27 @@ use crate::pac::CLOCK;
98

109
// ZST Type States
1110

12-
/// Internal/RC Oscillator
11+
/// Internal/RC Oscillator.
1312
pub struct Internal;
1413

15-
/// External Crystal Oscillator
14+
/// External Crystal Oscillator.
1615
pub struct ExternalOscillator;
1716

18-
/// Low Frequency Clock synthesize from High Frequency Clock
17+
/// Low Frequency Clock synthesize from High Frequency Clock.
1918
pub struct LfOscSynthesized;
2019

21-
/// Low Frequency Clock Started
20+
/// Low Frequency Clock Started.
2221
pub struct LfOscStarted;
2322

24-
/// Low Frequency Clock Stopped
23+
/// Low Frequency Clock Stopped.
2524
pub struct LfOscStopped;
2625

27-
/// High Frequency Clock Frequency (in Hz)
26+
/// High Frequency Clock Frequency (in Hz).
2827
pub const HFCLK_FREQ: u32 = 64_000_000;
29-
/// Low Frequency Clock Frequency (in Hz)
28+
/// Low Frequency Clock Frequency (in Hz).
3029
pub const LFCLK_FREQ: u32 = 32_768;
3130

32-
/// A high level abstraction for the CLOCK peripheral
31+
/// A high level abstraction for the CLOCK peripheral.
3332
pub struct Clocks<H, L, LSTAT> {
3433
hfclk: H,
3534
lfclk: L,
@@ -49,7 +48,7 @@ impl Clocks<Internal, Internal, LfOscStopped> {
4948
}
5049

5150
impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
52-
/// Use an external oscillator as the high frequency clock source
51+
/// Use an external oscillator as the high frequency clock source.
5352
pub fn enable_ext_hfosc(self) -> Clocks<ExternalOscillator, L, LSTAT> {
5453
self.periph.tasks_hfclkstart.write(|w| unsafe { w.bits(1) });
5554

@@ -67,7 +66,7 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
6766
}
6867
}
6968

70-
/// Use the internal oscillator as the high frequency clock source
69+
/// Use the internal oscillator as the high frequency clock source.
7170
pub fn disable_ext_hfosc(self) -> Clocks<Internal, L, LSTAT> {
7271
self.periph.tasks_hfclkstop.write(|w| unsafe { w.bits(1) });
7372
Clocks {
@@ -78,12 +77,12 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
7877
}
7978
}
8079

81-
/// Start the Low Frequency clock
80+
/// Start the Low Frequency clock.
8281
pub fn start_lfclk(self) -> Clocks<H, L, LfOscStarted> {
8382
self.periph.tasks_lfclkstart.write(|w| unsafe { w.bits(1) });
8483

8584
// Datasheet says this could take 100us from synth source
86-
// 600us from rc source, 0.25s from an external source
85+
// 600us from rc source, 0.25s from an external source.
8786
while self.periph.events_lfclkstarted.read().bits() != 1 {}
8887
self.periph
8988
.events_lfclkstarted
@@ -99,15 +98,15 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
9998
}
10099

101100
/// Allowable configuration options for the low frequency oscillator when
102-
/// driven fron an external crystal
101+
/// driven fron an external crystal.
103102
pub enum LfOscConfiguration {
104103
NoExternalNoBypass,
105104
ExternalNoBypass,
106105
ExternalAndBypass,
107106
}
108107

109108
impl<H, L> Clocks<H, L, LfOscStarted> {
110-
/// Stop the Low Frequency clock
109+
/// Stop the Low Frequency clock.
111110
pub fn stop_lfclk(self) -> Clocks<H, L, LfOscStopped> {
112111
self.periph.tasks_lfclkstop.write(|w| unsafe { w.bits(1) });
113112
Clocks {
@@ -120,7 +119,7 @@ impl<H, L> Clocks<H, L, LfOscStarted> {
120119
}
121120

122121
impl<H, L> Clocks<H, L, LfOscStopped> {
123-
/// Use the internal RC Oscillator for the low frequency clock source
122+
/// Use the internal RC Oscillator for the low frequency clock source.
124123
#[cfg(feature = "51")]
125124
pub fn set_lfclk_src_rc(self) -> Clocks<H, Internal, LfOscStopped> {
126125
self.periph.lfclksrc.write(|w| w.src().rc());
@@ -132,7 +131,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
132131
}
133132
}
134133

135-
/// Generate the Low Frequency clock from the high frequency clock source
134+
/// Generate the Low Frequency clock from the high frequency clock source.
136135
#[cfg(feature = "51")]
137136
pub fn set_lfclk_src_synth(self) -> Clocks<H, LfOscSynthesized, LfOscStopped> {
138137
self.periph.lfclksrc.write(|w| w.src().synth());
@@ -144,7 +143,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
144143
}
145144
}
146145

147-
/// Use an external crystal to drive the low frequency clock
146+
/// Use an external crystal to drive the low frequency clock.
148147
#[cfg(feature = "51")]
149148
pub fn set_lfclk_src_external(self) -> Clocks<H, ExternalOscillator, LfOscStopped> {
150149
self.periph.lfclksrc.write(move |w| w.src().xtal());
@@ -156,7 +155,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
156155
}
157156
}
158157

159-
/// Use the internal RC Oscillator for the low frequency clock source
158+
/// Use the internal RC Oscillator for the low frequency clock source.
160159
#[cfg(not(any(feature = "9160", feature = "51")))]
161160
pub fn set_lfclk_src_rc(self) -> Clocks<H, Internal, LfOscStopped> {
162161
self.periph
@@ -170,7 +169,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
170169
}
171170
}
172171

173-
/// Generate the Low Frequency clock from the high frequency clock source
172+
/// Generate the Low Frequency clock from the high frequency clock source.
174173
#[cfg(not(any(feature = "9160", feature = "51")))]
175174
pub fn set_lfclk_src_synth(self) -> Clocks<H, LfOscSynthesized, LfOscStopped> {
176175
self.periph
@@ -184,7 +183,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
184183
}
185184
}
186185

187-
/// Use an external crystal to drive the low frequency clock
186+
/// Use an external crystal to drive the low frequency clock.
188187
#[cfg(not(any(feature = "9160", feature = "51")))]
189188
pub fn set_lfclk_src_external(
190189
self,

nrf-hal-common/src/delay.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
//! Delays
1+
//! Delays.
22
use cast::u32;
33
use cortex_m::peripheral::syst::SystClkSource;
44
use cortex_m::peripheral::SYST;
55

66
use crate::clocks::HFCLK_FREQ;
77
use crate::hal::blocking::delay::{DelayMs, DelayUs};
88

9-
/// System timer (SysTick) as a delay provider
9+
/// System timer (SysTick) as a delay provider.
1010
pub struct Delay {
1111
syst: SYST,
1212
}
1313

1414
impl Delay {
15-
/// Configures the system timer (SysTick) as a delay provider
15+
/// Configures the system timer (SysTick) as a delay provider.
1616
pub fn new(mut syst: SYST) -> Self {
1717
syst.set_clock_source(SystClkSource::Core);
1818

1919
Delay { syst }
2020
}
2121

22-
/// Releases the system timer (SysTick) resource
22+
/// Releases the system timer (SysTick) resource.
2323
pub fn free(self) -> SYST {
2424
self.syst
2525
}

nrf-hal-common/src/ecb.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Ecb {
2424
regs.intenclr
2525
.write(|w| w.endecb().clear().errorecb().clear());
2626

27-
// NOTE(unsafe) 1 is a valid pattern to write to this register
27+
// NOTE(unsafe) 1 is a valid pattern to write to this register.
2828
regs.tasks_stopecb.write(|w| unsafe { w.bits(1) });
2929
Self { regs }
3030
}
@@ -68,12 +68,12 @@ impl Ecb {
6868
cipher_text: [0; 16],
6969
};
7070

71-
// NOTE(unsafe) Any 32bits pattern is safe to write to this register
71+
// NOTE(unsafe) Any 32bits pattern is safe to write to this register.
7272
self.regs
7373
.ecbdataptr
7474
.write(|w| unsafe { w.bits(&mut buf as *mut _ as u32) });
7575

76-
// Clear all events
76+
// Clear all events.
7777
self.regs.events_endecb.reset();
7878
self.regs.events_errorecb.reset();
7979

@@ -90,7 +90,7 @@ impl Ecb {
9090
compiler_fence(Ordering::Acquire);
9191

9292
if self.regs.events_errorecb.read().bits() == 1 {
93-
// It's ok to return here, the events will be cleared before the next encryption
93+
// It's ok to return here, the events will be cleared before the next encryption.
9494
return Err(EncryptionError {});
9595
}
9696
Ok(buf.cipher_text)

nrf-hal-common/src/gpio.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
use core::marker::PhantomData;
22

3-
/// Input mode (type state)
3+
/// Input mode (type state).
44
pub struct Input<MODE> {
55
_mode: PhantomData<MODE>,
66
}
77

8-
/// Floating input (type state)
8+
/// Floating input (type state).
99
pub struct Floating;
10-
/// Pulled down input (type state)
10+
/// Pulled down input (type state).
1111
pub struct PullDown;
12-
/// Pulled up input (type state)
12+
/// Pulled up input (type state).
1313
pub struct PullUp;
1414

15-
/// Output mode (type state)
15+
/// Output mode (type state).
1616
pub struct Output<MODE> {
1717
_mode: PhantomData<MODE>,
1818
}
1919

20-
/// Push pull output (type state)
20+
/// Push pull output (type state).
2121
pub struct PushPull;
22-
/// Open drain output (type state)
22+
/// Open drain output (type state).
2323
pub struct OpenDrain;
2424

25-
/// Represents a digital input or output level
25+
/// Represents a digital input or output level.
2626
pub enum Level {
2727
Low,
2828
High,
@@ -175,7 +175,7 @@ impl<MODE> Pin<MODE> {
175175
}
176176
}
177177

178-
/// Convert the pin to be a push-pull output with normal drive
178+
/// Convert the pin to be a push-pull output with normal drive.
179179
pub fn into_push_pull_output(self, initial_output: Level) -> Pin<Output<PushPull>> {
180180
let mut pin = Pin {
181181
_mode: PhantomData,
@@ -199,10 +199,10 @@ impl<MODE> Pin<MODE> {
199199
pin
200200
}
201201

202-
/// Convert the pin to be an open-drain output
202+
/// Convert the pin to be an open-drain output.
203203
///
204-
/// This method currently does not support configuring an
205-
/// internal pull-up or pull-down resistor.
204+
/// This method currently does not support configuring an internal pull-up or pull-down
205+
/// resistor.
206206
pub fn into_open_drain_output(
207207
self,
208208
config: OpenDrainConfig,
@@ -218,8 +218,7 @@ impl<MODE> Pin<MODE> {
218218
Level::High => pin.set_high().unwrap(),
219219
}
220220

221-
// This is safe, as we restrict our access to the dedicated
222-
// register for this pin.
221+
// This is safe, as we restrict our access to the dedicated register for this pin.
223222
let pin_cnf = &self.block().pin_cnf[self.pin() as usize];
224223
pin_cnf.write(|w| {
225224
w.dir().output();
@@ -249,7 +248,7 @@ impl<MODE> InputPin for Pin<Input<MODE>> {
249248
impl<MODE> OutputPin for Pin<Output<MODE>> {
250249
type Error = Void;
251250

252-
/// Set the output as high
251+
/// Set the output as high.
253252
fn set_high(&mut self) -> Result<(), Self::Error> {
254253
// NOTE(unsafe) atomic write to a stateless register - TODO(AJM) verify?
255254
// TODO - I wish I could do something like `.pins$i()`...
@@ -259,7 +258,7 @@ impl<MODE> OutputPin for Pin<Output<MODE>> {
259258
Ok(())
260259
}
261260

262-
/// Set the output as low
261+
/// Set the output as low.
263262
fn set_low(&mut self) -> Result<(), Self::Error> {
264263
// NOTE(unsafe) atomic write to a stateless register - TODO(AJM) verify?
265264
// TODO - I wish I could do something like `.pins$i()`...
@@ -284,7 +283,7 @@ impl<MODE> StatefulOutputPin for Pin<Output<MODE>> {
284283
}
285284
}
286285

287-
/// Pin configuration for open-drain mode
286+
/// Pin configuration for open-drain mode.
288287
pub enum OpenDrainConfig {
289288
Disconnect0Standard1,
290289
Disconnect0HighDrive1,

0 commit comments

Comments
 (0)