Skip to content

Commit eba4d94

Browse files
committed
Mark bit banding functions as unsafe
1 parent c001f85 commit eba4d94

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1111

1212
- MonoTimer now takes ownership of the DCB register
1313
- SPI objects now have a `FrameSize` type field
14+
- Bit banding functions (`bb::*`) are now correctly marked as unsafe
1415

1516
### Added
1617

1718
- Add 16 bit dataframe size for `SPI`
1819
- Implement `timer::Cancel` trait for `CountDownTimer`
1920
- Changing Output pin slew rates through the OutputSpeed trait
20-
21-
### Added
22-
2321
- Add support for ADC continuous conversion
2422
- Add supoort for ADC discontinuous mode
2523

src/bb.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
33
use core::ptr;
44

5-
pub fn clear<T>(register: *const T, bit: u8) {
5+
pub unsafe fn clear<T>(register: *const T, bit: u8) {
66
write(register, bit, false);
77
}
88

9-
pub fn set<T>(register: *const T, bit: u8) {
9+
pub unsafe fn set<T>(register: *const T, bit: u8) {
1010
write(register, bit, true);
1111
}
1212

13-
pub fn write<T>(register: *const T, bit: u8, set: bool) {
13+
pub unsafe fn write<T>(register: *const T, bit: u8, set: bool) {
1414
let addr = register as usize;
1515

1616
assert!(addr >= 0x4000_0000 && addr <= 0x4010_0000);
1717
assert!(bit < 32);
1818

1919
let bit = bit as usize;
2020
let bb_addr = (0x4200_0000 + (addr - 0x4000_0000) * 32) + 4 * bit;
21-
unsafe { ptr::write_volatile(bb_addr as *mut u32, if set { 1 } else { 0 }) }
21+
ptr::write_volatile(bb_addr as *mut u32, if set { 1 } else { 0 })
2222
}

0 commit comments

Comments
 (0)