diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-03-21 04:21:12 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-03-21 04:21:55 -0400 |
commit | effd2fd66f3f67e42a3fc8c0e3c7a82f30dc2e44 (patch) | |
tree | ff759838925933694c03d0982b898b892f0f0a19 | |
parent | 7241820179bb729d14900676fbff943f7f44cb97 (diff) | |
download | librambutan-effd2fd66f3f67e42a3fc8c0e3c7a82f30dc2e44.tar.gz librambutan-effd2fd66f3f67e42a3fc8c0e3c7a82f30dc2e44.zip |
More convenient bit-banding interface
-rw-r--r-- | libmaple/bitband.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libmaple/bitband.h b/libmaple/bitband.h index b817f73..3e02702 100644 --- a/libmaple/bitband.h +++ b/libmaple/bitband.h @@ -48,6 +48,26 @@ static inline __io uint32* bb_sramp(__io void *address, uint32 bit) { } /** + * @brief Get a bit from an address in the SRAM bit-band region. + * @param address Address in the SRAM bit-band region to read from + * @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) { + return *bb_sramp(address, bit); +} + +/** + * @brief Set a bit in an address in the SRAM bit-band region. + * @param address Address in the SRAM bit-band region to write to + * @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) { + *bb_sramp(address, bit) = val; +} + +/** * @brief Obtain a pointer to the bit-band address corresponding to a * bit in a peripheral address. * @param address Address in the bit-banded peripheral region @@ -57,6 +77,26 @@ static inline __io uint32* bb_perip(__io void *address, uint32 bit) { return __bb_addr(address, bit, BB_PERI_BASE, BB_PERI_REF); } +/** + * @brief Get a bit from an address in the peripheral bit-band region. + * @param address Address in the peripheral bit-band region to read from + * @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) { + return *bb_perip(address, bit); +} + +/** + * @brief Set a bit in an address in the peripheral bit-band region. + * @param address Address in the peripheral bit-band region to write to + * @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) { + *bb_perip(address, bit) = val; +} + static inline __io uint32* __bb_addr(__io void *address, uint32 bit, uint32 bb_base, |