Skip to content

Commit 9775288

Browse files
authored
util: add inline to functions
1 parent 0b80ef7 commit 9775288

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Moved `info::uid64_devnum` to `info::Uid64::read_devnum`.
2222
- Moved `info::package` to `info::Package::from_device`.
2323
- Moved `info::uid` to `info::Uid::from_device`.
24+
- Added `#[inline]` to `util::new_delay` and `util::reset_cycle_count`.
2425

2526
## [0.2.1] - 2021-11-20
2627
### Fixed

hal/src/util.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Miscellaneous utilities
22
use crate::pac;
3-
use core::ptr::write_volatile;
43
use cortex_m::{delay::Delay, peripheral::syst::SystClkSource};
54

65
/// Create a new [`cortex_m::delay::Delay`] from the current CPU systick
@@ -15,6 +14,7 @@ use cortex_m::{delay::Delay, peripheral::syst::SystClkSource};
1514
/// let cp = pac::CorePeripherals::take().unwrap();
1615
/// let delay = new_delay(cp.SYST, &dp.RCC);
1716
/// ```
17+
#[inline]
1818
pub fn new_delay(syst: pac::SYST, rcc: &pac::RCC) -> Delay {
1919
Delay::new(
2020
syst,
@@ -41,7 +41,8 @@ pub fn new_delay(syst: pac::SYST, rcc: &pac::RCC) -> Delay {
4141
///
4242
/// [#347]: https://github.com/rust-embedded/cortex-m/pull/347
4343
#[allow(unused_variables)]
44+
#[inline]
4445
pub fn reset_cycle_count(dwt: &mut pac::DWT) {
45-
const DWT_CYCCNT: usize = 0xE0001004;
46-
unsafe { write_volatile(DWT_CYCCNT as *mut u32, 0) };
46+
const DWT_CYCCNT: *mut u32 = 0xE0001004 as *mut u32;
47+
unsafe { DWT_CYCCNT.write_volatile(0) };
4748
}

0 commit comments

Comments
 (0)