em_bitband.h
Go to the documentation of this file.00001
00034 #ifndef __SILICON_LABS_EM_BITBAND_H_
00035 #define __SILICON_LABS_EM_BITBAND_H_
00036
00037 #include "em_device.h"
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041
00042
00047
00053
00071 __STATIC_INLINE void BITBAND_Peripheral(volatile uint32_t *addr,
00072 uint32_t bit,
00073 uint32_t val)
00074 {
00075 #if defined(BITBAND_PER_BASE)
00076 uint32_t tmp =
00077 BITBAND_PER_BASE + (((uint32_t)addr - PER_MEM_BASE) * 32) + (bit * 4);
00078
00079 *((volatile uint32_t *)tmp) = (uint32_t)val;
00080 #else
00081 uint32_t tmp = *addr;
00082
00083 val &= 0x1;
00084 *addr = (tmp & ~(1 << bit)) | (val << bit);
00085 #endif
00086 }
00087
00088
00089
00105 __STATIC_INLINE uint32_t BITBAND_PeripheralRead(volatile uint32_t *addr,
00106 uint32_t bit)
00107 {
00108 #if defined(BITBAND_PER_BASE)
00109 uint32_t tmp =
00110 BITBAND_PER_BASE + (((uint32_t)addr - PER_MEM_BASE) * 32) + (bit * 4);
00111
00112 return *((volatile uint32_t *)tmp);
00113 #else
00114 return ((*addr) >> bit) & 1;
00115 #endif
00116 }
00117
00118
00119
00137 __STATIC_INLINE void BITBAND_SRAM(uint32_t *addr, uint32_t bit, uint32_t val)
00138 {
00139 #if defined(BITBAND_RAM_BASE)
00140 uint32_t tmp =
00141 BITBAND_RAM_BASE + (((uint32_t)addr - RAM_MEM_BASE) * 32) + (bit * 4);
00142
00143 *((volatile uint32_t *)tmp) = (uint32_t)val;
00144 #else
00145 uint32_t tmp = *addr;
00146
00147 val &= 0x1;
00148 *addr = (tmp & ~(1 << bit)) | (val << bit);
00149 #endif
00150 }
00151
00152
00153
00169 __STATIC_INLINE uint32_t BITBAND_SRAMRead(uint32_t *addr, uint32_t bit)
00170 {
00171 #if defined(BITBAND_RAM_BASE)
00172 uint32_t tmp =
00173 BITBAND_RAM_BASE + (((uint32_t)addr - RAM_MEM_BASE) * 32) + (bit * 4);
00174
00175 return *((volatile uint32_t *)tmp);
00176 #else
00177 return ((*addr) >> bit) & 1;
00178 #endif
00179 }
00180
00184 #ifdef __cplusplus
00185 }
00186 #endif
00187
00188 #endif