1 /**************************************************************************//**
3 * @brief CMSIS Cortex-A Core Peripheral Access Layer Header File
4 ******************************************************************************/
6 /* IO definitions (access restrictions to peripheral registers) */
8 \defgroup peripheral_gr Peripheral Access
9 \brief Naming conventions and optional features for accessing peripherals.
11 The section below describes the naming conventions, requirements, and optional features for accessing device specific peripherals.
12 Most of the rules also apply to the core peripherals. The \ref device_h_pg "Device Header File \<device.h>" contains typically these definition and also includes
13 the core specific header files.
15 The definitions for \ref peripheral_gr can be generated using the <a href="../../SVD/html/index.html"><b>CMSIS-SVD</b></a> System View Description for Peripherals.
16 Refer to <a href="../../SVD/html/svd_SVDConv_pg.html"><b>SVDConv.exe</b></a> for more information.
18 Each peripheral provides a data type definition with a name that is composed of:
19 - an optional prefix <b><<i>device abbreviation></i>_</b>
20 - <b><<i>peripheral name</i>></b>
21 - postfix \b _Type or \b _TypeDef to identify a type definition.
24 - \b UART_TypeDef for the peripheral \b UART.
25 - \b IMX_UART_TypeDef for the device family \b IMX and the peripheral \b UART.
27 The data type definition uses standard C data types defined by the ANSI C header file <stdint.h>.
29 - IO Type Qualifiers are used to specify the access to peripheral variables.
30 IO Type Qualifier | Type | Description
31 :------------------|:----------------|:------------
32 \b __IM | Struct member | Defines 'read only' permissions
33 \b __OM | Struct member | Defines 'write only' permissions
34 \b __IOM | Struct member | Defines 'read / write' permissions
35 \b __I | Scalar variable | Defines 'read only' permissions
36 \b __O | Scalar variable | Defines 'write only' permissions
37 \b __IO | Scalar variable | Defines 'read / write' permissions
39 The typedef <b>\<<i>device abbreviation</i>\>_UART_TypeDef</b> shown below defines the generic register layout for all UART channels in a device.
43 __O uint32_t UART_CR; // Offset: 0x0000 ( /W) Control Register
44 __IO uint32_t UART_MR; // Offset: 0x0004 (R/W) Mode Register
45 __O uint32_t UART_IER; // Offset: 0x0008 ( /W) Interrupt Enable Register
46 __O uint32_t UART_IDR; // Offset: 0x000C ( /W) Interrupt Disable Register
47 __I uint32_t UART_IMR; // Offset: 0x0010 (R/ ) Interrupt Mask Register
48 __I uint32_t UART_SR; // Offset: 0x0014 (R/ ) Status Register
49 __I uint32_t UART_RHR; // Offset: 0x0018 (R/ ) Receive Holding Register
50 __O uint32_t UART_THR; // Offset: 0x001C ( /W) Transmit Holding Register
51 __IO uint32_t UART_BRGR; // Offset: 0x0020 (R/W) Baud Rate Generator Register
52 __IO uint32_t UART_CMPR; // Offset: 0x0024 (R/W) Comparison Register
53 __IO uint32_t UART_RTOR; // Offset: 0x0028 (R/W) Receiver Time-out Register
54 __I uint32_t RESERVED[46]; // Offset: 0x002C (R/ ) Reserved
55 __IO uint32_t UART_WPMR; // Offset: 0x00E4 (R/W) Write Protection Mode Register
59 To access the registers of the UART defined above, pointers to this register structure are defined.
60 If more instances of a peripheral exist, the variables have a postfix (digit or letter) that identifies the peripheral.
63 In this example, \b IMX_UART2 and \b IMX_UART3 are two pointers to UARTs defined with above register structure.
66 #define IMX_UART2 ((IMX_UART_TypeDef *) IMX_UART2_BASE)
67 #define IMX_UART3 ((IMX_UART_TypeDef *) IMX_UART3_BASE)
71 - The prefix <b>IMX</b> is optional.
73 The registers in the various UARTs can now be referred in the user code as shown below:\n
75 val = IMX_UART2->SR // is the Status Register of UART2.
80 \section core_cmsis_pal_min_reqs Minimal Requirements
82 To access the peripheral registers and related function in a device, the files <b><i>device.h</i></b> and <b>core_ca.h</b> define as a minimum:
84 - The <b>Register Layout Typedef</b> for each peripheral that defines all register names.
85 RESERVED is used to introduce space into the structure for adjusting the addresses of
86 the peripheral registers.
92 __IOM uint32_t C_CTLR; // Offset: 0x0000 (R/W) CPU Interface Control Register
93 __IOM uint32_t C_PMR; // Offset: 0x0004 (R/W) Interrupt Priority Mask Register
94 __IOM uint32_t C_BPR; // Offset: 0x0008 (R/W) Binary Point Register
95 __IM uint32_t C_IAR; // Offset: 0x000C (R/ ) Interrupt Acknowledge Register
96 __OM uint32_t C_EOIR; // Offset: 0x0010 ( /W) End Of Interrupt Register
97 __IM uint32_t C_RPR; // Offset: 0x0014 (R/ ) Running Priority Register
98 __IM uint32_t C_HPPIR; // Offset: 0x0018 (R/ ) Highest Priority Pending Interrupt Register
99 __IOM uint32_t C_ABPR; // Offset: 0x001C (R/W) Aliased Binary Point Register
100 __IM uint32_t C_AIAR; // Offset: 0x0020 (R/ ) Aliased Interrupt Acknowledge Register
101 __OM uint32_t C_AEOIR; // Offset: 0x0024 ( /W) Aliased End Of Interrupt Register
102 __IM uint32_t C_AHPPIR; // Offset: 0x0028 (R/ ) Aliased Highest Priority Pending Interrupt Register
103 __IOM uint32_t C_STATUSR; // Offset: 0x002C (R/W) Error Reporting Status Register, optional
104 __I uint32_t RESERVED1[40]; // Offset: 0x0030 (R/ ) Reserved
105 __IOM uint32_t C_APR[4]; // Offset: 0x00D0 (R/W) Active Priority Register
106 __IOM uint32_t C_NSAPR[4]; // Offset: 0x00E0 (R/W) Non-secure Active Priority Register
107 __I uint32_t RESERVED2[3]; // Offset: 0x00F6 (R/ ) Reserved
108 __IM uint32_t C_IIDR; // Offset: 0x00FC (R/ ) CPU Interface Identification Register
109 __I uint32_t RESERVED3[960]; // Offset: 0x0100 (R/ ) Reserved
110 __OM uint32_t C_DIR; // Offset: 0x1000 ( /W) Deactivate Interrupt Register
115 - <b>Base Address</b> for each peripheral (in case of multiple peripherals
116 that use the same <b>register layout typedef</b> multiple base addresses are defined).
120 #define GIC_INTERFACE_BASE (0xe8202000UL) // GIC Interface Base Address
124 - <b>Access Definitions</b> for each peripheral. In case of multiple peripherals that are using the same
125 <b>register layout typedef</b>, multiple access definitions exist.
129 #define GICInterface ((GICInterface_Type *) GIC_INTERFACE_BASE) // GIC Interface Access Definition
133 These definitions allow accessing peripheral registers with simple assignments.
138 GICInterface->C_CTLR |= 1; // Enable Interface
143 \section core_cmsis_pal_opts Optional Features
145 Optionally, the file <b><i>device</i>.h</b> may define:
147 - \ref core_cmsis_pal_bitfields and \#define constants that simplify access to peripheral registers.
148 These constants may define bit-positions or other specific patterns that are required for
149 programming peripheral registers. The identifiers should start with
150 <b><<i>device abbreviation</i>>_</b> and <b><<i>peripheral name</i>>_</b>.
151 It is recommended to use CAPITAL letters for \#define constants.
153 - More complex functions (i.e. status query before
154 a sending register is accessed). Again, these functions start with
155 <b><<i>device abbreviation</i>>_</b> and <b><<i>peripheral name</i>>_</b>.
159 \section core_cmsis_pal_bitfields Register Bit Fields
162 For Core Register, macros define the position and the mask value for a bit field.
166 Bit field definitions for register ACTLR in CP15.
170 // CP15 Register ACTLR
171 #define ACTLR_DDI_Pos 28U
172 #define ACTLR_DDI_Msk (1UL << ACTLR_DDI_Pos)
174 #define ACTLR_DDVM_Pos 15U
175 #define ACTLR_DDVM_Msk (1UL << ACTLR_DDVM_Pos)
177 #define ACTLR_L1PCTL_Pos 13U
178 #define ACTLR_L1PCTL_Msk (3UL << ACTLR_L1PCTL_Pos)
180 #define ACTLR_L1RADIS_Pos 12U
181 #define ACTLR_L1RADIS_Msk (1UL << ACTLR_L1RADIS_Pos)
183 #define ACTLR_L2RADIS_Pos 11U
184 #define ACTLR_L2RADIS_Msk (1UL << ACTLR_L2RADIS_Pos)
186 #define ACTLR_DODMBS_Pos 10U
187 #define ACTLR_DODMBS_Msk (1UL << ACTLR_DODMBS_Pos)
189 #define ACTLR_SMP_Pos 6U
190 #define ACTLR_SMP_Msk (1UL << ACTLR_SMP_Pos)
193 The macros <b>_VAL2FLD(field, value)</b> and <b>_FLD2VAL(field, value)</b> enable access to bit fields.
198 \def _VAL2FLD(field, value)
199 \param field name of bit field.
200 \param value value for the bit field. This parameter is interpreted as an uint32_t type.
201 \brief Mask and shift a bit field value for assigning the result to a peripheral register.
203 The macro \ref _VAL2FLD uses the \#define's <i>_Pos</i> and <i>_Msk</i> of the related bit field to shift bit-field values for
204 assigning to a register.
208 ACTLR = _VAL2FLD(ACTLR_SMP, 0x1)
212 #define _VAL2FLD(field, value)
216 \def _FLD2VAL(field, value)
217 \param field name of bit field.
218 \param value value of the register. This parameter is interpreted as an uint32_t type.
219 \brief Extract from a peripheral register value the a bit field value.
221 The macro \ref _FLD2VAL uses the \#define's <i>_Pos</i> and <i>_Msk</i> of the related bit field to extract the value of a bit field from a register.
225 i = _FLD2VAL(ACTLR_SMP, ACTLR);
229 #define _FLD2VAL(field, value)
232 /*end of group peripheral_gr */
235 /*******************************************************************************
237 ******************************************************************************/
239 \defgroup version_ctrl Version Control
240 \brief Version symbols for CMSIS release specific C/C++ source code.
245 /* CMSIS CA definitions */
247 \def __CA_CMSIS_VERSION_MAIN
249 Use this define to query the major version of CMSIS-Core(A) component.
253 #if __CA_CMSIS_VERSION_MAIN < 5
254 #error This code needs at least CMSIS-Core(A) version 5!
258 \def __CA_CMSIS_VERSION_SUB
260 Use this define to query the minor version of CMSIS-Core(A) component.
264 #if __CA_CMSIS_VERSION_MAIN < 5
265 #error This code needs at least CMSIS-Core(A) version 5!
267 #if __CA_CMSIS_VERSION_SUB < 1
268 #warning Using CMSIS-Core(A) version 5.0 compatibility functions.
273 \def __CA_CMSIS_VERSION
275 Use this define to query the full version of CMSIS-Core(A) component.
277 | Bits | Name | Function |
278 | :------ | :------------ | :-----------------------|
279 | [31:16] | MAIN | __CA_CMSIS_VERSION_MAIN |
280 | [15:0] | SUB | __CA_CMSIS_VERSION_SUB |
285 #if __CA_CMSIS_VERSION < 0x00050001
286 #error This code needs at least CMSIS-Core(A) version 5.1!
291 \brief Contains the core revision for a Cortex-A class device.
293 Use this define to query the core design revision number implemented in the selected device.
295 | Bits | Name | Function |
296 | :------ | :------------ | :---------------|
297 | [15:8] | REV | Revision number |
298 | [7:0] | PATCH | Patch number |
302 #if __CA_REV < 0x0201
303 #error This code needs at least a core revision r2p1.
308 \brief Contains the core family for a Cortex-A class device.
310 Use this define to query the actual Cortex-A class device number implemented in the selected device.
315 #warning Running on Cortex-A5.
316 #elif __CORTEX_A == 7
317 #warning Running on Cortex-A7.
318 #elif __CORTEX_A == 9
319 #warning Running on Cortex-A9.
325 /*end of group version_ctrl */
328 \defgroup CMSIS_Core_FunctionInterface Core Peripherals
331 Hardware Abstraction Layer.
332 The Core-A function interface contains:
335 - \ref L1_cache_functions
336 - \ref L2_cache_functions
338 - \ref PL1_timer_functions
339 - \ref PTM_timer_functions
343 /* ########################## FPU functions ############################ */
345 \defgroup FPU_functions Floating Point Unit Functions
346 \ingroup CMSIS_Core_FunctionInterface
347 \brief FPU Functions enable the use of Floating Point instructions and extensions.\n
348 Reference: <a href="http://infocenter.arm.com/help/topic/com.arm.doc.ddi0406c/index.html">Architecture Reference Manual Reference Manual - ARMv7-A and ARMv7-R edition</a>.
350 \fn __STATIC_INLINE __ASM void __FPU_Enable(void)