1 /* 2 * Copyright 1997-2016 Freescale Semiconductor, Inc. 3 * Copyright 2016-2022 NXP 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /*! 9 * @file S32K146_M4.h 10 * @version 1.1 11 * @date 2022-01-31 12 * @brief Peripheral Access Layer for S32K146_M4 13 * 14 * This file contains register definitions and macros for easy access to their 15 * bit fields. 16 * 17 * This file assumes LITTLE endian system. 18 */ 19 20 /** 21 * @page misra_violations MISRA-C:2012 violations 22 * 23 * @section [global] 24 * Violates MISRA 2012 Advisory Rule 2.3, local typedef not referenced 25 * The SoC header defines typedef for all modules. 26 * 27 * @section [global] 28 * Violates MISRA 2012 Advisory Rule 2.5, local macro not referenced 29 * The SoC header defines macros for all modules and registers. 30 * 31 * @section [global] 32 * Violates MISRA 2012 Advisory Directive 4.9, Function-like macro 33 * These are generated macros used for accessing the bit-fields from registers. 34 * 35 * @section [global] 36 * Violates MISRA 2012 Required Rule 5.1, identifier clash 37 * The supported compilers use more than 31 significant characters for identifiers. 38 * 39 * @section [global] 40 * Violates MISRA 2012 Required Rule 5.2, identifier clash 41 * The supported compilers use more than 31 significant characters for identifiers. 42 * 43 * @section [global] 44 * Violates MISRA 2012 Required Rule 5.4, identifier clash 45 * The supported compilers use more than 31 significant characters for identifiers. 46 * 47 * @section [global] 48 * Violates MISRA 2012 Required Rule 5.5, identifier clash 49 * The supported compilers use more than 31 significant characters for identifiers. 50 * 51 * @section [global] 52 * Violates MISRA 2012 Required Rule 21.1, defined macro '__I' is reserved to the compiler 53 * This type qualifier is needed to ensure correct I/O access and addressing. 54 */ 55 56 57 /* ---------------------------------------------------------------------------- 58 -- MCU activation 59 ---------------------------------------------------------------------------- */ 60 61 /* Prevention from multiple including the same memory map */ 62 #if !defined(S32K146_COMMON_H_) /* Check if memory map has not been already included */ 63 #define S32K146_COMMON_H_ 64 #define MCU_S32K146 65 66 /* Check if another memory map has not been also included */ 67 #if (defined(MCU_ACTIVE)) 68 #error S32K146_M4 memory map: There is already included another memory map. Only one memory map can be included. 69 #endif /* (defined(MCU_ACTIVE)) */ 70 #define MCU_ACTIVE 71 72 #include "BasicTypes.h" 73 74 /** Memory map major version (memory maps with equal major version number are 75 * compatible) */ 76 #define MCU_MEM_MAP_VERSION 0x0100U 77 /** Memory map minor version */ 78 #define MCU_MEM_MAP_VERSION_MINOR 0x0001U 79 80 /* ---------------------------------------------------------------------------- 81 -- Generic macros 82 ---------------------------------------------------------------------------- */ 83 84 /* IO definitions (access restrictions to peripheral registers) */ 85 /** 86 * IO Type Qualifiers are used 87 * \li to specify the access to peripheral variables. 88 * \li for automatic generation of peripheral register debug information. 89 */ 90 #ifndef __IO 91 #ifdef __cplusplus 92 #define __I volatile /*!< Defines 'read only' permissions */ 93 #else 94 #define __I volatile const /*!< Defines 'read only' permissions */ 95 #endif 96 #define __O volatile /*!< Defines 'write only' permissions */ 97 #define __IO volatile /*!< Defines 'read / write' permissions */ 98 #endif 99 100 101 /** 102 * @brief 32 bits memory read macro. 103 */ 104 #if !defined(REG_READ32) 105 #define REG_READ32(address) (*(volatile uint32_t*)(address)) 106 #endif 107 108 /** 109 * @brief 32 bits memory write macro. 110 */ 111 #if !defined(REG_WRITE32) 112 #define REG_WRITE32(address, value) ((*(volatile uint32_t*)(address))= (uint32_t)(value)) 113 #endif 114 115 /** 116 * @brief 32 bits bits setting macro. 117 */ 118 #if !defined(REG_BIT_SET32) 119 #define REG_BIT_SET32(address, mask) ((*(volatile uint32_t*)(address))|= (uint32_t)(mask)) 120 #endif 121 122 /** 123 * @brief 32 bits bits clearing macro. 124 */ 125 #if !defined(REG_BIT_CLEAR32) 126 #define REG_BIT_CLEAR32(address, mask) ((*(volatile uint32_t*)(address))&= ((uint32_t)~((uint32_t)(mask)))) 127 #endif 128 129 /** 130 * @brief 32 bit clear bits and set with new value 131 * @note It is user's responsability to make sure that value has only "mask" bits set - (value&~mask)==0 132 */ 133 #if !defined(REG_RMW32) 134 #define REG_RMW32(address, mask, value) (REG_WRITE32((address), ((REG_READ32(address)& ((uint32_t)~((uint32_t)(mask))))| ((uint32_t)(value))))) 135 #endif 136 137 138 /* ---------------------------------------------------------------------------- 139 -- Interrupt vector numbers 140 ---------------------------------------------------------------------------- */ 141 142 /*! 143 * @addtogroup Interrupt_vector_numbers Interrupt vector numbers 144 * @{ 145 */ 146 147 /** Interrupt Number Definitions */ 148 #define NUMBER_OF_INT_VECTORS 151 /**< Number of interrupts in the Vector table */ 149 150 typedef enum { 151 /* Auxiliary constants */ 152 NotAvail_IRQn = -128, /**< Not available device specific interrupt */ 153 154 /* Core interrupts */ 155 NonMaskableInt_IRQn = -14, /**< Non Maskable Interrupt */ 156 HardFault_IRQn = -13, /**< Cortex-M4 SV Hard Fault Interrupt */ 157 MemoryManagement_IRQn = -12, /**< Cortex-M4 Memory Management Interrupt */ 158 BusFault_IRQn = -11, /**< Cortex-M4 Bus Fault Interrupt */ 159 UsageFault_IRQn = -10, /**< Cortex-M4 Usage Fault Interrupt */ 160 SVCall_IRQn = -5, /**< Cortex-M4 SV Call Interrupt */ 161 DebugMonitor_IRQn = -4, /**< Cortex-M4 Debug Monitor Interrupt */ 162 PendSV_IRQn = -2, /**< Cortex-M4 Pend SV Interrupt */ 163 SysTick_IRQn = -1, /**< Cortex-M4 System Tick Interrupt */ 164 165 /* Device specific interrupts */ 166 DMA0_IRQn = 0, /**< DMA channel 0 transfer complete */ 167 DMA1_IRQn = 1, /**< DMA channel 1 transfer complete */ 168 DMA2_IRQn = 2, /**< DMA channel 2 transfer complete */ 169 DMA3_IRQn = 3, /**< DMA channel 3 transfer complete */ 170 DMA4_IRQn = 4, /**< DMA channel 4 transfer complete */ 171 DMA5_IRQn = 5, /**< DMA channel 5 transfer complete */ 172 DMA6_IRQn = 6, /**< DMA channel 6 transfer complete */ 173 DMA7_IRQn = 7, /**< DMA channel 7 transfer complete */ 174 DMA8_IRQn = 8, /**< DMA channel 8 transfer complete */ 175 DMA9_IRQn = 9, /**< DMA channel 9 transfer complete */ 176 DMA10_IRQn = 10, /**< DMA channel 10 transfer complete */ 177 DMA11_IRQn = 11, /**< DMA channel 11 transfer complete */ 178 DMA12_IRQn = 12, /**< DMA channel 12 transfer complete */ 179 DMA13_IRQn = 13, /**< DMA channel 13 transfer complete */ 180 DMA14_IRQn = 14, /**< DMA channel 14 transfer complete */ 181 DMA15_IRQn = 15, /**< DMA channel 15 transfer complete */ 182 DMA_Error_IRQn = 16, /**< DMA error interrupt channels 0-15 */ 183 MCM_IRQn = 17, /**< FPU sources */ 184 FTFC_CMD_IRQn = 18, /**< FTFC Command complete */ 185 FTFC_Read_Collision_IRQn = 19, /**< FTFC Read collision */ 186 LVD_LVW_IRQn = 20, /**< PMC Low voltage detect interrupt */ 187 FTFC_Fault_IRQn = 21, /**< FTFC Double bit fault detect */ 188 WDOG_EWM_IRQn = 22, /**< Interrupt request out before WDOG reset out, EWM output as interrupt */ 189 RCM_IRQn = 23, /**< RCM Asynchronous Interrupt */ 190 LPI2C0_Master_IRQn = 24, /**< LPI2C0 Master Interrupt */ 191 LPI2C0_Slave_IRQn = 25, /**< LPI2C0 Slave Interrupt */ 192 LPSPI0_IRQn = 26, /**< LPSPI0 Interrupt */ 193 LPSPI1_IRQn = 27, /**< LPSPI1 Interrupt */ 194 LPSPI2_IRQn = 28, /**< LPSPI2 Interrupt */ 195 LPUART0_RxTx_IRQn = 31, /**< LPUART0 Transmit / Receive Interrupt / Error / Overrun */ 196 LPUART1_RxTx_IRQn = 33, /**< LPUART1 Transmit / Receive Interrupt / Error / Overrun */ 197 LPUART2_RxTx_IRQn = 35, /**< LPUART2 Transmit / Receive Interrupt / Error / Overrun */ 198 ADC0_IRQn = 39, /**< ADC0 interrupt request */ 199 ADC1_IRQn = 40, /**< ADC1 interrupt request */ 200 CMP0_IRQn = 41, /**< CMP0 interrupt request */ 201 ERM_single_fault_IRQn = 44, /**< ERM single bit error correction */ 202 ERM_double_fault_IRQn = 45, /**< ERM double bit error non-correctable */ 203 RTC_IRQn = 46, /**< RTC alarm interrupt */ 204 RTC_Seconds_IRQn = 47, /**< RTC seconds interrupt */ 205 LPIT0_Ch0_IRQn = 48, /**< LPIT0 channel 0 overflow interrupt */ 206 LPIT0_Ch1_IRQn = 49, /**< LPIT0 channel 1 overflow interrupt */ 207 LPIT0_Ch2_IRQn = 50, /**< LPIT0 channel 2 overflow interrupt */ 208 LPIT0_Ch3_IRQn = 51, /**< LPIT0 channel 3 overflow interrupt */ 209 PDB0_IRQn = 52, /**< PDB0 interrupt */ 210 SCG_IRQn = 57, /**< SCG bus interrupt request */ 211 LPTMR0_IRQn = 58, /**< LPTIMER interrupt request */ 212 PORTA_IRQn = 59, /**< Port A pin detect interrupt */ 213 PORTB_IRQn = 60, /**< Port B pin detect interrupt */ 214 PORTC_IRQn = 61, /**< Port C pin detect interrupt */ 215 PORTD_IRQn = 62, /**< Port D pin detect interrupt */ 216 PORTE_IRQn = 63, /**< Port E pin detect interrupt */ 217 SWI_IRQn = 64, /**< Software interrupt */ 218 PDB1_IRQn = 68, /**< PDB1 interrupt */ 219 FLEXIO_IRQn = 69, /**< Software interrupt */ 220 CAN0_ORed_IRQn = 78, /**< CAN0 OR'ed Bus in Off State. */ 221 CAN0_Error_IRQn = 79, /**< CAN0 Interrupt indicating that errors were detected on the CAN bus */ 222 CAN0_Wake_Up_IRQn = 80, /**< CAN0 Interrupt asserted when Pretended Networking operation is enabled, and a valid message matches the selected filter criteria during Low Power mode */ 223 CAN0_ORed_0_15_MB_IRQn = 81, /**< CAN0 OR'ed Message buffer (0-15) */ 224 CAN0_ORed_16_31_MB_IRQn = 82, /**< CAN0 OR'ed Message buffer (16-31) */ 225 CAN1_ORed_IRQn = 85, /**< CAN1 OR'ed Bus in Off State */ 226 CAN1_Error_IRQn = 86, /**< CAN1 Interrupt indicating that errors were detected on the CAN bus */ 227 CAN1_ORed_0_15_MB_IRQn = 88, /**< CAN1 OR'ed Message buffer (0-15) */ 228 CAN1_ORed_16_31_MB_IRQn = 89, /**< CAN1 OR'ed Message buffer (16-31) */ 229 CAN2_ORed_IRQn = 92, /**< CAN2 OR'ed Bus in Off State */ 230 CAN2_Error_IRQn = 93, /**< CAN2 Interrupt indicating that errors were detected on the CAN bus */ 231 CAN2_ORed_0_15_MB_IRQn = 95, /**< CAN2 OR'ed Message buffer (0-15) */ 232 FTM0_Ch0_Ch1_IRQn = 99, /**< FTM0 Channel 0 and 1 interrupt */ 233 FTM0_Ch2_Ch3_IRQn = 100, /**< FTM0 Channel 2 and 3 interrupt */ 234 FTM0_Ch4_Ch5_IRQn = 101, /**< FTM0 Channel 4 and 5 interrupt */ 235 FTM0_Ch6_Ch7_IRQn = 102, /**< FTM0 Channel 6 and 7 interrupt */ 236 FTM0_Fault_IRQn = 103, /**< FTM0 Fault interrupt */ 237 FTM0_Ovf_Reload_IRQn = 104, /**< FTM0 Counter overflow and Reload interrupt */ 238 FTM1_Ch0_Ch1_IRQn = 105, /**< FTM1 Channel 0 and 1 interrupt */ 239 FTM1_Ch2_Ch3_IRQn = 106, /**< FTM1 Channel 2 and 3 interrupt */ 240 FTM1_Ch4_Ch5_IRQn = 107, /**< FTM1 Channel 4 and 5 interrupt */ 241 FTM1_Ch6_Ch7_IRQn = 108, /**< FTM1 Channel 6 and 7 interrupt */ 242 FTM1_Fault_IRQn = 109, /**< FTM1 Fault interrupt */ 243 FTM1_Ovf_Reload_IRQn = 110, /**< FTM1 Counter overflow and Reload interrupt */ 244 FTM2_Ch0_Ch1_IRQn = 111, /**< FTM2 Channel 0 and 1 interrupt */ 245 FTM2_Ch2_Ch3_IRQn = 112, /**< FTM2 Channel 2 and 3 interrupt */ 246 FTM2_Ch4_Ch5_IRQn = 113, /**< FTM2 Channel 4 and 5 interrupt */ 247 FTM2_Ch6_Ch7_IRQn = 114, /**< FTM2 Channel 6 and 7 interrupt */ 248 FTM2_Fault_IRQn = 115, /**< FTM2 Fault interrupt */ 249 FTM2_Ovf_Reload_IRQn = 116, /**< FTM2 Counter overflow and Reload interrupt */ 250 FTM3_Ch0_Ch1_IRQn = 117, /**< FTM3 Channel 0 and 1 interrupt */ 251 FTM3_Ch2_Ch3_IRQn = 118, /**< FTM3 Channel 2 and 3 interrupt */ 252 FTM3_Ch4_Ch5_IRQn = 119, /**< FTM3 Channel 4 and 5 interrupt */ 253 FTM3_Ch6_Ch7_IRQn = 120, /**< FTM3 Channel 6 and 7 interrupt */ 254 FTM3_Fault_IRQn = 121, /**< FTM3 Fault interrupt */ 255 FTM3_Ovf_Reload_IRQn = 122, /**< FTM3 Counter overflow and Reload interrupt */ 256 FTM4_Ch0_Ch1_IRQn = 123, /**< FTM4 Channel 0 and 1 interrupt */ 257 FTM4_Ch2_Ch3_IRQn = 124, /**< FTM4 Channel 2 and 3 interrupt */ 258 FTM4_Ch4_Ch5_IRQn = 125, /**< FTM4 Channel 4 and 5 interrupt */ 259 FTM4_Ch6_Ch7_IRQn = 126, /**< FTM4 Channel 6 and 7 interrupt */ 260 FTM4_Fault_IRQn = 127, /**< FTM4 Fault interrupt */ 261 FTM4_Ovf_Reload_IRQn = 128, /**< FTM4 Counter overflow and Reload interrupt */ 262 FTM5_Ch0_Ch1_IRQn = 129, /**< FTM5 Channel 0 and 1 interrupt */ 263 FTM5_Ch2_Ch3_IRQn = 130, /**< FTM5 Channel 2 and 3 interrupt */ 264 FTM5_Ch4_Ch5_IRQn = 131, /**< FTM5 Channel 4 and 5 interrupt */ 265 FTM5_Ch6_Ch7_IRQn = 132, /**< FTM5 Channel 6 and 7 interrupt */ 266 FTM5_Fault_IRQn = 133, /**< FTM5 Fault interrupt */ 267 FTM5_Ovf_Reload_IRQn = 134 /**< FTM5 Counter overflow and Reload interrupt */ 268 } IRQn_Type; 269 270 /*! 271 * @} 272 */ /* end of group Interrupt_vector_numbers */ 273 274 275 /* ---------------------------------------------------------------------------- 276 -- Cortex M4 Core Configuration 277 ---------------------------------------------------------------------------- */ 278 279 /*! 280 * @addtogroup Cortex_Core_Configuration Cortex M4 Core Configuration 281 * @{ 282 */ 283 284 #define __MPU_PRESENT 0 /**< Defines if an MPU is present or not */ 285 #define __NVIC_PRIO_BITS 4 /**< Number of priority bits implemented in the NVIC */ 286 #define __Vendor_SysTickConfig 0 /**< Vendor specific implementation of SysTickConfig is defined */ 287 #define __FPU_PRESENT 1 /**< Defines if an FPU is present or not */ 288 289 290 /*! 291 * @} 292 */ /* end of group Cortex_Core_Configuration */ 293 294 295 /* ---------------------------------------------------------------------------- 296 -- SDK Compatibility 297 ---------------------------------------------------------------------------- */ 298 299 /*! 300 * @addtogroup SDK_Compatibility_Symbols SDK Compatibility 301 * @{ 302 */ 303 304 /* No SDK compatibility issues. */ 305 306 /*! 307 * @} 308 */ /* end of group SDK_Compatibility_Symbols */ 309 310 311 #endif /* #if !defined(S32K146_COMMON_H_) */ 312 313