1 /** 2 ****************************************************************************** 3 * @file stm32h7rsxx.h 4 * @author MCD Application Team 5 * @brief CMSIS STM32H7RSxx Device Peripheral Access Layer Header File. 6 * 7 * The file is the unique include file that the application programmer 8 * is using in the C source code, usually in main.c. This file contains: 9 * - Configuration section that allows to select: 10 * - The STM32H7RSxx device used in the target application 11 * - To use or not the peripherals drivers in application code(i.e. 12 * code will be based on direct access to peripherals registers 13 * rather than drivers API), this option is controlled by 14 * "#define USE_HAL_DRIVER" 15 * 16 ****************************************************************************** 17 * @attention 18 * 19 * Copyright (c) 2022 STMicroelectronics. 20 * All rights reserved. 21 * 22 * This software is licensed under terms that can be found in the LICENSE file 23 * in the root directory of this software component. 24 * If no LICENSE file comes with this software, it is provided AS-IS. 25 * 26 ****************************************************************************** 27 */ 28 29 /** @addtogroup CMSIS 30 * @{ 31 */ 32 33 /** @addtogroup stm32h7rsxx 34 * @{ 35 */ 36 37 #ifndef STM32H7RSxx_H 38 #define STM32H7RSxx_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif /* __cplusplus */ 43 44 /** @addtogroup Library_configuration_section 45 * @{ 46 */ 47 48 /** 49 * @brief STM32 Family 50 */ 51 #if !defined (STM32H7RS) 52 #define STM32H7RS 53 #endif /* STM32H7RS */ 54 55 /* Uncomment the line below according to the target STM32H7RS device used in your 56 application 57 */ 58 59 #if !defined (STM32H7R7xx) && !defined (STM32H7R3xx) && !defined (STM32H7S3xx) && !defined (STM32H7S7xx) 60 /* #define STM32H7R3xx */ /*!< STM32H7R3xx Devices */ 61 /* #define STM32H7R7xx */ /*!< STM32H7R7xx Devices */ 62 /* #define STM32H7S3xx */ /*!< STM32H7S3xx Devices */ 63 /* #define STM32H7S7xx */ /*!< STM32H7S7xx Devices */ 64 #endif 65 66 /* Tip: To avoid modifying this file each time you need to switch between these 67 devices, you can define the device in your toolchain compiler preprocessor. 68 */ 69 #if !defined (USE_HAL_DRIVER) 70 /** 71 * @brief Comment the line below if you will not use the peripherals drivers. 72 In this case, these drivers will not be included and the application code will 73 be based on direct access to peripherals registers 74 */ 75 /*#define USE_HAL_DRIVER */ 76 #endif /* USE_HAL_DRIVER */ 77 78 /** 79 * @brief CMSIS Device version number 80 */ 81 #define __STM32H7RS_CMSIS_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 82 #define __STM32H7RS_CMSIS_VERSION_SUB1 (0x01U) /*!< [23:16] sub1 version */ 83 #define __STM32H7RS_CMSIS_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 84 #define __STM32H7RS_CMSIS_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 85 #define __STM32H7RS_CMSIS_VERSION ((__STM32H7RS_CMSIS_VERSION_MAIN << 24U)\ 86 |(__STM32H7RS_CMSIS_VERSION_SUB1 << 16U)\ 87 |(__STM32H7RS_CMSIS_VERSION_SUB2 << 8U )\ 88 |(__STM32H7RS_CMSIS_VERSION_RC)) 89 90 /** 91 * @} 92 */ 93 94 /** @addtogroup Device_Included 95 * @{ 96 */ 97 98 #if defined(STM32H7R3xx) 99 #include "stm32h7r3xx.h" 100 #elif defined(STM32H7R7xx) 101 #include "stm32h7r7xx.h" 102 #elif defined(STM32H7S3xx) 103 #include "stm32h7s3xx.h" 104 #elif defined(STM32H7S7xx) 105 #include "stm32h7s7xx.h" 106 #else 107 #error "Please select first the target STM32H7RSxx device used in your application (in stm32h7rsxx.h file)" 108 #endif 109 110 /** 111 * @} 112 */ 113 114 /** @addtogroup Exported_types 115 * @{ 116 */ 117 typedef enum 118 { 119 RESET = 0, 120 SET = !RESET 121 } FlagStatus, ITStatus; 122 123 typedef enum 124 { 125 DISABLE = 0, 126 ENABLE = !DISABLE 127 } FunctionalState; 128 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 129 130 typedef enum 131 { 132 SUCCESS = 0, 133 ERROR = !SUCCESS 134 } ErrorStatus; 135 136 /** 137 * @} 138 */ 139 140 141 /** @addtogroup Exported_macros 142 * @{ 143 */ 144 #define SET_BIT(REG, BIT) ((REG) |= (BIT)) 145 146 #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) 147 148 #define READ_BIT(REG, BIT) ((REG) & (BIT)) 149 150 #define CLEAR_REG(REG) ((REG) = (0x0)) 151 152 #define WRITE_REG(REG, VAL) ((REG) = (VAL)) 153 154 #define READ_REG(REG) ((REG)) 155 156 #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) 157 158 #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) 159 160 /* Use of CMSIS compiler intrinsics for register exclusive access */ 161 /* Atomic 32-bit register access macro to set one or several bits */ 162 #define ATOMIC_SET_BIT(REG, BIT) \ 163 do { \ 164 uint32_t val; \ 165 do { \ 166 val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \ 167 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 168 } while(0) 169 170 /* Atomic 32-bit register access macro to clear one or several bits */ 171 #define ATOMIC_CLEAR_BIT(REG, BIT) \ 172 do { \ 173 uint32_t val; \ 174 do { \ 175 val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \ 176 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 177 } while(0) 178 179 /* Atomic 32-bit register access macro to clear and set one or several bits */ 180 #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \ 181 do { \ 182 uint32_t val; \ 183 do { \ 184 val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 185 } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \ 186 } while(0) 187 188 /* Atomic 16-bit register access macro to set one or several bits */ 189 #define ATOMIC_SETH_BIT(REG, BIT) \ 190 do { \ 191 uint16_t val; \ 192 do { \ 193 val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \ 194 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 195 } while(0) 196 197 /* Atomic 16-bit register access macro to clear one or several bits */ 198 #define ATOMIC_CLEARH_BIT(REG, BIT) \ 199 do { \ 200 uint16_t val; \ 201 do { \ 202 val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \ 203 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 204 } while(0) 205 206 /* Atomic 16-bit register access macro to clear and set one or several bits */ 207 #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \ 208 do { \ 209 uint16_t val; \ 210 do { \ 211 val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \ 212 } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \ 213 } while(0) 214 215 /** 216 * @} 217 */ 218 219 #if defined (USE_HAL_DRIVER) 220 #include "stm32h7rsxx_hal.h" 221 #endif /* USE_HAL_DRIVER */ 222 223 #ifdef __cplusplus 224 } 225 #endif /* __cplusplus */ 226 227 #endif /* STM32H7RSxx_H */ 228 /** 229 * @} 230 */ 231 232 /** 233 * @} 234 */ 235