distortos  v0.5.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 #define DISTORTOS_BITBANDING_SUPPORTED
25 
27 enum { bitbandSramBegin = 0x20000000 };
28 
30 enum { bitbandSramEnd = 0x200fffff };
31 
33 enum { bitbandSramBase = 0x22000000 };
34 
36 enum { bitbandPeripheralBegin = 0x40000000 };
37 
39 enum { bitbandPeripheralEnd = 0x400fffff };
40 
42 enum { bitbandPeripheralBase = 0x42000000 };
43 
53 #define BITBAND_SRAM_ADDRESS(address, bit) \
54  (bitbandSramBase + (((unsigned long)address) - bitbandSramBegin) * 32 + (bit) * 4)
55 
65 #define BITBAND_PERIPHERAL_ADDRESS(address, bit) \
66  (bitbandPeripheralBase + (((unsigned long)address) - bitbandPeripheralBegin) * 32 + (bit) * 4)
67 
78 #define BITBAND_ADDRESS(address, bit) \
79  ((((unsigned long)address) >= bitbandSramBegin) && (((unsigned long)address) <= bitbandSramEnd) ? \
80  BITBAND_SRAM_ADDRESS(address, bit) : \
81  (((unsigned long)address) >= bitbandPeripheralBegin) && (((unsigned long)address) <= bitbandPeripheralEnd) ? \
82  BITBAND_PERIPHERAL_ADDRESS(address, bit) : \
83  0 /* fail */ )
84 
94 #define BITBAND_SRAM(address, bit) (*(volatile unsigned long*)BITBAND_SRAM_ADDRESS(address, bit))
95 
105 #define BITBAND_PERIPHERAL(address, bit) (*(volatile unsigned long*)BITBAND_PERIPHERAL_ADDRESS(address, bit))
106 
117 #define BITBAND(address, bit) (*(volatile unsigned long*)BITBAND_ADDRESS(address, bit))
118 
119 #endif /* defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M3) || defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M4) */
120 
121 #endif /* SOURCE_ARCHITECTURE_ARM_ARMV6_M_ARMV7_M_INCLUDE_DISTORTOS_ARCHITECTURE_ARMV7_M_BIT_BANDING_H_ */
distortos configuration