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 LPC_UART_TypeDef for the device family \b LPC 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.
45 __IM uint8_t RBR; // Offset: 0x000 (R/ ) Receiver Buffer Register
46 __OM uint8_t THR; // Offset: 0x000 ( /W) Transmit Holding Register
47 __IOM uint8_t DLL; // Offset: 0x000 (R/W) Divisor Latch LSB
51 __IOM uint8_t DLM; // Offset: 0x004 (R/W) Divisor Latch MSB
52 __IOM uint32_t IER; // Offset: 0x004 (R/W) Interrupt Enable Register
55 __IM uint32_t IIR; // Offset: 0x008 (R/ ) Interrupt ID Register
56 __OM uint8_t FCR; // Offset: 0x008 ( /W) FIFO Control Register
58 __IOM uint8_t LCR; // Offset: 0x00C (R/W) Line Control Register
60 __IM uint8_t LSR; // Offset: 0x014 (R/ ) Line Status Register
62 __IOM uint8_t SCR; // Offset: 0x01C (R/W) Scratch Pad Register
64 __IOM uint32_t ACR; // Offset: 0x020 (R/W) Autobaud Control Register
65 __IOM uint8_t ICR; // Offset: 0x024 (R/W) IrDA Control Register
67 __IOM uint8_t FDR; // Offset: 0x028 (R/W) Fractional Divider Register
69 __IOM uint8_t TER; // Offset: 0x030 (R/W) Transmit Enable Register
70 uint8_t RESERVED6[39];
71 __IM uint8_t FIFOLVL; // Offset: 0x058 (R/ ) FIFO Level Register
75 To access the registers of the UART defined above, pointers to this register structure are defined.
76 If more instances of a peripheral exist, the variables have a postfix (digit or letter) that identifies the peripheral.
79 In this example, \b LPC_UART2 and \b LPC_UART3 are two pointers to UARTs defined with above register structure.
82 #define LPC_UART2 ((LPC_UART_TypeDef *) LPC_UART2_BASE )
83 #define LPC_UART3 ((LPC_UART_TypeDef *) LPC_UART3_BASE )
87 - The prefix <b>LPC</b> is optional.
89 The registers in the various UARTs can now be referred in the user code as shown below:\n
91 val = LPC_UART2->DR // is the data register of UART1.
96 \section core_cmsis_pal_min_reqs Minimal Requirements
98 To access the peripheral registers and related function in a device, the files <b><i>device.h</i></b> and <b>core_ca<i>#</i>.h</b> define as a minimum:
100 - The <b>Register Layout Typedef</b> for each peripheral that defines all register names.
101 RESERVED is used to introduce space into the structure for adjusting the addresses of
102 the peripheral registers.
108 __IOM uint32_t CTRL; // Offset: 0x000 (R/W) SysTick Control and Status Register
109 __IOM uint32_t LOAD; // Offset: 0x004 (R/W) SysTick Reload Value Register
110 __IOM uint32_t VAL; // Offset: 0x008 (R/W) SysTick Current Value Register
111 __IM uint32_t CALIB; // Offset: 0x00C (R/ ) SysTick Calibration Register
116 - <b>Base Address</b> for each peripheral (in case of multiple peripherals
117 that use the same <b>register layout typedef</b> multiple base addresses are defined).
121 #define SysTick_BASE (SCS_BASE + 0x0010) // SysTick Base Address
125 - <b>Access Definitions</b> for each peripheral. In case of multiple peripherals that are using the same
126 <b>register layout typdef</b>, multiple access definitions exist (LPC_UART0, LPC_UART2).
130 #define SysTick ((SysTick_Type *) Systick_BASE) // SysTick access definition
134 These definitions allow accessing peripheral registers with simple assignments.
144 \section core_cmsis_pal_opts Optional Features
146 Optionally, the file <b><i>device</i>.h</b> may define:
148 - \ref core_cmsis_pal_bitfields and \#define constants that simplify access to peripheral registers.
149 These constants may define bit-positions or other specific patterns that are required for
150 programming peripheral registers. The identifiers should start with
151 <b><<i>device abbreviation</i>>_</b> and <b><<i>peripheral name</i>>_</b>.
152 It is recommended to use CAPITAL letters for \#define constants.
154 - More complex functions (i.e. status query before
155 a sending register is accessed). Again, these functions start with
156 <b><<i>device abbreviation</i>>_</b> and <b><<i>peripheral name</i>>_</b>.
160 \section core_cmsis_pal_bitfields Register Bit Fields
163 For Core Register, macros define the position and the mask value for a bit field. It is recommended to create such definitions also
164 for other peripheral registers.
168 Bit field definitions for register CPUID in SCB (System Control Block).
172 // SCB CPUID Register Definitions
173 #define SCB_CPUID_IMPLEMENTER_Pos 24U
174 #define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos)
176 #define SCB_CPUID_VARIANT_Pos 20U
177 #define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos)
179 #define SCB_CPUID_ARCHITECTURE_Pos 16U
180 #define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos)
182 #define SCB_CPUID_PARTNO_Pos 4U
183 #define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos)
185 #define SCB_CPUID_REVISION_Pos 0U
186 #define SCB_CPUID_REVISION_Msk (0xFUL)
189 The macros <b>_VAL2FLD(field, value)</b> and <b>_FLD2VAL(field, value)</b> enable access to bit fields.
204 /*end of group peripheral_gr */
207 /*******************************************************************************
209 ******************************************************************************/
211 \defgroup CMSIS_glob_defs CMSIS Global Defines
212 \brief Definitions common to all interfaces
213 <b>IO Type Qualifiers</b> are used
214 \li to specify the access to peripheral variables.
215 \li for automatic generation of peripheral register debug information.
219 /* CMSIS CA definitions */
221 \def __CA_CMSIS_VERSION_MAIN
222 \def __CA_CMSIS_VERSION_SUB
223 \def __CA_CMSIS_VERSION
228 __FPU_USED indicates whether an FPU is used or not. For this, \ref __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions.
234 /*end of group CMSIS_glob_defs */
239 \defgroup core_reg_gr Core Register Defines
240 \ingroup core_reg_func_gr
241 \brief Type definitions and defines for Cortex-A processor based devices.
245 /* Core Register CPSR */
247 \defgroup CMSIS_CPSR Core Register CPSR
248 \brief Type definitions and defines for CPSR
255 // CPSR Register Definitions
273 /* end group CMSIS_CPSR */
276 /* CP15 Register SCTLR */
278 \defgroup CMSIS_SCTLR Core Register SCTLR
279 \brief Type definitions and defines for SCTLR
302 \def SCTLR_CP15BEN_Pos
308 /* end group CMSIS_SCTLR */
310 /* CP15 Register CPACR */
312 \defgroup CMSIS_CPACR Core Register CPACR
313 \brief Type definitions and defines for CPACR
319 \def CPACR_ASEDIS_Pos
320 \def CPACR_D32DIS_Pos
325 /* end group CMSIS_CPACR */
327 /* CP15 Register DFSR */
329 \defgroup CMSIS_DFSR Core Register DFSR
330 \brief Type definitions and defines for DFSR
344 /* end group CMSIS_DFSR */
346 /* CP15 Register IFSR */
348 \defgroup CMSIS_IFSR Core Register IFSR
349 \brief Type definitions and defines for IFSR
360 /* end group CMSIS_IFSR */
362 /* CP15 Register ISR */
364 \defgroup CMSIS_ISR Core Register ISR
365 \brief Type definitions and defines for ISR
376 /* end group CMSIS_ISR */
379 /* end of group CMSIS_core_register */
382 \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
385 Hardware Abstraction Layer.
386 The Core-A function interface contains:
387 - \ref L1_chache_functions
388 - \ref L2_chache_functions
389 - \ref PL1_timer_functions
397 /* ########################## L1 Cache functions ################################# */
400 \defgroup L1_chache_functions L1 Cache Functions
402 \fn __STATIC_INLINE void L1C_EnableCaches(void)
403 \fn __STATIC_INLINE void L1C_DisableCaches(void)
404 \fn __STATIC_INLINE void L1C_EnableBTAC(void)
405 \fn __STATIC_INLINE void L1C_DisableBTAC(void)
406 \fn __STATIC_INLINE void L1C_InvalidateBTAC(void)
407 \fn __STATIC_INLINE void L1C_InvalidateICacheAll(void)
408 \fn __STATIC_INLINE void L1C_CleanDCacheMVA(void *va)
409 \fn __STATIC_INLINE void L1C_InvalidateDCacheMVA(void *va)
410 \fn __STATIC_INLINE void L1C_CleanInvalidateDCacheMVA(void *va)
411 \fn __STATIC_INLINE void L1C_CleanInvalidateCache(uint32_t op)
412 \fn __STATIC_INLINE void L1C_InvalidateDCacheAll(void)
413 \fn __STATIC_INLINE void L1C_CleanDCacheAll(void)
414 \fn __STATIC_INLINE void L1C_CleanInvalidateDCacheAll(void)
415 \fn __STATIC_ASM void __L1C_CleanInvalidateCache(uint32_t op)
419 /* ########################## L2 Cache functions ################################# */
421 //Cache Sync operation
423 \defgroup L2_chache_functions L2C-310 Cache Controller Functions
425 \struct L2C_310_TypeDef
427 \fn __STATIC_INLINE void L2C_Sync(void)
428 \fn __STATIC_INLINE int L2C_GetID (void)
429 \fn __STATIC_INLINE int L2C_GetType (void)
430 \fn __STATIC_INLINE void L2C_InvAllByWay (void)
431 \fn __STATIC_INLINE void L2C_CleanInvAllByWay (void)
432 \fn __STATIC_INLINE void L2C_Enable(void)
433 \fn __STATIC_INLINE void L2C_Disable(void)
434 \fn __STATIC_INLINE void L2C_InvPa (void *pa)
435 \fn __STATIC_INLINE void L2C_CleanPa (void *pa)
436 \fn __STATIC_INLINE void L2C_CleanInvPa (void *pa)
440 /* ########################## GIC functions ###################################### */
442 \defgroup GIC_functions GIC functions
444 \struct GICDistributor_Type
446 \struct GICInterface_Type
448 \fn __STATIC_INLINE void GIC_EnableDistributor(void)
449 \fn __STATIC_INLINE void GIC_DisableDistributor(void)
450 \fn __STATIC_INLINE uint32_t GIC_DistributorInfo(void)
451 \fn __STATIC_INLINE uint32_t GIC_DistributorImplementer(void)
452 \fn __STATIC_INLINE void GIC_SetTarget(IRQn_Type IRQn, uint32_t cpu_target)
453 \fn __STATIC_INLINE void GIC_SetICDICFR (const uint32_t *ICDICFRn)
454 \fn __STATIC_INLINE uint32_t GIC_GetTarget(IRQn_Type IRQn)
455 \fn __STATIC_INLINE void GIC_EnableInterface(void)
456 \fn __STATIC_INLINE void GIC_DisableInterface(void)
457 \fn __STATIC_INLINE IRQn_Type GIC_AcknowledgePending(void)
458 \fn __STATIC_INLINE void GIC_EndInterrupt(IRQn_Type IRQn)
459 \fn __STATIC_INLINE void GIC_EnableIRQ(IRQn_Type IRQn)
460 \fn __STATIC_INLINE void GIC_DisableIRQ(IRQn_Type IRQn)
461 \fn __STATIC_INLINE void GIC_SetPendingIRQ(IRQn_Type IRQn)
462 \fn __STATIC_INLINE void GIC_ClearPendingIRQ(IRQn_Type IRQn)
463 \fn __STATIC_INLINE void GIC_SetLevelModel(IRQn_Type IRQn, int8_t edge_level, int8_t model)
464 \fn __STATIC_INLINE void GIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
465 \fn __STATIC_INLINE uint32_t GIC_GetPriority(IRQn_Type IRQn)
466 \fn __STATIC_INLINE void GIC_InterfacePriorityMask(uint32_t priority)
467 \fn __STATIC_INLINE void GIC_SetBinaryPoint(uint32_t binary_point)
468 \fn __STATIC_INLINE uint32_t GIC_GetBinaryPoint(uint32_t binary_point)
469 \fn __STATIC_INLINE uint32_t GIC_GetIRQStatus(IRQn_Type IRQn)
470 \fn __STATIC_INLINE void GIC_SendSGI(IRQn_Type IRQn, uint32_t target_list, uint32_t filter_list)
471 \fn __STATIC_INLINE void GIC_DistInit(void)
472 \fn __STATIC_INLINE void GIC_CPUInterfaceInit(void)
473 \fn __STATIC_INLINE void GIC_Enable(void)
477 /* ########################## Generic Timer functions ############################ */
479 \defgroup pl1_timer_gr Generic Timer Functions
480 \brief Generic hardware timer functions
483 /* leave the function defs in here */
486 The function \b PL1_SetLoadValue sets the reset value of the timer.
488 __STATIC_INLINE void PL1_SetLoadValue(uint32_t value);
492 The function \b PL1_GetCurrentValue returns the current timer value.
494 __STATIC_INLINE uint32_t PL1_GetCurrentValue();
498 The function \b PL1_SetControl sets timer control values.
500 __STATIC_INLINE void PL1_SetControl(uint32_t value);
503 /* end of pl1_timer_gr */
506 /* ########################## Private Timer functions ############################ */
508 \defgroup PTM_timer_functions Private Timer Functions
509 \brief Private timer functions
513 \fn __STATIC_INLINE void PTIM_SetLoadValue(uint32_t value)
514 \fn __STATIC_INLINE uint32_t PTIM_GetLoadValue()
515 \fn __STATIC_INLINE uint32_t PTIM_GetCurrentValue()
516 \fn __STATIC_INLINE void PTIM_SetControl(uint32_t value)
517 \fn __STATIC_INLINE uint32_t PTIM_GetControl(void)
518 \fn __STATIC_INLINE void PTIM_ClearEventFlag(void)
522 /* ########################## FPU functions ############################ */
524 \defgroup FPU_functions Floating Point Unit Functions
527 \fn __STATIC_ASM void __FPU_Enable(void)
531 /* ########################## MMU functions ###################################### */
533 \defgroup MMU_gr MMU Functions
534 \brief Functions and defines that relate to the Memory Management Unit
539 \defgroup MMU_defs_gr MMU Defines and Structs
540 \brief Defines and structures that relate to the Memory Management Unit
545 \def SECTION_DESCRIPTOR
548 \def SECTION_TEX0_SHIFT
549 \def SECTION_TEX1_SHIFT
550 \def SECTION_TEX2_SHIFT
551 \def SECTION_XN_SHIFT
552 \def SECTION_DOMAIN_SHIFT
554 \def SECTION_AP_SHIFT
555 \def SECTION_AP2_SHIFT
557 \def SECTION_NG_SHIFT
558 \def SECTION_NS_SHIFT
559 \def PAGE_L1_DESCRIPTOR
561 \def PAGE_L2_64K_DESC
564 \def PAGE_4K_TEX0_SHIFT
565 \def PAGE_4K_TEX1_SHIFT
566 \def PAGE_4K_TEX2_SHIFT
567 \def PAGE_64K_B_SHIFT
568 \def PAGE_64K_C_SHIFT
569 \def PAGE_64K_TEX0_SHIFT
570 \def PAGE_64K_TEX1_SHIFT
571 \def PAGE_64K_TEX2_SHIFT
575 \def PAGE_XN_4K_SHIFT
576 \def PAGE_XN_64K_SHIFT
577 \def PAGE_DOMAIN_SHIFT
587 \def DESCRIPTOR_FAULT
589 \enum mmu_region_size_Type
590 \enum mmu_memory_Type
591 \enum mmu_cacheability_Type
592 \enum mmu_ecc_check_Type
593 \enum mmu_execute_Type
594 \enum mmu_global_Type
595 \enum mmu_shared_Type
596 \enum mmu_secure_Type
597 \enum mmu_access_Type
599 \struct mmu_region_attributes_Type
601 \def section_normal(descriptor_l1, region)
602 \def section_normal_cod(descriptor_l1, region)
603 \def section_normal_ro(descriptor_l1, region)
604 \def section_normal_rw(descriptor_l1, region)
605 \def section_so(descriptor_l1, region)
606 \def section_device_ro(descriptor_l1, region)
607 \def section_device_rw(descriptor_l1, region)
608 \def page4k_device_rw(descriptor_l1, descriptor_l2, region)
609 \def page64k_device_rw(descriptor_l1, descriptor_l2, region)
612 /* end group MMU_defs_gr */
614 /* start grouping functions */
620 \fn __STATIC_INLINE int MMU_XNSection(uint32_t *descriptor_l1, mmu_execute_Type xn)
622 The function sets section execution-never attribute
624 \fn __STATIC_INLINE int MMU_DomainSection(uint32_t *descriptor_l1, uint8_t domain)
626 The function sets section domain.
628 \fn __STATIC_INLINE int MMU_PSection(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
630 The function sets section parity check
632 \fn __STATIC_INLINE int MMU_APSection(uint32_t *descriptor_l1, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
634 The function sets section access privileges
636 \fn __STATIC_INLINE int MMU_SharedSection(uint32_t *descriptor_l1, mmu_shared_Type s_bit)
638 The function sets section shareability
640 \fn __STATIC_INLINE int MMU_GlobalSection(uint32_t *descriptor_l1, mmu_global_Type g_bit)
642 The function sets section Global attribute
644 \fn __STATIC_INLINE int MMU_SecureSection(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
646 The function sets section Global attribute
648 \fn __STATIC_INLINE int MMU_XNPage(uint32_t *descriptor_l2, mmu_execute_Type xn, mmu_region_size_Type page)
650 The function sets 4k/64k page execution-never attribute
652 \fn __STATIC_INLINE int MMU_DomainPage(uint32_t *descriptor_l1, uint8_t domain)
654 The function sets 4k/64k page domain
656 \fn __STATIC_INLINE int MMU_PPage(uint32_t *descriptor_l1, mmu_ecc_check_Type p_bit)
658 The function sets 4k/64k page parity check
660 \fn __STATIC_INLINE int MMU_APPage(uint32_t *descriptor_l2, mmu_access_Type user, mmu_access_Type priv, uint32_t afe)
662 The function sets 4k/64k page access privileges
663 \fn __STATIC_INLINE int MMU_SharedPage(uint32_t *descriptor_l2, mmu_shared_Type s_bit)
665 The function sets 4k/64k page shareability
667 \fn __STATIC_INLINE int MMU_GlobalPage(uint32_t *descriptor_l2, mmu_global_Type g_bit)
669 The function sets 4k/64k page Global attribute
671 \fn __STATIC_INLINE int MMU_SecurePage(uint32_t *descriptor_l1, mmu_secure_Type s_bit)
673 The function sets 4k/64k page Global attribute
675 \fn __STATIC_INLINE int MMU_MemorySection(uint32_t *descriptor_l1, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner)
677 The function sets section memory attributes
679 \fn __STATIC_INLINE int MMU_MemoryPage(uint32_t *descriptor_l2, mmu_memory_Type mem, mmu_cacheability_Type outer, mmu_cacheability_Type inner, mmu_region_size_Type page)
681 The function sets 4k/64k page memory attributes
683 \fn __STATIC_INLINE int MMU_GetSectionDescriptor(uint32_t *descriptor, mmu_region_attributes_Type reg)
685 The function creates a section descriptor.
687 \fn __STATIC_INLINE int MMU_GetPageDescriptor(uint32_t *descriptor, uint32_t *descriptor2, mmu_region_attributes_Type reg)
689 The function creates a 4k/64k page descriptor.
691 - TEX remap disabled, so memory type and attributes are described directly by bits in the descriptor
692 - Functions always return 0
694 \fn __STATIC_INLINE void MMU_TTSection(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1)
695 \fn __STATIC_INLINE void MMU_TTPage4k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
696 \fn __STATIC_INLINE void MMU_TTPage64k(uint32_t *ttb, uint32_t base_address, uint32_t count, uint32_t descriptor_l1, uint32_t *ttb_l2, uint32_t descriptor_l2 )
697 \fn __STATIC_INLINE void MMU_Enable(void)
699 Set M bit 0 to enable the MMU
700 Set AFE bit to enable simplified access permissions model
701 Clear TRE bit to disable TEX remap and A bit to disable strict alignment fault checking
703 \fn __STATIC_INLINE void MMU_Disable(void)
705 \fn __STATIC_INLINE void MMU_InvalidateTLB(void)
709 /* end of MMU_func_gr */
717 /* end of CMSIS_Core_FunctionInterface - currently disabled */