Spi_Cfg.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /**
  2. * @file Spi_Cfg.h
  3. * @version 1.0.0
  4. *
  5. * @brief AUTOSAR Spi - Spi configuration header file.
  6. * @details This file is the header containing all the necessary information for SPI
  7. * module configuration(s).
  8. * @addtogroup SPI_DRIVER_CONFIGURATION Spi Driver Configuration
  9. * @{
  10. */
  11. /*==================================================================================================
  12. * Project : RTD AUTOSAR 4.4
  13. * Platform : CORTEXM
  14. * Peripheral : LPSPI
  15. * Dependencies :
  16. *
  17. * Autosar Version : 4.4.0
  18. * Autosar Revision : ASR_REL_4_4_REV_0000
  19. * Autosar Conf.Variant :
  20. * SW Version : 1.0.0
  21. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  22. *
  23. * (c) Copyright 2020-2021 NXP Semiconductors
  24. * All Rights Reserved.
  25. *
  26. * NXP Confidential. This software is owned or controlled by NXP and may only be
  27. * used strictly in accordance with the applicable license terms. By expressly
  28. * accepting such terms or by downloading, installing, activating and/or otherwise
  29. * using the software, you are agreeing that you have read, and that you agree to
  30. * comply with and are bound by, such license terms. If you do not agree to be
  31. * bound by the applicable license terms, then you may not retain, install,
  32. * activate or otherwise use the software.
  33. ==================================================================================================*/
  34. #ifndef SPI_CFG_H
  35. #define SPI_CFG_H
  36. #ifdef __cplusplus
  37. extern "C"{
  38. #endif
  39. /*==================================================================================================
  40. * INCLUDE FILES
  41. * 1) system and project includes
  42. * 2) needed interfaces from external units
  43. * 3) internal and external interfaces from this unit
  44. * 4) user callback header files
  45. ==================================================================================================*/
  46. #include "Mcal.h"
  47. #include "OsIf.h"
  48. #include "Spi_VS_0_PBcfg.h"
  49. #include "Spi_Ipw_Cfg.h"
  50. /*==================================================================================================
  51. * SOURCE FILE VERSION INFORMATION
  52. ==================================================================================================*/
  53. #define SPI_VENDOR_ID_CFG 43
  54. #define SPI_AR_RELEASE_MAJOR_VERSION_CFG 4
  55. #define SPI_AR_RELEASE_MINOR_VERSION_CFG 4
  56. #define SPI_AR_RELEASE_REVISION_VERSION_CFG 0
  57. #define SPI_SW_MAJOR_VERSION_CFG 1
  58. #define SPI_SW_MINOR_VERSION_CFG 0
  59. #define SPI_SW_PATCH_VERSION_CFG 0
  60. /*==================================================================================================
  61. * FILE VERSION CHECKS
  62. ==================================================================================================*/
  63. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  64. /* Check if current file and Mcal header file are of the same Autosar version */
  65. #if ((SPI_AR_RELEASE_MAJOR_VERSION_CFG != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  66. (SPI_AR_RELEASE_MINOR_VERSION_CFG != MCAL_AR_RELEASE_MINOR_VERSION))
  67. #error "AutoSar Version Numbers of Spi_Cfg.h and Mcal.h are different"
  68. #endif
  69. /* Check if the current file and OsIf.h header file are of the same version */
  70. #if ((SPI_AR_RELEASE_MAJOR_VERSION_CFG != OSIF_AR_RELEASE_MAJOR_VERSION) || \
  71. (SPI_AR_RELEASE_MINOR_VERSION_CFG != OSIF_AR_RELEASE_MINOR_VERSION))
  72. #error "AutoSar Version Numbers of Spi_Cfg.h and OsIf.h are different"
  73. #endif
  74. #endif
  75. /* Check if Spi_VS_0_PBcfg header file and Spi configuration header file are of the same vendor */
  76. #if (SPI_VENDOR_ID_VS_0_PBCFG_H != SPI_VENDOR_ID_CFG)
  77. #error "Spi_VS_0_PBcfg.h and Spi_Cfg.h have different vendor IDs"
  78. #endif
  79. /* Check if Spi_VS_0_PBcfg header file and Spi configuration header file are of the same Autosar version */
  80. #if ((SPI_AR_RELEASE_MAJOR_VERSION_VS_0_PBCFG_H != SPI_AR_RELEASE_MAJOR_VERSION_CFG) || \
  81. (SPI_AR_RELEASE_MINOR_VERSION_VS_0_PBCFG_H != SPI_AR_RELEASE_MINOR_VERSION_CFG) || \
  82. (SPI_AR_RELEASE_REVISION_VERSION_VS_0_PBCFG_H != SPI_AR_RELEASE_REVISION_VERSION_CFG))
  83. #error "AutoSar Version Numbers of Spi_VS_0_PBcfg.h and Spi_Cfg.h are different"
  84. #endif
  85. /* Check if Spi_VS_0_PBcfg header file and Spi configuration header file are of the same software version */
  86. #if ((SPI_SW_MAJOR_VERSION_VS_0_PBCFG_H != SPI_SW_MAJOR_VERSION_CFG) || \
  87. (SPI_SW_MINOR_VERSION_VS_0_PBCFG_H != SPI_SW_MINOR_VERSION_CFG) || \
  88. (SPI_SW_PATCH_VERSION_VS_0_PBCFG_H != SPI_SW_PATCH_VERSION_CFG))
  89. #error "Software Version Numbers of Spi_VS_0_PBcfg.h and Spi_Cfg.h are different"
  90. #endif
  91. /* Check if Spi_Ipw_Cfg header file and Spi configuration header file are of the same vendor */
  92. #if (SPI_IPW_VENDOR_ID_CFG_H != SPI_VENDOR_ID_CFG)
  93. #error "Spi_Ipw_Cfg.h and Spi_Cfg.h have different vendor IDs"
  94. #endif
  95. /* Check if Spi_Ipw_Cfg header file and Spi configuration header file are of the same Autosar version */
  96. #if ((SPI_IPW_AR_RELEASE_MAJOR_VERSION_CFG_H != SPI_AR_RELEASE_MAJOR_VERSION_CFG) || \
  97. (SPI_IPW_AR_RELEASE_MINOR_VERSION_CFG_H != SPI_AR_RELEASE_MINOR_VERSION_CFG) || \
  98. (SPI_IPW_AR_RELEASE_REVISION_VERSION_CFG_H != SPI_AR_RELEASE_REVISION_VERSION_CFG))
  99. #error "AutoSar Version Numbers of Spi_Ipw_Cfg.h and Spi_Cfg.h are different"
  100. #endif
  101. /* Check if Spi_Ipw_Cfg header file and Spi configuration header file are of the same software version */
  102. #if ((SPI_IPW_SW_MAJOR_VERSION_CFG_H != SPI_SW_MAJOR_VERSION_CFG) || \
  103. (SPI_IPW_SW_MINOR_VERSION_CFG_H != SPI_SW_MINOR_VERSION_CFG) || \
  104. (SPI_IPW_SW_PATCH_VERSION_CFG_H != SPI_SW_PATCH_VERSION_CFG))
  105. #error "Software Version Numbers of Spi_Ipw_Cfg.h and Spi_Cfg.h are different"
  106. #endif
  107. /*==================================================================================================
  108. * CONSTANTS
  109. ==================================================================================================*/
  110. /**
  111. * @brief Switches the Development Error functionality ON or OFF.
  112. * @details Switches the Development Error Detection and Notification ON or OFF.
  113. * @implements SPI_DEV_ERROR_DETECT_define
  114. */
  115. #define SPI_DEV_ERROR_DETECT (STD_ON)
  116. /**
  117. * @brief Switches the Version Information API functionality ON or OFF.
  118. * @details Switches the Spi_GetVersionInfo function ON or OFF.
  119. */
  120. #define SPI_VERSION_INFO_API (STD_ON)
  121. /**
  122. * @brief Switches the Interruptible Sequences handling functionality ON or OFF.
  123. * @details This parameter depends on SPI_LEVEL_DELIVERED value.
  124. * It is only used for SPI_LEVEL_DELIVERED configured to 1 or 2.
  125. * @implements SPI_INTERRUPTIBLE_SEQ_ALLOWED_define
  126. */
  127. #define SPI_INTERRUPTIBLE_SEQ_ALLOWED (STD_OFF)
  128. /**
  129. * @brief Switches the Spi_GetHWUnitStatus function ON or OFF.
  130. * @details Switches the Spi_GetHWUnitStatus function ON or OFF.
  131. * @implements SPI_HW_STATUS_API_define
  132. */
  133. #define SPI_HW_STATUS_API (STD_ON)
  134. /**
  135. * @brief Switches the Spi_Cancel function ON or OFF.
  136. * @details Switches the Spi_Cancel function ON or OFF. (see chapter 8.3.13)
  137. * @implements SPI_CANCEL_API_define
  138. */
  139. #define SPI_CANCEL_API (STD_ON)
  140. /* Only Internal Buffers are allowed in Handler Driver.*/
  141. #define USAGE0 0x00u
  142. /* Only External Buffers are allowed in Handler Driver.*/
  143. #define USAGE1 0x01u
  144. /* Both Buffer types are allowd in Handler Driver. */
  145. #define USAGE2 0x02u
  146. /**
  147. * @brief Selects the SPI Handler Driver Channel Buffers usage allowed and delivered.
  148. * @details Selects the SPI Handler Driver Channel Buffers usage allowed and delivered.
  149. * (see chapter 7.2.1)
  150. * @implements SPI_CHANNEL_BUFFERS_ALLOWED_define
  151. */
  152. #define SPI_CHANNEL_BUFFERS_ALLOWED (USAGE1)
  153. /* The LEVEL 0 Simple Synchronous SPI Handler Driver functionalities are selected.*/
  154. #define LEVEL0 0x00u
  155. /* The LEVEL 1 Basic Asynchronous SPI Handler Driver functionalities are selected.*/
  156. #define LEVEL1 0x01u
  157. /* The LEVEL 2 Enhanced SPI Handler Driver functionalities are selected. */
  158. #define LEVEL2 0x02u
  159. /**
  160. * @brief Selects the SPI Handler Driver level of scalable functionality.
  161. * @details Selects the SPI Handler Driver level of scalable functionality that
  162. * is available and delivered. (see chapter 7.1)
  163. * @implements SPI_LEVEL_DELIVERED_define
  164. */
  165. #define SPI_LEVEL_DELIVERED (LEVEL2)
  166. /**
  167. * @brief Defines the maximum number of supported channels.
  168. * @details Defines the maximum number of supported channels
  169. * for all the driver configurations.
  170. */
  171. #define SpiConf_SpiChannel_SpiChannel_0 ((Spi_ChannelType)0)
  172. #define SPI_MAX_CHANNEL (1u)
  173. /**
  174. * @brief Total number of Jobs configured.
  175. * @details Defines the maximum number of supported jobs
  176. * for all the driver configurations.
  177. */
  178. #define SpiConf_SpiJob_SpiJob_0 ((Spi_JobType)0)
  179. #define SPI_MAX_JOB (1u)
  180. /**
  181. * @brief Total number of Sequences configured.
  182. * @details Defines the maximum number of supported sequences
  183. * for all the driver configurations.
  184. */
  185. #define SpiConf_SpiSequence_SpiSequence_0 ((Spi_SequenceType)0)
  186. #define SPI_MAX_SEQUENCE (1u)
  187. /**
  188. * @brief Defines the peripherals used throughout the configuration(s).
  189. * @details Defines the peripherals used throughout the configuration(s).
  190. */
  191. #define CSIB0 ((uint8)0u)
  192. /**
  193. * @brief Total number of SpiPhyUnit configured.
  194. */
  195. #define SPI_MAX_HWUNIT (1u)
  196. /**
  197. * @brief Defines the external devices the driver will use.
  198. * @details Reference to the external device used by this job.
  199. */
  200. #define SPI_SpiExternalDevice_0 ((Spi_ExternalDeviceType)0u)
  201. /**
  202. * @brief Switches the Production Error Detection and Notification OFF
  203. *
  204. * @implements SPI_DISABLE_DEM_REPORT_ERROR_STATUS_define
  205. *
  206. */
  207. #define SPI_DISABLE_DEM_REPORT_ERROR_STATUS (STD_ON) /* Disable Production Error Detection */
  208. /*==================================================================================================
  209. * DEFINES AND MACROS
  210. ==================================================================================================*/
  211. /**
  212. * @brief Define values for Autosar configuration variants.
  213. * @details Define values for Autosar configuration variants.
  214. */
  215. #define SPI_VARIANT_PRECOMPILE (0)
  216. #define SPI_VARIANT_POSTBUILD (1)
  217. #define SPI_VARIANT_LINKTIME (2)
  218. /**
  219. * @brief Defines the use of Pre-Compile(PC) support
  220. * @details VARIANT-PRE-COMPILE: Only parameters with "Pre-compile time" configu-ration are allowed
  221. * in this variant.
  222. */
  223. /* Pre-Compile(PC) Support. */
  224. /* Link Time Support. */
  225. #define SPI_CONFIG_VARIANT (SPI_VARIANT_PRECOMPILE)
  226. /**
  227. * @brief Define precompile support.
  228. * @details Define precompile support if VariantPreCompile or VariantLinkTime is selected and number of variant <=1.
  229. */
  230. #define SPI_PRECOMPILE_SUPPORT (STD_ON)
  231. /**
  232. * @brief Defines the "Number of Loops" timeout.
  233. * @details Defines the "Number of Loops" timeout used by Spi_SyncTransmit and Spi_AsyncTransmit
  234. * function during the wait on TX/RX transmission to complete one frame.
  235. * One timeout unit means that no TX or RX was executed(the IF statements are returning FALSE).
  236. */
  237. #define SPI_TIMEOUT_COUNTER ((uint32)(50000))
  238. /**
  239. * @brief Allow simultaneous calls to Spi_SyncTransmit() for different threads.
  240. * @details Two concurrent calls to Spi_SyncTransmit() will be allowed only if the related sequences
  241. * do not share HW units.
  242. */
  243. #define SPI_SUPPORT_CONCURRENT_SYNC_TRANSMIT (STD_ON)
  244. /*==================================================================================================
  245. * SpiAutosarExt DEFINES
  246. ==================================================================================================*/
  247. /**
  248. * @brief If enabled, the asyncronous operation mode (POLLING or INTERRUPT)
  249. * @details If enabled, the asyncronous operation mode (POLLING or INTERRUPT) can
  250. * be defined independently for each HWUnit using Spi_SetHWUnitAsyncMode().
  251. * @implements SPI_HWUNIT_ASYNC_MODE_define
  252. */
  253. #define SPI_HWUNIT_ASYNC_MODE (STD_OFF)
  254. /**
  255. * @brief If enabled, allows to configure more than 256 sequences, jobs and channels.
  256. */
  257. #define SPI_ALLOW_BIGSIZE_COLLECTIONS (STD_OFF)
  258. /**
  259. * @brief If enabled, SPI_MAIN_FUNCTION_PERIOD defines the cycle time of the function Spi_MainFunction_Handling in seconds
  260. */
  261. /**
  262. * @brief Total number of partitions configured in Ecu.
  263. */
  264. #define SPI_MAX_PARTITIONS (1U)
  265. /**
  266. * @brief Enable Multicore Support.
  267. * @details When SpiGeneral/SpiMulticoreSupport = TRUE,
  268. * the SPI driver can be configured to support multicore.
  269. */
  270. #define SPI_MULTICORE_ENABLED (STD_OFF)
  271. #if (STD_OFF == SPI_MULTICORE_ENABLED)
  272. /**
  273. * @brief Defines default CodeId value which is assigned to HWUnits, Sequences, Jobs and Channels in the case multicore is not enabled.
  274. */
  275. #define SPI_SPURIOUS_CORE_ID ((uint32)0UL)
  276. #endif
  277. #if (STD_ON == SPI_MULTICORE_ENABLED)
  278. #define Spi_GetCoreID ((uint32)OsIf_GetCoreID())
  279. #else
  280. #define Spi_GetCoreID SPI_SPURIOUS_CORE_ID
  281. #endif
  282. /**
  283. * @brief Slave support
  284. */
  285. #define SPI_SLAVE_SUPPORT SPI_IPW_SLAVE_SUPPORT
  286. /**
  287. * @brief Defines if transfers are made using DMA or FIFO.
  288. * @details Defines if transfers are made using DMA or FIFO.
  289. * @implements SPI_DMA_USED_define
  290. */
  291. #define SPI_DMA_USED SPI_IPW_DMA_USED
  292. /**
  293. * @brief If enabled, allows dual MCU clock configuration settings.
  294. * @details If enabled, allows dual MCU clock configuration settings.
  295. * @implements SPI_DUAL_CLOCK_MODE_define
  296. */
  297. #define SPI_DUAL_CLOCK_MODE SPI_IPW_DUAL_CLOCK_MODE
  298. /**
  299. * @brief If enabled, allows to Sequence transfer in Dma Fast mode.
  300. */
  301. #define SPI_ENABLE_DMAFASTTRANSFER_SUPPORT SPI_IPW_ENABLE_DMAFASTTRANSFER_SUPPORT
  302. /**
  303. * @brief Half duplex mdoe enable .
  304. */
  305. #define SPI_HALF_DUPLEX_MODE_SUPPORT SPI_IPW_SPI_HALF_DUPLEX_MODE_SUPPORT
  306. /*==================================================================================================
  307. * ENUMS
  308. ==================================================================================================*/
  309. /*==================================================================================================
  310. * STRUCTURES AND OTHER TYPEDEFS
  311. ==================================================================================================*/
  312. /*==================================================================================================
  313. * GLOBAL VARIABLE DECLARATIONS
  314. ==================================================================================================*/
  315. /*==================================================================================================
  316. * FUNCTION PROTOTYPES
  317. ==================================================================================================*/
  318. #ifdef __cplusplus
  319. }
  320. #endif
  321. #endif /*SPI_CFG_H*/
  322. /** @} */