diff options
-rw-r--r-- | libmaple/bitband.h | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/libmaple/bitband.h b/libmaple/bitband.h index 870abe9..69b1dd2 100644 --- a/libmaple/bitband.h +++ b/libmaple/bitband.h @@ -38,7 +38,10 @@ #define BB_PERI_REF 0x40000000 #define BB_PERI_BASE 0x42000000 -static inline __io uint32* __bb_addr(__io void*, uint32, uint32, uint32); +static inline volatile uint32* __bb_addr(volatile void*, + uint32, + uint32, + uint32); /** * @brief Obtain a pointer to the bit-band address corresponding to a @@ -46,7 +49,7 @@ static inline __io uint32* __bb_addr(__io void*, uint32, uint32, uint32); * @param address Address in the bit-banded SRAM region * @param bit Bit in address to bit-band */ -static inline __io uint32* bb_sramp(__io void *address, uint32 bit) { +static inline volatile uint32* bb_sramp(volatile void *address, uint32 bit) { return __bb_addr(address, bit, BB_SRAM_BASE, BB_SRAM_REF); } @@ -56,7 +59,7 @@ static inline __io uint32* bb_sramp(__io void *address, uint32 bit) { * @param bit Bit in address to read * @return bit's value in address. */ -static inline uint8 bb_sram_get_bit(__io void *address, uint32 bit) { +static inline uint8 bb_sram_get_bit(volatile void *address, uint32 bit) { return *bb_sramp(address, bit); } @@ -66,7 +69,9 @@ static inline uint8 bb_sram_get_bit(__io void *address, uint32 bit) { * @param bit Bit in address to write to * @param val Value to write for bit, either 0 or 1. */ -static inline void bb_sram_set_bit(__io void *address, uint32 bit, uint8 val) { +static inline void bb_sram_set_bit(volatile void *address, + uint32 bit, + uint8 val) { *bb_sramp(address, bit) = val; } @@ -76,7 +81,7 @@ static inline void bb_sram_set_bit(__io void *address, uint32 bit, uint8 val) { * @param address Address in the bit-banded peripheral region * @param bit Bit in address to bit-band */ -static inline __io uint32* bb_perip(__io void *address, uint32 bit) { +static inline volatile uint32* bb_perip(volatile void *address, uint32 bit) { return __bb_addr(address, bit, BB_PERI_BASE, BB_PERI_REF); } @@ -86,7 +91,7 @@ static inline __io uint32* bb_perip(__io void *address, uint32 bit) { * @param bit Bit in address to read * @return bit's value in address. */ -static inline uint8 bb_peri_get_bit(__io void *address, uint32 bit) { +static inline uint8 bb_peri_get_bit(volatile void *address, uint32 bit) { return *bb_perip(address, bit); } @@ -96,15 +101,18 @@ static inline uint8 bb_peri_get_bit(__io void *address, uint32 bit) { * @param bit Bit in address to write to * @param val Value to write for bit, either 0 or 1. */ -static inline void bb_peri_set_bit(__io void *address, uint32 bit, uint8 val) { +static inline void bb_peri_set_bit(volatile void *address, + uint32 bit, + uint8 val) { *bb_perip(address, bit) = val; } -static inline __io uint32* __bb_addr(__io void *address, - uint32 bit, - uint32 bb_base, - uint32 bb_ref) { - return (__io uint32*)(bb_base + ((uint32)address - bb_ref) * 32 + bit * 4); +static inline volatile uint32* __bb_addr(volatile void *address, + uint32 bit, + uint32 bb_base, + uint32 bb_ref) { + return (volatile uint32*)(bb_base + ((uint32)address - bb_ref) * 32 + + bit * 4); } #endif /* _BITBAND_H_ */ |