Qspi_Ip_Controller.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : FTFC_FLS_IP IPV_QSPI
  5. * Dependencies : none
  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 QSPI_IP_CONTROLLER_H
  25. #define QSPI_IP_CONTROLLER_H
  26. /**
  27. * @file Qspi_Ip_Controller.h
  28. *
  29. * @addtogroup IPV_QSPI QSPI IPV Driver
  30. * @{
  31. */
  32. /* implements Qspi_Ip_Controller.h_Artifact */
  33. #ifdef __cplusplus
  34. extern "C"{
  35. #endif
  36. #include "Qspi_Ip_Features.h"
  37. #include "Qspi_Ip_Common.h"
  38. #include "Qspi_Ip.h"
  39. /*==================================================================================================
  40. * SOURCE FILE VERSION INFORMATION
  41. ==================================================================================================*/
  42. #define QSPI_IP_CONTROLLER_VENDOR_ID_H 43
  43. #define QSPI_IP_CONTROLLER_AR_RELEASE_MAJOR_VERSION_H 4
  44. #define QSPI_IP_CONTROLLER_AR_RELEASE_MINOR_VERSION_H 4
  45. #define QSPI_IP_CONTROLLER_AR_RELEASE_REVISION_VERSION_H 0
  46. #define QSPI_IP_CONTROLLER_SW_MAJOR_VERSION_H 1
  47. #define QSPI_IP_CONTROLLER_SW_MINOR_VERSION_H 0
  48. #define QSPI_IP_CONTROLLER_SW_PATCH_VERSION_H 0
  49. /*==================================================================================================
  50. * FILE VERSION CHECKS
  51. ==================================================================================================*/
  52. /* Check if current file and Qspi_Ip_Features header file are of the same vendor */
  53. #if (QSPI_IP_CONTROLLER_VENDOR_ID_H != QSPI_IP_FEATURES_VENDOR_ID_CFG)
  54. #error "Qspi_Ip_Controller.h and Qspi_Ip_Features.h have different vendor ids"
  55. #endif
  56. /* Check if current file and Qspi_Ip_Features header file are of the same Autosar version */
  57. #if ((QSPI_IP_CONTROLLER_AR_RELEASE_MAJOR_VERSION_H != QSPI_IP_FEATURES_AR_RELEASE_MAJOR_VERSION_CFG) || \
  58. (QSPI_IP_CONTROLLER_AR_RELEASE_MINOR_VERSION_H != QSPI_IP_FEATURES_AR_RELEASE_MINOR_VERSION_CFG) || \
  59. (QSPI_IP_CONTROLLER_AR_RELEASE_REVISION_VERSION_H != QSPI_IP_FEATURES_AR_RELEASE_REVISION_VERSION_CFG) \
  60. )
  61. #error "AutoSar Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip_Features.h are different"
  62. #endif
  63. /* Check if current file and Qspi_Ip_Features header file are of the same Software version */
  64. #if ((QSPI_IP_CONTROLLER_SW_MAJOR_VERSION_H != QSPI_IP_FEATURES_SW_MAJOR_VERSION_CFG) || \
  65. (QSPI_IP_CONTROLLER_SW_MINOR_VERSION_H != QSPI_IP_FEATURES_SW_MINOR_VERSION_CFG) || \
  66. (QSPI_IP_CONTROLLER_SW_PATCH_VERSION_H != QSPI_IP_FEATURES_SW_PATCH_VERSION_CFG) \
  67. )
  68. #error "Software Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip_Features.h are different"
  69. #endif
  70. /* Check if current file and Qspi_Ip_Common header file are of the same vendor */
  71. #if (QSPI_IP_CONTROLLER_VENDOR_ID_H != QSPI_IP_COMMON_VENDOR_ID_H)
  72. #error "Qspi_Ip_Controller.h and Qspi_Ip_Common.h have different vendor ids"
  73. #endif
  74. /* Check if current file and Qspi_Ip_Common header file are of the same Autosar version */
  75. #if ((QSPI_IP_CONTROLLER_AR_RELEASE_MAJOR_VERSION_H != QSPI_IP_COMMON_AR_RELEASE_MAJOR_VERSION_H) || \
  76. (QSPI_IP_CONTROLLER_AR_RELEASE_MINOR_VERSION_H != QSPI_IP_COMMON_AR_RELEASE_MINOR_VERSION_H) || \
  77. (QSPI_IP_CONTROLLER_AR_RELEASE_REVISION_VERSION_H != QSPI_IP_COMMON_AR_RELEASE_REVISION_VERSION_H) \
  78. )
  79. #error "AutoSar Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip_Common.h are different"
  80. #endif
  81. /* Check if current file and Qspi_Ip_Common header file are of the same Software version */
  82. #if ((QSPI_IP_CONTROLLER_SW_MAJOR_VERSION_H != QSPI_IP_COMMON_SW_MAJOR_VERSION_H) || \
  83. (QSPI_IP_CONTROLLER_SW_MINOR_VERSION_H != QSPI_IP_COMMON_SW_MINOR_VERSION_H) || \
  84. (QSPI_IP_CONTROLLER_SW_PATCH_VERSION_H != QSPI_IP_COMMON_SW_PATCH_VERSION_H) \
  85. )
  86. #error "Software Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip_Common.h are different"
  87. #endif
  88. /* Check if current file and Qspi_Ip header file are of the same vendor */
  89. #if (QSPI_IP_CONTROLLER_VENDOR_ID_H != QSPI_IP_VENDOR_ID_H)
  90. #error "Qspi_Ip_Controller.h and Qspi_Ip.h have different vendor ids"
  91. #endif
  92. /* Check if current file and Qspi_Ip header file are of the same Autosar version */
  93. #if ((QSPI_IP_CONTROLLER_AR_RELEASE_MAJOR_VERSION_H != QSPI_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  94. (QSPI_IP_CONTROLLER_AR_RELEASE_MINOR_VERSION_H != QSPI_IP_AR_RELEASE_MINOR_VERSION_H) || \
  95. (QSPI_IP_CONTROLLER_AR_RELEASE_REVISION_VERSION_H != QSPI_IP_AR_RELEASE_REVISION_VERSION_H) \
  96. )
  97. #error "AutoSar Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip.h are different"
  98. #endif
  99. /* Check if current file and Qspi_Ip header file are of the same Software version */
  100. #if ((QSPI_IP_CONTROLLER_SW_MAJOR_VERSION_H != QSPI_IP_SW_MAJOR_VERSION_H) || \
  101. (QSPI_IP_CONTROLLER_SW_MINOR_VERSION_H != QSPI_IP_SW_MINOR_VERSION_H) || \
  102. (QSPI_IP_CONTROLLER_SW_PATCH_VERSION_H != QSPI_IP_SW_PATCH_VERSION_H) \
  103. )
  104. #error "Software Version Numbers of Qspi_Ip_Controller.h and Qspi_Ip.h are different"
  105. #endif
  106. #if (QSPI_IP_MEM_INSTANCE_COUNT > 0)
  107. /*******************************************************************************
  108. * Enumerations.
  109. ******************************************************************************/
  110. /*******************************************************************************
  111. * Definitions
  112. ******************************************************************************/
  113. #define FLS_START_SEC_CONST_UNSPECIFIED
  114. #include "Fls_MemMap.h"
  115. extern QuadSPI_Type * const Qspi_Ip_BaseAddress[];
  116. #define FLS_STOP_SEC_CONST_UNSPECIFIED
  117. #include "Fls_MemMap.h"
  118. /*******************************************************************************
  119. * API
  120. ******************************************************************************/
  121. /*!
  122. * @name QuadSPI Driver
  123. * @{
  124. */
  125. #define FLS_START_SEC_CODE
  126. #include "Fls_MemMap.h"
  127. /*!
  128. * @brief Configures LUT commands
  129. *
  130. * This function configures a pair of LUT commands in the specified LUT register.
  131. * LUT sequences start at index multiple of 4 and can have up to 8 commands
  132. *
  133. * @param instance QuadSPI peripheral instance number
  134. * @param lut Index in LUT table
  135. * @param instr0 First instruction
  136. * @param instr1 Second instruction
  137. * Implements Qspi_Ip_SetLut_Activity
  138. */
  139. void Qspi_Ip_SetLut(uint32 instance,
  140. uint8 lut,
  141. Qspi_Ip_InstrOpType operation0,
  142. Qspi_Ip_InstrOpType operation1
  143. );
  144. /*!
  145. * @brief Sets sequence ID for AHB operations
  146. *
  147. * @param instance QuadSPI peripheral instance number
  148. * @param seqID Sequence ID in LUT for read operation
  149. * Implements Qspi_Ip_SetAhbSeqId_Activity
  150. */
  151. void Qspi_Ip_SetAhbSeqId(uint32 instance,
  152. uint8 seqID
  153. );
  154. /*!
  155. * @brief Returns the physical base address of a flash device
  156. *
  157. * This function returns the physical base address of a flash device, depending on the QSPI connection.
  158. * The controller must be initialized prior to calling this function.
  159. *
  160. * @param instance QuadSPI peripheral instance number
  161. * @param connectionType Connection of the flash device to QSPI
  162. */
  163. uint32 Qspi_Ip_GetBaseAdress(uint32 instance,
  164. Qspi_Ip_ConnectionType connectionType
  165. );
  166. /*!
  167. * @brief Launches a simple IP command
  168. *
  169. * @param instance QuadSPI peripheral instance number
  170. * @param lut Index of LUT register
  171. * @param addr Address of the target serial flash
  172. * @return Error or success status returned by API
  173. */
  174. Qspi_Ip_StatusType Qspi_Ip_IpCommand(uint32 instance,
  175. uint8 lut,
  176. uint32 addr
  177. );
  178. /*!
  179. * @brief Launches an IP read command
  180. *
  181. * This function can launch a read command in 3 modes:
  182. * - normal read (dataRead != NULL_PTR): Data is read from serial flash and placed in the buffer
  183. * - verify (dataRead == NULL_PTR, dataCmp != NULL_PTR): Data is read from serial flash and compared to the reference buffer
  184. * - blank check (dataRead == NULL_PTR, dataCmp == NULL_PTR): Data is read from serial flash and compared to 0xFF
  185. * Only normal read mode can use DMA.
  186. *
  187. * @param instance QuadSPI peripheral instance number
  188. * @param lut Index of LUT register
  189. * @param addr Start address for read operation in serial flash
  190. * @param dataRead Buffer where to store read data
  191. * @param dataCmp Buffer to be compared to read data
  192. * @param size Size of data buffer
  193. * @return Error or success status returned by API
  194. */
  195. Qspi_Ip_StatusType Qspi_Ip_IpRead(uint32 instance,
  196. uint8 lut,
  197. uint32 addr,
  198. uint8 * dataRead,
  199. const uint8 * dataCmp,
  200. uint32 size
  201. );
  202. /*!
  203. * @brief Launches an IP write command
  204. *
  205. * @param instance QuadSPI peripheral instance number
  206. * @param lut Index of LUT register
  207. * @param addr Start address for write operation in serial flash
  208. * @param data Data to be programmed in flash
  209. * @param size Size of data buffer
  210. * @return Error or success status returned by API
  211. */
  212. Qspi_Ip_StatusType Qspi_Ip_IpWrite(uint32 instance,
  213. uint8 lut,
  214. uint32 addr,
  215. const uint8 * data,
  216. uint32 size
  217. );
  218. #define FLS_STOP_SEC_CODE
  219. #include "Fls_MemMap.h"
  220. #endif /* (QSPI_IP_MEM_INSTANCE_COUNT > 0) */
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224. /** @} */
  225. #endif /* QSPI_IP_CONTROLLER_H */