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