Fix bit-band access
parent
aaacf82f39
commit
c16a43cdd3
|
@ -23,7 +23,7 @@ const PERIPHERAL_LIMIT: usize = 0x4010_0000;
|
|||
const ALIAS_OFFSET: usize = 0x0200_0000;
|
||||
|
||||
const REGION_MASK: usize = 0xF000_0000;
|
||||
const WORD_MASK: usize = 0x0FFF_0000;
|
||||
const WORD_MASK: usize = 0x0FFF_FFFF;
|
||||
|
||||
/// Atomically sets (via read/modify/write) a single bit at the given address
|
||||
/// without affecting other bits in that memory location.
|
||||
|
@ -31,7 +31,7 @@ const WORD_MASK: usize = 0x0FFF_0000;
|
|||
pub unsafe fn set_bit<T>(address: *const T, bit: u8) {
|
||||
let address = address as usize;
|
||||
let bit_address = bitband_alias_of(address, bit);
|
||||
write_volatile(bit_address as *mut _, 0x01);
|
||||
write_volatile(bit_address as *mut u16, 0x01);
|
||||
}
|
||||
|
||||
/// Atomically clears (via read/modify/write) a single bit at the given address
|
||||
|
@ -40,7 +40,7 @@ pub unsafe fn set_bit<T>(address: *const T, bit: u8) {
|
|||
pub unsafe fn clear_bit<T>(address: *const T, bit: u8) {
|
||||
let address = address as usize;
|
||||
let bit_address = bitband_alias_of(address, bit);
|
||||
write_volatile(bit_address as *mut _, 0x00);
|
||||
write_volatile(bit_address as *mut u16, 0x00);
|
||||
}
|
||||
|
||||
/// Reads a single bit at the given address without affecting other
|
||||
|
@ -49,7 +49,7 @@ pub unsafe fn clear_bit<T>(address: *const T, bit: u8) {
|
|||
pub unsafe fn read_bit<T>(address: *const T, bit: u8) -> T {
|
||||
let address = address as usize;
|
||||
let bit_address = bitband_alias_of(address, bit);
|
||||
read_volatile(bit_address as *const _)
|
||||
read_volatile(bit_address as *const T)
|
||||
}
|
||||
|
||||
/// Calculate the address in the bitband region of the given bit
|
||||
|
|
Loading…
Reference in New Issue