/* ** ################################################################### ** Processor: S32K118 ** Reference manual: S32K1XXRM Rev. 9, 09/2018 ** Version: rev. 1.3, 2019-02-19 ** Build: b190219 ** ** Abstract: ** Peripheral Access Layer for S32K118 ** ** Copyright (c) 1997 - 2016 Freescale Semiconductor, Inc. ** Copyright 2016-2019 NXP ** All rights reserved. ** ** THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, ** INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ** STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ** IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF ** THE POSSIBILITY OF SUCH DAMAGE. ** ** http: www.nxp.com ** mail: support@nxp.com ** ** Revisions: ** - rev. 1.0 (2017-12-14) - Mihai Volmer ** Initial version based on S32K1XXRM Rev. 6, 12/2017. ** - rev. 1.1 (2018-02-08) - Mihai Volmer ** Renamed the NVIC register array IP to IPR to reflect the register access difference from Cortex-M4 NVIC registers ** Fixed CSE_PRAM base address ** - rev. 1.2 (2018-07-19) - Dan Nastasa ** Updated the header based on S32K1XXRM Rev. 8, 06/2018. ** Added MTB_DWT peripheral to the header file ** - rev. 1.3 (2019-02-19) - Ionut Pavel ** Updated the header based on S32K1XXRM Rev. 9, 09/2018. ** Removed LMEM_LMDR2 register from the header file. ** Modified LMEM_LMPECR register to Read-Only. ** ** ################################################################### */ /*! * @file S32K118.h * @version 1.3 * @date 2019-02-19 * @brief Peripheral Access Layer for S32K118 * * This file contains register definitions and macros for easy access to their * bit fields. * * This file assumes LITTLE endian system. */ /** * @page misra_violations MISRA-C:2012 violations * * @section [global] * Violates MISRA 2012 Advisory Rule 2.3, local typedef not referenced * The SoC header defines typedef for all modules. * * @section [global] * Violates MISRA 2012 Advisory Rule 2.5, local macro not referenced * The SoC header defines macros for all modules and registers. * * @section [global] * Violates MISRA 2012 Advisory Directive 4.9, Function-like macro * These are generated macros used for accessing the bit-fields from registers. * * @section [global] * Violates MISRA 2012 Required Rule 5.1, identifier clash * The supported compilers use more than 31 significant characters for identifiers. * * @section [global] * Violates MISRA 2012 Required Rule 5.2, identifier clash * The supported compilers use more than 31 significant characters for identifiers. * * @section [global] * Violates MISRA 2012 Required Rule 5.4, identifier clash * The supported compilers use more than 31 significant characters for identifiers. * * @section [global] * Violates MISRA 2012 Required Rule 5.5, identifier clash * The supported compilers use more than 31 significant characters for identifiers. * * @section [global] * Violates MISRA 2012 Required Rule 21.1, defined macro '__I' is reserved to the compiler * This type qualifier is needed to ensure correct I/O access and addressing. */ /* ---------------------------------------------------------------------------- -- MCU activation ---------------------------------------------------------------------------- */ /* Prevention from multiple including the same memory map */ #if !defined(S32K118_H_) /* Check if memory map has not been already included */ #define S32K118_H_ #define MCU_S32K118 /* Check if another memory map has not been also included */ #if (defined(MCU_ACTIVE)) #error S32K118 memory map: There is already included another memory map. Only one memory map can be included. #endif /* (defined(MCU_ACTIVE)) */ #define MCU_ACTIVE #include /** Memory map major version (memory maps with equal major version number are * compatible) */ #define MCU_MEM_MAP_VERSION 0x0100u /** Memory map minor version */ #define MCU_MEM_MAP_VERSION_MINOR 0x0003u /* ---------------------------------------------------------------------------- -- Generic macros ---------------------------------------------------------------------------- */ /* IO definitions (access restrictions to peripheral registers) */ /** * IO Type Qualifiers are used * \li to specify the access to peripheral variables. * \li for automatic generation of peripheral register debug information. */ #ifndef __IO #ifdef __cplusplus #define __I volatile /*!< Defines 'read only' permissions */ #else #define __I volatile const /*!< Defines 'read only' permissions */ #endif #define __O volatile /*!< Defines 'write only' permissions */ #define __IO volatile /*!< Defines 'read / write' permissions */ #endif /** * @brief 32 bits memory read macro. */ #if !defined(REG_READ32) #define REG_READ32(address) (*(volatile uint32_t*)(address)) #endif /** * @brief 32 bits memory write macro. */ #if !defined(REG_WRITE32) #define REG_WRITE32(address, value) ((*(volatile uint32_t*)(address))= (uint32_t)(value)) #endif /** * @brief 32 bits bits setting macro. */ #if !defined(REG_BIT_SET32) #define REG_BIT_SET32(address, mask) ((*(volatile uint32_t*)(address))|= (uint32_t)(mask)) #endif /** * @brief 32 bits bits clearing macro. */ #if !defined(REG_BIT_CLEAR32) #define REG_BIT_CLEAR32(address, mask) ((*(volatile uint32_t*)(address))&= ((uint32_t)~((uint32_t)(mask)))) #endif /** * @brief 32 bit clear bits and set with new value * @note It is user's responsability to make sure that value has only "mask" bits set - (value&~mask)==0 */ #if !defined(REG_RMW32) #define REG_RMW32(address, mask, value) (REG_WRITE32((address), ((REG_READ32(address)& ((uint32_t)~((uint32_t)(mask))))| ((uint32_t)(value))))) #endif /* ---------------------------------------------------------------------------- -- Interrupt vector numbers for S32K118 ---------------------------------------------------------------------------- */ /*! * @addtogroup Interrupt_vector_numbers_S32K118 Interrupt vector numbers for S32K118 * @{ */ /** Interrupt Number Definitions */ #define NUMBER_OF_INT_VECTORS 48u /**< Number of interrupts in the Vector table */ /** * @brief Defines the Interrupt Numbers definitions * * This enumeration is used to configure the interrupts. * * Implements : IRQn_Type_Class */ typedef enum { /* Auxiliary constants */ NotAvail_IRQn = -128, /**< Not available device specific interrupt */ /* Core interrupts */ NonMaskableInt_IRQn = -14, /**< Non Maskable Interrupt */ HardFault_IRQn = -13, /**< Cortex-M0 SV Hard Fault Interrupt */ SVCall_IRQn = -5, /**< Cortex-M0 SV Call Interrupt */ PendSV_IRQn = -2, /**< Cortex-M0 Pend SV Interrupt */ SysTick_IRQn = -1, /**< Cortex-M0 System Tick Interrupt */ /* Device specific interrupts */ DMA0_IRQn = 0u, /**< DMA channel 0 transfer complete */ DMA1_IRQn = 1u, /**< DMA channel 1 transfer complete */ DMA2_IRQn = 2u, /**< DMA channel 2 transfer complete */ DMA3_IRQn = 3u, /**< DMA channel 3 transfer complete */ DMA_Error_IRQn = 4u, /**< DMA error interrupt channels 0-3 */ ERM_fault_IRQn = 5u, /**< ERM single and double bit error correction */ RTC_IRQn = 6u, /**< RTC alarm interrupt */ RTC_Seconds_IRQn = 7u, /**< RTC seconds interrupt */ LPTMR0_IRQn = 8u, /**< LPTIMER interrupt request */ PORT_IRQn = 9u, /**< Port A, B, C, D and E pin detect interrupt */ CAN0_ORed_Err_Wakeup_IRQn = 10u, /**< OR’ed [Bus Off OR Bus Off Done OR Transmit Warning OR Receive Warning], Interrupt indicating that errors were detected on the CAN bus, Interrupt asserted when Pretended Networking operation is enabled, and a valid message matches the selected filter criteria during Low Power mode */ CAN0_ORed_0_31_MB_IRQn = 11u, /**< OR'ed Message buffer (0-15, 16-31) */ FTM0_Ch0_7_IRQn = 12u, /**< FTM0 Channel 0 to 7 interrupt */ FTM0_Fault_IRQn = 13u, /**< FTM0 Fault interrupt */ FTM0_Ovf_Reload_IRQn = 14u, /**< FTM0 Counter overflow and Reload interrupt */ FTM1_Ch0_7_IRQn = 15u, /**< FTM1 Channel 0 to 7 interrupt */ FTM1_Fault_IRQn = 16u, /**< FTM1 Fault interrupt */ FTM1_Ovf_Reload_IRQn = 17u, /**< FTM1 Counter overflow and Reload interrupt */ FTFC_IRQn = 18u, /**< FTFC Command complete, Read collision and Double bit fault detect */ PDB0_IRQn = 19u, /**< PDB0 interrupt */ LPIT0_IRQn = 20u, /**< LPIT interrupt */ SCG_CMU_LVD_LVWSCG_IRQn = 21u, /**< PMC Low voltage detect interrupt, SCG bus interrupt request and CMU loss of range interrupt */ WDOG_IRQn = 22u, /**< WDOG interrupt request out before wdg reset out */ RCM_IRQn = 23u, /**< RCM Asynchronous Interrupt */ LPI2C0_Master_Slave_IRQn = 24u, /**< LPI2C0 Master Interrupt and Slave Interrupt */ FLEXIO_IRQn = 25u, /**< FlexIO Interrupt */ LPSPI0_IRQn = 26u, /**< LPSPI0 Interrupt */ LPSPI1_IRQn = 27u, /**< LPSPI1 Interrupt */ ADC0_IRQn = 28u, /**< ADC0 interrupt request. */ CMP0_IRQn = 29u, /**< CMP0 interrupt request */ LPUART1_RxTx_IRQn = 30u, /**< LPUART1 Transmit / Receive Interrupt */ LPUART0_RxTx_IRQn = 31u /**< LPUART0 Transmit / Receive Interrupt */ } IRQn_Type; /*! * @} */ /* end of group Interrupt_vector_numbers_S32K118 */ /* ---------------------------------------------------------------------------- -- Device Peripheral Access Layer for S32K118 ---------------------------------------------------------------------------- */ /*! * @addtogroup Peripheral_access_layer_S32K118 Device Peripheral Access Layer for S32K118 * @{ */ /* @brief This module covers memory mapped registers available on SoC */ /* ---------------------------------------------------------------------------- -- ADC Peripheral Access Layer ---------------------------------------------------------------------------- */ /*! * @addtogroup ADC_Peripheral_Access_Layer ADC Peripheral Access Layer * @{ */ /** ADC - Size of Registers Arrays */ #define ADC_SC1_COUNT 16u #define ADC_R_COUNT 16u #define ADC_CV_COUNT 2u /** ADC - Register Layout Typedef */ typedef struct { __IO uint32_t SC1[ADC_SC1_COUNT]; /**< ADC Status and Control Register 1, array offset: 0x0, array step: 0x4 */ __IO uint32_t CFG1; /**< ADC Configuration Register 1, offset: 0x40 */ __IO uint32_t CFG2; /**< ADC Configuration Register 2, offset: 0x44 */ __I uint32_t R[ADC_R_COUNT]; /**< ADC Data Result Registers, array offset: 0x48, array step: 0x4 */ __IO uint32_t CV[ADC_CV_COUNT]; /**< Compare Value Registers, array offset: 0x88, array step: 0x4 */ __IO uint32_t SC2; /**< Status and Control Register 2, offset: 0x90 */ __IO uint32_t SC3; /**< Status and Control Register 3, offset: 0x94 */ __IO uint32_t BASE_OFS; /**< BASE Offset Register, offset: 0x98 */ __IO uint32_t OFS; /**< ADC Offset Correction Register, offset: 0x9C */ __IO uint32_t USR_OFS; /**< USER Offset Correction Register, offset: 0xA0 */ __IO uint32_t XOFS; /**< ADC X Offset Correction Register, offset: 0xA4 */ __IO uint32_t YOFS; /**< ADC Y Offset Correction Register, offset: 0xA8 */ __IO uint32_t G; /**< ADC Gain Register, offset: 0xAC */ __IO uint32_t UG; /**< ADC User Gain Register, offset: 0xB0 */ __IO uint32_t CLPS; /**< ADC General Calibration Value Register S, offset: 0xB4 */ __IO uint32_t CLP3; /**< ADC Plus-Side General Calibration Value Register 3, offset: 0xB8 */ __IO uint32_t CLP2; /**< ADC Plus-Side General Calibration Value Register 2, offset: 0xBC */ __IO uint32_t CLP1; /**< ADC Plus-Side General Calibration Value Register 1, offset: 0xC0 */ __IO uint32_t CLP0; /**< ADC Plus-Side General Calibration Value Register 0, offset: 0xC4 */ __IO uint32_t CLPX; /**< ADC Plus-Side General Calibration Value Register X, offset: 0xC8 */ __IO uint32_t CLP9; /**< ADC Plus-Side General Calibration Value Register 9, offset: 0xCC */ __IO uint32_t CLPS_OFS; /**< ADC General Calibration Offset Value Register S, offset: 0xD0 */ __IO uint32_t CLP3_OFS; /**< ADC Plus-Side General Calibration Offset Value Register 3, offset: 0xD4 */ __IO uint32_t CLP2_OFS; /**< ADC Plus-Side General Calibration Offset Value Register 2, offset: 0xD8 */ __IO uint32_t CLP1_OFS; /**< ADC Plus-Side General Calibration Offset Value Register 1, offset: 0xDC */ __IO uint32_t CLP0_OFS; /**< ADC Plus-Side General Calibration Offset Value Register 0, offset: 0xE0 */ __IO uint32_t CLPX_OFS; /**< ADC Plus-Side General Calibration Offset Value Register X, offset: 0xE4 */ __IO uint32_t CLP9_OFS; /**< ADC Plus-Side General Calibration Offset Value Register 9, offset: 0xE8 */ } ADC_Type, *ADC_MemMapPtr; /** Number of instances of the ADC module. */ #define ADC_INSTANCE_COUNT (1u) /* ADC - Peripheral instance base addresses */ /** Peripheral ADC0 base address */ #define ADC0_BASE (0x4003B000u) /** Peripheral ADC0 base pointer */ #define ADC0 ((ADC_Type *)ADC0_BASE) /** Array initializer of ADC peripheral base addresses */ #define ADC_BASE_ADDRS { ADC0_BASE } /** Array initializer of ADC peripheral base pointers */ #define ADC_BASE_PTRS { ADC0 } /** Number of interrupt vector arrays for the ADC module. */ #define ADC_IRQS_ARR_COUNT (1u) /** Number of interrupt channels for the ADC module. */ #define ADC_IRQS_CH_COUNT (1u) /** Interrupt vectors for the ADC peripheral type */ #define ADC_IRQS { ADC0_IRQn } /* ---------------------------------------------------------------------------- -- ADC Register Masks ---------------------------------------------------------------------------- */ /*! * @addtogroup ADC_Register_Masks ADC Register Masks * @{ */ /* SC1 Bit Fields */ #define ADC_SC1_ADCH_MASK 0x1Fu #define ADC_SC1_ADCH_SHIFT 0u #define ADC_SC1_ADCH_WIDTH 5u #define ADC_SC1_ADCH(x) (((uint32_t)(((uint32_t)(x))<