distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
ARMv7-M-bit-banding.h
Go to the documentation of this file.
1 
12 #ifndef SOURCE_ARCHITECTURE_ARM_ARMV6_M_ARMV7_M_INCLUDE_DISTORTOS_ARCHITECTURE_ARMV7_M_BIT_BANDING_H_
13 #define SOURCE_ARCHITECTURE_ARM_ARMV6_M_ARMV7_M_INCLUDE_DISTORTOS_ARCHITECTURE_ARMV7_M_BIT_BANDING_H_
14 
16 
17 #if defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M3) || defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M4)
18 
19 /*---------------------------------------------------------------------------------------------------------------------+
20 | global defines
21 +---------------------------------------------------------------------------------------------------------------------*/
22 
24 enum { bitbandSramBegin = 0x20000000 };
25 
27 enum { bitbandSramEnd = 0x200fffff };
28 
30 enum { bitbandSramBase = 0x22000000 };
31 
33 enum { bitbandPeripheralBegin = 0x40000000 };
34 
36 enum { bitbandPeripheralEnd = 0x400fffff };
37 
39 enum { bitbandPeripheralBase = 0x42000000 };
40 
50 #define BITBAND_SRAM_ADDRESS(address, bit) \
51  (bitbandSramBase + (((unsigned long)address) - bitbandSramBegin) * 32 + (bit) * 4)
52 
62 #define BITBAND_PERIPHERAL_ADDRESS(address, bit) \
63  (bitbandPeripheralBase + (((unsigned long)address) - bitbandPeripheralBegin) * 32 + (bit) * 4)
64 
75 #define BITBAND_ADDRESS(address, bit) \
76  ((((unsigned long)address) >= bitbandSramBegin) && (((unsigned long)address) <= bitbandSramEnd) ? \
77  BITBAND_SRAM_ADDRESS(address, bit) : \
78  (((unsigned long)address) >= bitbandPeripheralBegin) && (((unsigned long)address) <= bitbandPeripheralEnd) ? \
79  BITBAND_PERIPHERAL_ADDRESS(address, bit) : \
80  0 /* fail */ )
81 
91 #define BITBAND_SRAM(address, bit) (*(volatile unsigned long*)BITBAND_SRAM_ADDRESS(address, bit))
92 
102 #define BITBAND_PERIPHERAL(address, bit) (*(volatile unsigned long*)BITBAND_PERIPHERAL_ADDRESS(address, bit))
103 
114 #define BITBAND(address, bit) (*(volatile unsigned long*)BITBAND_ADDRESS(address, bit))
115 
116 #endif /* defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M3) || defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M4) */
117 
118 #endif /* SOURCE_ARCHITECTURE_ARM_ARMV6_M_ARMV7_M_INCLUDE_DISTORTOS_ARCHITECTURE_ARMV7_M_BIT_BANDING_H_ */
distortos configuration