distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
STM32-bit-banding.h
Go to the documentation of this file.
1 
12 #ifndef SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_STM32_BIT_BANDING_H_
13 #define SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_STM32_BIT_BANDING_H_
14 
16 
17 #if defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M3) || defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M4)
18 
19 #include <stddef.h>
20 
21 /*---------------------------------------------------------------------------------------------------------------------+
22 | global defines
23 +---------------------------------------------------------------------------------------------------------------------*/
24 
36 #define STM32_BITBAND_IMPLEMENTATION(base, type, member, mask) \
37  BITBAND_PERIPHERAL_ADDRESS(base + offsetof(type, member), __builtin_ctzl(mask))
38 
53 #define STM32_BITBAND_ADDRESS(registerr, member, bit) \
54  STM32_BITBAND_IMPLEMENTATION(registerr ## _BASE, registerr ## _TypeDef, member, \
55  registerr ## _ ## member ## _ ## bit)
56 
71 #define STM32_BITBAND(registerr, member, bit) \
72  (*(volatile unsigned long*)STM32_BITBAND_IMPLEMENTATION(registerr ## _BASE, registerr ## _TypeDef, member, \
73  registerr ## _ ## member ## _ ## bit))
74 
84 #define STM32_BITBAND_FLASH_ADDRESS(member, bit) \
85  STM32_BITBAND_IMPLEMENTATION(FLASH_R_BASE, FLASH_TypeDef, member, FLASH_ ## member ## _ ## bit)
86 
96 #define STM32_BITBAND_FLASH(member, bit) \
97  (*(volatile unsigned long*)STM32_BITBAND_IMPLEMENTATION(FLASH_R_BASE, FLASH_TypeDef, member, \
98  FLASH_ ## member ## _ ## bit))
99 
100 #endif /* defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M3) || defined(CONFIG_ARCHITECTURE_ARM_CORTEX_M4) */
101 
102 #endif /* SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_STM32_BIT_BANDING_H_ */
Header with definitions for bit-banding for ARMv7-M.