Flexio_Spi_Ip.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : LPSPI
  5. * Dependencies :
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. #ifndef FLEXIO_SPI_IP_H
  25. #define FLEXIO_SPI_IP_H
  26. /**
  27. * @file Flexio_Spi_Ip.h
  28. *
  29. * @brief FLEXIO_SPI IP driver header file.
  30. * @details FLEXIO_SPI IP driver header file.
  31. * @addtogroup FLEXIO_SPI_DRIVER Flexio_Spi Driver
  32. * @{
  33. */
  34. #ifdef __cplusplus
  35. extern "C"{
  36. #endif
  37. /*==================================================================================================
  38. * INCLUDE FILES
  39. * 1) system and project includes
  40. * 2) needed interfaces from external units
  41. * 3) internal and external interfaces from this unit
  42. ==================================================================================================*/
  43. #include "Flexio_Spi_Ip_Types.h"
  44. #ifdef FLEXIO_SPI_IP_ENABLE_USER_MODE_SUPPORT
  45. #include "Mcal.h"
  46. #endif
  47. /*==================================================================================================
  48. * SOURCE FILE VERSION INFORMATION
  49. ==================================================================================================*/
  50. #define FLEXIO_SPI_IP_VENDOR_ID 43
  51. #define FLEXIO_SPI_IP_AR_RELEASE_MAJOR_VERSION 4
  52. #define FLEXIO_SPI_IP_AR_RELEASE_MINOR_VERSION 4
  53. #define FLEXIO_SPI_IP_AR_RELEASE_REVISION_VERSION 0
  54. #define FLEXIO_SPI_IP_SW_MAJOR_VERSION 1
  55. #define FLEXIO_SPI_IP_SW_MINOR_VERSION 0
  56. #define FLEXIO_SPI_IP_SW_PATCH_VERSION 0
  57. /*==================================================================================================
  58. * FILE VERSION CHECKS
  59. ==================================================================================================*/
  60. /* Check if Flexio_Spi_Ip.h and Flexio_Spi_Ip_Types.h are of the same vendor */
  61. #if (FLEXIO_SPI_IP_VENDOR_ID != FLEXIO_SPI_IP_TYPES_VENDOR_ID)
  62. #error "Flexio_Spi_Ip.h and Flexio_Spi_Ip_Types.h have different vendor ids"
  63. #endif
  64. /* Check if Flexio_Spi_Ip.h file and Flexio_Spi_Ip_Types.h file are of the same Autosar version */
  65. #if ((FLEXIO_SPI_IP_AR_RELEASE_MAJOR_VERSION != FLEXIO_SPI_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  66. (FLEXIO_SPI_IP_AR_RELEASE_MINOR_VERSION != FLEXIO_SPI_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
  67. (FLEXIO_SPI_IP_AR_RELEASE_REVISION_VERSION != FLEXIO_SPI_IP_TYPES_AR_RELEASE_REVISION_VERSION))
  68. #error "AutoSar Version Numbers of Flexio_Spi_Ip.h and Flexio_Spi_Ip_Types.h are different"
  69. #endif
  70. #if ((FLEXIO_SPI_IP_SW_MAJOR_VERSION != FLEXIO_SPI_IP_TYPES_SW_MAJOR_VERSION) || \
  71. (FLEXIO_SPI_IP_SW_MINOR_VERSION != FLEXIO_SPI_IP_TYPES_SW_MINOR_VERSION) || \
  72. (FLEXIO_SPI_IP_SW_PATCH_VERSION != FLEXIO_SPI_IP_TYPES_SW_PATCH_VERSION))
  73. #error "Software Version Numbers of Flexio_Spi_Ip.h and Flexio_Spi_Ip_Types.h are different"
  74. #endif
  75. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  76. #ifdef FLEXIO_SPI_IP_ENABLE_USER_MODE_SUPPORT
  77. /* Check if Flexio_Spi_Ip.h file and Mcal.h file are of the same Autosar version */
  78. #if ((FLEXIO_SPI_IP_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  79. (FLEXIO_SPI_IP_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION) \
  80. )
  81. #error "AutoSar Version Numbers of Flexio_Spi_Ip.h and Mcal.h are different"
  82. #endif
  83. #endif /* FLEXIO_SPI_IP_ENABLE_USER_MODE_SUPPORT */
  84. #endif
  85. /*==================================================================================================
  86. * CONSTANTS
  87. ==================================================================================================*/
  88. /*==================================================================================================
  89. * DEFINES AND MACROS
  90. ==================================================================================================*/
  91. /*==================================================================================================
  92. * ENUMS
  93. ==================================================================================================*/
  94. /*==================================================================================================
  95. * STRUCTURES AND OTHER TYPEDEFS
  96. ==================================================================================================*/
  97. /*==================================================================================================
  98. * GLOBAL VARIABLE DECLARATIONS
  99. ==================================================================================================*/
  100. #if (FLEXIO_SPI_IP_ENABLE == STD_ON)
  101. #define SPI_START_SEC_CONFIG_DATA_UNSPECIFIED
  102. #include "Spi_MemMap.h"
  103. /**
  104. * @brief Export Post-Build configurations.
  105. */
  106. FLEXIO_SPI_IP_CONFIG_EXT
  107. #define SPI_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  108. #include "Spi_MemMap.h"
  109. /*==================================================================================================
  110. * FUNCTION PROTOTYPES
  111. ==================================================================================================*/
  112. #define SPI_START_SEC_CODE
  113. #include "Spi_MemMap.h"
  114. /**
  115. * @brief FLEXIO_SPI peripheral initialization.
  116. * @details The function initialize the SPI Unit specified in the configuration.
  117. *
  118. * @param[in] Configuration - pointer to the specified SPI Unit configuration.
  119. *
  120. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Initialization command has been accepted.
  121. * FLEXIO_SPI_IP_STATUS_FAIL: Initialization command has not been accepted.
  122. * @implements Flexio_Spi_Ip_Init_Activity
  123. */
  124. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_Init(const Flexio_Spi_Ip_ConfigType *Configuration);
  125. /**
  126. * @brief FLEXIO_SPI peripheral deinitialization.
  127. * @details The function de-initialize the SPI peripheral instance specified.
  128. * All registers of SPI peripheral will be reset.
  129. *
  130. * @param[in] Instance - SPI peripheral instance number.
  131. *
  132. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: De-initialization command has been accepted.
  133. * FLEXIO_SPI_IP_STATUS_FAIL: De-initialization command has not been accepted.
  134. * @implements Flexio_Spi_Ip_DeInit_Activity
  135. */
  136. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_DeInit(uint8 Instance);
  137. /**
  138. * @brief FLEXIO_SPI synchronous transmission.
  139. * @details This function initializes a synchronous transfer using the bus parameters provided
  140. * by external device.
  141. *
  142. * @param[in] ExternalDevice - pointer to the external device where data is transmitted.
  143. * @param[in] TxBuffer - pointer to transmit buffer.
  144. * @param[in-out] RxBuffer - pointer to receive buffer.
  145. * @param[in] Length - number of bytes to be sent.
  146. * @param[in] TimeOut - duration for sending one frame.
  147. *
  148. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Transmission command has been accepted.
  149. * FLEXIO_SPI_IP_FIFO_ERROR: Overflow or underflow error occurred.
  150. * FLEXIO_SPI_IP_STATUS_FAIL: Transmission command has not been accepted.
  151. * FLEXIO_SPI_IP_TIMEOUT: Timeout error occurred.
  152. *
  153. * @implements Flexio_Spi_Ip_SyncTransmit_Activity
  154. */
  155. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_SyncTransmit(
  156. const Flexio_Spi_Ip_ExternalDeviceType *ExternalDevice,
  157. uint8 *TxBuffer,
  158. uint8 *RxBuffer,
  159. uint16 Length,
  160. uint32 TimeOut
  161. );
  162. /**
  163. * @brief FLEXIO_SPI asynchronous transmission.
  164. * @details This function initializes an asynchronous transfer using the bus parameters provided
  165. * by external device.
  166. *
  167. * @param[in] ExternalDevice - pointer to the external device where data is transmitted
  168. * @param[in] TxBuffer - pointer to transmit buffer.
  169. * @param[in-out] RxBuffer - pointer to receive buffer.
  170. * @param[in] Length - number of bytes to be sent.
  171. * @param[in] Callback - callback function is called at the end of transfer.
  172. *
  173. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Transmission command has been accepted.
  174. * FLEXIO_SPI_IP_STATUS_FAIL: Transmission command has not been accepted.
  175. * @implements Flexio_Spi_Ip_AsyncTransmit_Activity
  176. */
  177. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_AsyncTransmit(
  178. const Flexio_Spi_Ip_ExternalDeviceType *ExternalDevice,
  179. uint8* TxBuffer,
  180. uint8* RxBuffer,
  181. uint16 Length,
  182. Flexio_Spi_Ip_CallbackType Callback /* TBD de pus la init/instanta */
  183. );
  184. /**
  185. * @brief Get status of HW unit.
  186. * @details This function will return status of HW unit assigned.
  187. *
  188. * @param[in] instance Instance of the hardware unit.
  189. *
  190. * @return Flexio_Spi_Ip_HwStatusType
  191. * @retval FLEXIO_SPI_IP_IDLE Hardware unit is not used
  192. * @retval FLEXIO_SPI_IP_BUSY A transfer is in progress
  193. * @retval FLEXIO_SPI_IP_FAULT During last transfer a fault occurred
  194. * @implements Flexio_Spi_Ip_GetStatus_Activity
  195. */
  196. Flexio_Spi_Ip_HwStatusType Flexio_Spi_Ip_GetStatus(uint8 Instance);
  197. /**
  198. * @brief Process transfer in POLLING mode.
  199. * @details This function shall polls the SPI interrupts linked to SPI peripheral instance allocated to
  200. * the transmission of data to enable the evolution of transmission state machine.
  201. *
  202. * @param[in] Instance - SPI peripheral instance number.
  203. *
  204. * @return void
  205. * @implements Flexio_Spi_Ip_ManageBuffers_Activity
  206. */
  207. void Flexio_Spi_Ip_ManageBuffers(uint8 Instance);
  208. /**
  209. * @brief FLEXIO_SPI change frame size.
  210. * @details This function updates frame size of specific external device configuration for next transfers.
  211. *
  212. * @param[in] ExternalDevice - pointer to the external device configuration.
  213. * @param[in] FrameSize - Frame size.
  214. *
  215. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Setting command has been accepted.
  216. * FLEXIO_SPI_IP_STATUS_FAIL: Setting command has not been accepted.
  217. * @implements Flexio_Spi_Ip_UpdateFrameSize_Activity
  218. */
  219. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_UpdateFrameSize(const Flexio_Spi_Ip_ExternalDeviceType *ExternalDevice, uint8 FrameSize);
  220. /**
  221. * @brief FLEXIO_SPI change bit order.
  222. * @details This function updates bits order LSB or MSB of specific external device configuration for next transfer.
  223. *
  224. * @param[in] ExternalDevice - pointer to the external device configuration.
  225. * @param[in] Lsb - Data is transferred LSB first or not.
  226. *
  227. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Setting command has been accepted.
  228. * FLEXIO_SPI_IP_STATUS_FAIL: Setting command has not been accepted.
  229. * @implements Flexio_Spi_Ip_UpdateLsb_Activity
  230. */
  231. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_UpdateLsb(const Flexio_Spi_Ip_ExternalDeviceType *ExternalDevice, boolean Lsb);
  232. /**
  233. * @brief FLEXIO_SPI change default transmit data.
  234. * @details This function updates default transmit data of specific external device configuration for next transfer.
  235. *
  236. * @param[in] ExternalDevice - pointer to the external device configuration.
  237. * @param[in] DefaultData - New default transmit data.
  238. *
  239. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Setting command has been accepted.
  240. * FLEXIO_SPI_IP_STATUS_FAIL: Setting command has not been accepted.
  241. * @implements Flexio_Spi_Ip_UpdateDefaultTransmitData_Activity
  242. */
  243. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_UpdateDefaultTransmitData(const Flexio_Spi_Ip_ExternalDeviceType *ExternalDevice, uint32 DefaultData);
  244. /**
  245. * @brief FLEXIO_SPI change transfer mode.
  246. * @details This function updates the asynchronous mechanism mode for the specified SPI Hardware microcontroller peripheral.
  247. *
  248. * @param[in] Instance - SPI peripheral instance number.
  249. * @param[in] Mode - new mode (interrupt or polling).
  250. *
  251. * @return FLEXIO_SPI_IP_STATUS_SUCCESS: Setting command has been accepted.
  252. * FLEXIO_SPI_IP_STATUS_FAIL: Setting command has not been accepted.
  253. * @implements Flexio_Spi_Ip_UpdateTransferMode_Activity
  254. */
  255. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_UpdateTransferMode(uint8 Instance, Flexio_Spi_Ip_ModeType Mode);
  256. /**
  257. * @brief FLEXIO_SPI cancel current transmission.
  258. * @details This function will cancel current asynchronous transmission.
  259. *
  260. * @param[in] Instance Instance of the hardware unit.
  261. *
  262. * @implements Flexio_Spi_Ip_Cancel_Activity
  263. */
  264. void Flexio_Spi_Ip_Cancel(uint8 Instance);
  265. #if (FLEXIO_SPI_IP_DUAL_CLOCK_MODE == STD_ON)
  266. /**
  267. * @brief This function will change clock mode.
  268. * @details This function will change clock mode to operate with other clock reference.
  269. *
  270. * @param[in] Instance Instance of the hardware unit.
  271. * @param[in] ClockMode Clock mode.
  272. *
  273. * @return An error code or FLEXIO_SPI_IP_STATUS_SUCCESS
  274. */
  275. Flexio_Spi_Ip_StatusType Flexio_Spi_Ip_SetClockMode(uint8 Instance, Flexio_Spi_Ip_DualClockModeType ClockMode);
  276. #endif
  277. #if (FLEXIO_SPI_IP_DMA_USED == STD_ON)
  278. void Flexio_Spi_Ip_IrqTxDmaHandler(uint8 Instance);
  279. void Flexio_Spi_Ip_IrqRxDmaHandler(uint8 Instance);
  280. #endif
  281. #define SPI_STOP_SEC_CODE
  282. #include "Spi_MemMap.h"
  283. #endif /*FLEXIO_SPI_IP_ENABLE == STD_ON)*/
  284. #ifdef __cplusplus
  285. }
  286. #endif
  287. #endif /* FLEXIO_SPI_IP_H */
  288. /** @} */