1 /* 2 * Copyright 2022-2024 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef SPI_IP_CFG_H 8 #define SPI_IP_CFG_H 9 10 /** 11 * @file Spi_Ip_Cfg.h 12 * @version 2.0.0 13 * 14 * @brief AUTOSAR Spi - Spi configuration header file. 15 * @details This file is the header containing all the necessary information for SPI 16 * module configuration(s). 17 * @addtogroup SPI_IP_DRIVER_CONFIGURATION Spi Ip Driver Configuration 18 * @{ 19 */ 20 21 #ifdef __cplusplus 22 extern "C" 23 { 24 #endif 25 26 27 /*================================================================================================== 28 * INCLUDE FILES 29 * 1) system and project includes 30 * 2) needed interfaces from external units 31 * 3) internal and external interfaces from this unit 32 * 4) user callback header files 33 ==================================================================================================*/ 34 #include <zephyr/devicetree.h> 35 #include "Mcal.h" 36 #include "OsIf.h" 37 #include "Spi_Ip_Sa_Init_PBcfg.h" 38 #include "S32Z2_SPI.h" 39 /*================================================================================================== 40 * SOURCE FILE VERSION INFORMATION 41 ==================================================================================================*/ 42 #define SPI_IP_VENDOR_ID_CFG 43 43 #define SPI_IP_AR_RELEASE_MAJOR_VERSION_CFG 4 44 #define SPI_IP_AR_RELEASE_MINOR_VERSION_CFG 7 45 #define SPI_IP_AR_RELEASE_REVISION_VERSION_CFG 0 46 #define SPI_IP_SW_MAJOR_VERSION_CFG 2 47 #define SPI_IP_SW_MINOR_VERSION_CFG 0 48 #define SPI_IP_SW_PATCH_VERSION_CFG 0 49 50 /*================================================================================================== 51 FILE VERSION CHECKS 52 ==================================================================================================*/ 53 #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK 54 /* Check if current file and Mcal header file are of the same Autosar version */ 55 #if ((SPI_IP_AR_RELEASE_MAJOR_VERSION_CFG != MCAL_AR_RELEASE_MAJOR_VERSION) || \ 56 (SPI_IP_AR_RELEASE_MINOR_VERSION_CFG != MCAL_AR_RELEASE_MINOR_VERSION)) 57 #error "AutoSar Version Numbers of Spi_Ip_Cfg.h and Mcal.h are different" 58 #endif 59 60 /* Check if the current file and OsIf.h header file are of the same version */ 61 #if ((SPI_IP_AR_RELEASE_MAJOR_VERSION_CFG != OSIF_AR_RELEASE_MAJOR_VERSION) || \ 62 (SPI_IP_AR_RELEASE_MINOR_VERSION_CFG != OSIF_AR_RELEASE_MINOR_VERSION) \ 63 ) 64 #error "AutoSar Version Numbers of Spi_Ip_Cfg.h and OsIf.h are different" 65 #endif 66 #endif 67 68 /* Check if Spi_Ip_INIT_PBcfg header file and Spi configuration header file are of the same vendor */ 69 #if (SPI_IP_SA_INIT_VENDOR_ID_PBCFG != SPI_IP_VENDOR_ID_CFG) 70 #error "Spi_Ip_Sa_INIT_PBcfg.h and Spi_Ip_Cfg.h have different vendor IDs" 71 #endif 72 /* Check if Spi_Ip_INIT_PBcfg header file and Spi configuration header file are of the same Autosar version */ 73 #if ((SPI_IP_SA_INIT_AR_RELEASE_MAJOR_VERSION_PBCFG != SPI_IP_AR_RELEASE_MAJOR_VERSION_CFG) || \ 74 (SPI_IP_SA_INIT_AR_RELEASE_MINOR_VERSION_PBCFG != SPI_IP_AR_RELEASE_MINOR_VERSION_CFG) || \ 75 (SPI_IP_SA_INIT_AR_RELEASE_REVISION_VERSION_PBCFG != SPI_IP_AR_RELEASE_REVISION_VERSION_CFG)) 76 #error "AutoSar Version Numbers of Spi_Ip_Sa_INIT_PBcfg.h and Spi_Ip_Cfg.h are different" 77 #endif 78 /* Check if Spi_Ip_INIT_PBcfg header file and Spi configuration header file are of the same software version */ 79 #if ((SPI_IP_SA_INIT_SW_MAJOR_VERSION_PBCFG != SPI_IP_SW_MAJOR_VERSION_CFG) || \ 80 (SPI_IP_SA_INIT_SW_MINOR_VERSION_PBCFG != SPI_IP_SW_MINOR_VERSION_CFG) || \ 81 (SPI_IP_SA_INIT_SW_PATCH_VERSION_PBCFG != SPI_IP_SW_PATCH_VERSION_CFG)) 82 #error "Software Version Numbers of Spi_Ip_Sa_INIT_PBcfg.h and Spi_Ip_Cfg.h are different" 83 #endif 84 /*================================================================================================== 85 CONSTANTS 86 ==================================================================================================*/ 87 #define SPI_IP_CONFIG_EXT \ 88 SPI_IP_SA_CONFIG_INIT_PB \ 89 90 /** @brief Total number of SpiPhyUnit configured as SPI. */ 91 #define SPI_IP_NUMBER_OF_INSTANCES (DT_NUM_INST_STATUS_OKAY(nxp_s32_spi)) 92 93 /** @brief Number of FIFO entries supported */ 94 #define SPI_IP_FIFO_SIZE_U16 ((uint16)5U) 95 96 /** @brief Enable Spi Slave Support */ 97 #define SPI_IP_SLAVE_SUPPORT IS_ENABLED(CONFIG_SPI_SLAVE) 98 99 /** 100 * @brief Defines if transfers are made using DMA or FIFO. 101 * @details Defines if transfers are made using DMA or FIFO. 102 */ 103 #define SPI_IP_DMA_USED (STD_OFF) 104 105 /** 106 * @brief If enabled, allows dual MCU clock configuration settings. 107 * @details If enabled, allows dual MCU clock configuration settings. 108 */ 109 #define SPI_IP_DUAL_CLOCK_MODE (STD_OFF) 110 111 /** 112 * @brief Enable Dma Fast transfer support. 113 * @details When SpiEnableDmaFastTransferSupport = TRUE, 114 * the SPI driver can be supported to transmit multiple transfers and CPU used only for processing end of sequence transfer. 115 */ 116 #define SPI_IP_ENABLE_DMAFASTTRANSFER_SUPPORT (STD_OFF) 117 118 /** 119 * @brief Enable User Mode Support. 120 * @details When SpiEnableUserModeSupport = TRUE, 121 * the SPI driver can be executed from both supervisor and user mode. 122 * 123 * @api 124 */ 125 #define SPI_IP_ENABLE_USER_MODE_SUPPORT (STD_OFF) 126 127 #ifndef MCAL_ENABLE_USER_MODE_SUPPORT 128 #ifdef SPI_IP_ENABLE_USER_MODE_SUPPORT 129 #if (STD_ON == SPI_IP_ENABLE_USER_MODE_SUPPORT) 130 #error MCAL_ENABLE_USER_MODE_SUPPORT is not enabled. For running Spi in user mode the MCAL_ENABLE_USER_MODE_SUPPORT needs to be defined 131 #endif /* (STD_ON == SPI_IP_ENABLE_USER_MODE_SUPPORT) */ 132 #endif /* ifdef MCAL_ENABLE_USER_MODE_SUPPORT */ 133 #endif /* ifndef MCAL_ENABLE_USER_MODE_SUPPORT*/ 134 135 /** 136 * @brief SPI registers is controlled by REG_PROT IP. 137 */ 138 #define SPI_IP_REG_PROT_AVAILABLE (STD_OFF) 139 140 #if (STD_ON == SPI_IP_REG_PROT_AVAILABLE) 141 /** 142 * @brief The protection size 143 */ 144 #define SPI_IP_PROT_MEM_U32 ((uint32)4U) 145 #endif 146 /** 147 * @brief Maximum of frame size supported. 148 */ 149 #define SPI_IP_FRAMESIZE_MAX_U8 ((uint8)32U) 150 151 /** 152 * @brief Minimum of frame size supported. 153 */ 154 #define SPI_IP_FRAMESIZE_MIN_U8 ((uint8)4U) 155 156 /** 157 * @brief Define Timeout Method. 158 * @details Define a certain timeout method from OsIf will be used in the driver. 159 */ 160 #define SPI_IP_TIMEOUT_METHOD (OSIF_COUNTER_SYSTEM) 161 162 /** 163 * @brief Switches ON or OFF for the detection and reporting of development errors(API parameter checking) at IP level. 164 */ 165 /** @implements SPI_IP_DEV_ERROR_DETECT_define */ 166 #define SPI_IP_DEV_ERROR_DETECT (STD_OFF) 167 /*================================================================================================== 168 * DEFINES AND MACROS 169 ==================================================================================================*/ 170 171 /*================================================================================================== 172 * ENUMS 173 ==================================================================================================*/ 174 175 176 /*================================================================================================== 177 * STRUCTURES AND OTHER TYPEDEFS 178 ==================================================================================================*/ 179 180 181 /*================================================================================================== 182 * GLOBAL VARIABLE DECLARATIONS 183 ==================================================================================================*/ 184 185 186 /*================================================================================================== 187 * FUNCTION PROTOTYPES 188 ==================================================================================================*/ 189 190 191 #ifdef __cplusplus 192 } 193 #endif 194 #endif 195 196 /** @} */ 197