1 /**
2   ******************************************************************************
3   * @file    stm32mp1xx.h
4   * @author  MCD Application Team
5   * @brief   CMSIS STM32MP1xx 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 STM32MP1xx device used in the target application
11   *              - To use or not the peripheral�s drivers in application code(i.e.
12   *                code will be based on direct access to peripheral�s registers
13   *                rather than drivers API), this option is controlled by
14   *                "#define USE_HAL_DRIVER"
15   *
16   ******************************************************************************
17   * @attention
18   *
19   * Copyright (c) 2019 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 stm32mp1xx
34   * @{
35   */
36 
37 #ifndef __STM32MP1xx_H
38 #define __STM32MP1xx_H
39 
40 #ifdef __cplusplus
41  extern "C" {
42 #endif /* __cplusplus */
43 
44 /** @addtogroup Library_configuration_section
45   * @{
46   */
47 
48 /* Uncomment the line below according to the target STM32MP1 device used in your
49    application
50   */
51 
52 #if !defined (STM32MP1)
53 #define STM32MP1
54 #endif /* STM32MP1 */
55 
56 /*  Tip: To avoid modifying this file each time you need to switch between these
57         devices, you can define the device in your toolchain compiler preprocessor.
58   */
59 #if !defined  (USE_HAL_DRIVER)
60 /**
61  * @brief Comment the line below if you will not use the peripherals drivers.
62    In this case, these drivers will not be included and the application code will
63    be based on direct access to peripherals registers
64    */
65   /*#define USE_HAL_DRIVER */
66 #endif /* USE_HAL_DRIVER */
67 
68 /**
69   * @brief CMSIS Device version number
70   */
71 #define __STM32MP1xx_CMSIS_VERSION_MAIN   (0x01U) /*!< [31:24] main version */
72 #define __STM32MP1xx_CMSIS_VERSION_SUB1   (0x06U) /*!< [23:16] sub1 version */
73 #define __STM32MP1xx_CMSIS_VERSION_SUB2   (0x00U) /*!< [15:8]  sub2 version */
74 #define __STM32MP1xx_CMSIS_VERSION_RC     (0x00U) /*!< [7:0]  release candidate */
75 #define __STM32MP1xx_CMSIS_VERSION        ((__CMSIS_DEVICE_VERSION_MAIN     << 24)\
76                                       |(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
77                                       |(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
78                                       |(__CMSIS_DEVICE_HAL_VERSION_RC))
79 
80 /**
81   * @}
82   */
83 
84 /** @addtogroup Device_Included
85   * @{
86   */
87 #if defined(CORE_CM4)
88 #if defined(STM32MP15xx)  /* keep for backward compatibility STM32MP15xx = STM32MP157Cxx */
89   #include "stm32mp157cxx_cm4.h"
90 #elif defined(STM32MP157Axx)
91   #include "stm32mp157axx_cm4.h"
92 #elif defined(STM32MP157Cxx)
93   #include "stm32mp157cxx_cm4.h"
94 #elif defined(STM32MP157Dxx)
95   #include "stm32mp157dxx_cm4.h"
96 #elif defined(STM32MP157Fxx)
97   #include "stm32mp157fxx_cm4.h"
98 #elif defined(STM32MP153Axx)
99   #include "stm32mp153axx_cm4.h"
100 #elif defined(STM32MP153Cxx)
101   #include "stm32mp153cxx_cm4.h"
102 #elif defined(STM32MP153Dxx)
103   #include "stm32mp153dxx_cm4.h"
104 #elif defined(STM32MP153Fxx)
105   #include "stm32mp153fxx_cm4.h"
106 #elif defined(STM32MP151Axx)
107   #include "stm32mp151axx_cm4.h"
108 #elif defined(STM32MP151Cxx)
109   #include "stm32mp151cxx_cm4.h"
110 #elif defined(STM32MP151Dxx)
111   #include "stm32mp151dxx_cm4.h"
112 #elif defined(STM32MP151Fxx)
113   #include "stm32mp151fxx_cm4.h"
114 #else
115  #error "Please select first the target STM32MP1xx device used in your application (in stm32mp1xx.h file)"
116 #endif
117 #endif
118 
119 #if defined(CORE_CA7)
120 #if defined(STM32MP15xx)  /* keep for backward compatibility STM32MP15xx = STM32MP157Cxx */
121   #include "stm32mp157cxx_ca7.h"
122 #elif defined(STM32MP157Axx)
123   #include "stm32mp157axx_ca7.h"
124 #elif defined(STM32MP157Cxx)
125   #include "stm32mp157cxx_ca7.h"
126 #elif defined(STM32MP157Dxx)
127   #include "stm32mp157dxx_ca7.h"
128 #elif defined(STM32MP157Fxx)
129   #include "stm32mp157fxx_ca7.h"
130 #elif defined(STM32MP153Axx)
131   #include "stm32mp153axx_ca7.h"
132 #elif defined(STM32MP153Cxx)
133   #include "stm32mp153cxx_ca7.h"
134 #elif defined(STM32MP153Dxx)
135   #include "stm32mp153dxx_ca7.h"
136 #elif defined(STM32MP153Fxx)
137   #include "stm32mp153fxx_ca7.h"
138 #elif defined(STM32MP151Axx)
139   #include "stm32mp151axx_ca7.h"
140 #elif defined(STM32MP151Cxx)
141   #include "stm32mp151cxx_ca7.h"
142 #elif defined(STM32MP151Dxx)
143   #include "stm32mp151dxx_ca7.h"
144 #elif defined(STM32MP151Fxx)
145   #include "stm32mp151fxx_ca7.h"
146 #else
147  #error "Please select first the target STM32MP1xx device used in your application (in stm32mp1xx.h file)"
148 #endif
149 #endif
150 
151 /**
152   * @}
153   */
154 
155 /** @addtogroup Exported_types
156   * @{
157   */
158 typedef enum
159 {
160   RESET = 0,
161   SET = !RESET
162 } FlagStatus, ITStatus;
163 
164 typedef enum
165 {
166   DISABLE = 0,
167   ENABLE = !DISABLE
168 } FunctionalState;
169 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
170 
171 typedef enum
172 {
173   ERROR = 0,
174   SUCCESS = !ERROR
175 } ErrorStatus;
176 
177 /**
178   * @}
179   */
180 
181 
182 /** @addtogroup Exported_macros
183   * @{
184   */
185 #define SET_BIT(REG, BIT)     ((REG) |= (BIT))
186 
187 #define CLEAR_BIT(REG, BIT)   ((REG) &= ~(BIT))
188 
189 #define READ_BIT(REG, BIT)    ((REG) & (BIT))
190 
191 #define CLEAR_REG(REG)        ((REG) = (0x0))
192 
193 #define WRITE_REG(REG, VAL)   ((REG) = (VAL))
194 
195 #define READ_REG(REG)         ((REG))
196 
197 #define MODIFY_REG(REG, CLEARMASK, SETMASK)  WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
198 
199 #define POSITION_VAL(VAL)     (__CLZ(__RBIT(VAL)))
200 
201 
202 /**
203   * @}
204   */
205 
206 #if defined (USE_HAL_DRIVER)
207  #include "stm32mp1xx_hal.h"
208 #endif /* USE_HAL_DRIVER */
209 
210 
211 #ifdef __cplusplus
212 }
213 #endif /* __cplusplus */
214 
215 #endif /* __STM32MP1xx_H */
216 /**
217   * @}
218   */
219 
220 /**
221   * @}
222   */
223