Fls_Types.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. /*==================================================================================================
  25. ==================================================================================================*/
  26. #ifndef FLS_TYPES_H
  27. #define FLS_TYPES_H
  28. /**
  29. * @file Fls_Types.h
  30. *
  31. * @addtogroup FLS FLS Driver
  32. * @{
  33. */
  34. /* implements Fls_Types.h_Artifact */
  35. #ifdef __cplusplus
  36. extern "C"{
  37. #endif
  38. /*==================================================================================================
  39. * INCLUDE FILES
  40. * 1) system and project includes
  41. * 2) needed interfaces from external units
  42. * 3) internal and external interfaces from this unit
  43. ==================================================================================================*/
  44. #include "StandardTypes.h"
  45. #include "MemIf_Types.h"
  46. #include "Ftfc_Fls_Ip_Types.h"
  47. #include "Qspi_Ip_Types.h"
  48. /*==================================================================================================
  49. * SOURCE FILE VERSION INFORMATION
  50. ==================================================================================================*/
  51. #define FLS_TYPES_VENDOR_ID 43
  52. #define FLS_TYPES_AR_RELEASE_MAJOR_VERSION 4
  53. #define FLS_TYPES_AR_RELEASE_MINOR_VERSION 4
  54. #define FLS_TYPES_AR_RELEASE_REVISION_VERSION 0
  55. #define FLS_TYPES_SW_MAJOR_VERSION 1
  56. #define FLS_TYPES_SW_MINOR_VERSION 0
  57. #define FLS_TYPES_SW_PATCH_VERSION 0
  58. /*==================================================================================================
  59. FILE VERSION CHECKS
  60. ==================================================================================================*/
  61. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  62. /* Check if current file and StandardTypes.h file are of the same version */
  63. #if ((FLS_TYPES_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
  64. (FLS_TYPES_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)\
  65. )
  66. #error "AutoSar Version Numbers of Fls_Types.h and StandardTypes.h are different"
  67. #endif
  68. #endif
  69. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  70. /* Check if current file and MemIf_Types.h file are of the same version */
  71. #if ((FLS_TYPES_AR_RELEASE_MAJOR_VERSION != MEMIF_AR_RELEASE_MAJOR_VERSION) || \
  72. (FLS_TYPES_AR_RELEASE_MINOR_VERSION != MEMIF_AR_RELEASE_MINOR_VERSION)\
  73. )
  74. #error "AutoSar Version Numbers of Fls_Types.h and MemIf_Types.h are different"
  75. #endif
  76. #endif
  77. /* Check if current file and Ftfc_Fls_Ip_Types.h header file are of the same vendor */
  78. #if (FLS_TYPES_VENDOR_ID != FTFC_FLS_IP_TYPES_VENDOR_ID)
  79. #error "Fls_Types.h and Ftfc_Fls_Ip_Types.h have different vendor ids"
  80. #endif
  81. /* Check if current file and Ftfc_Fls_Ip_Types.h header file are of the same Autosar version */
  82. #if ((FLS_TYPES_AR_RELEASE_MAJOR_VERSION != FTFC_FLS_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  83. (FLS_TYPES_AR_RELEASE_MINOR_VERSION != FTFC_FLS_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
  84. (FLS_TYPES_AR_RELEASE_REVISION_VERSION != FTFC_FLS_IP_TYPES_AR_RELEASE_REVISION_VERSION) \
  85. )
  86. #error "AutoSar Version Numbers of Fls_Types.h and Ftfc_Fls_Ip_Types.h are different"
  87. #endif
  88. /* Check if current file and Ftfc_Fls_Ip_Types.h header file are of the same software version */
  89. #if ((FLS_TYPES_SW_MAJOR_VERSION != FTFC_FLS_IP_TYPES_SW_MAJOR_VERSION) || \
  90. (FLS_TYPES_SW_MINOR_VERSION != FTFC_FLS_IP_TYPES_SW_MINOR_VERSION) || \
  91. (FLS_TYPES_SW_PATCH_VERSION != FTFC_FLS_IP_TYPES_SW_PATCH_VERSION) \
  92. )
  93. #error "Software Version Numbers of Fls_Types.h and Ftfc_Fls_Ip_Types.h are different"
  94. #endif
  95. /* Check if current file and Qspi_Ip_Types.h header file are of the same vendor */
  96. #if (FLS_TYPES_VENDOR_ID != FLS_QSPI_TYPES_VENDOR_ID)
  97. #error "Fls_Types.h and Qspi_Ip_Types.h have different vendor ids"
  98. #endif
  99. /* Check if current file and Qspi_Ip_Types.h header file are of the same Autosar version */
  100. #if ((FLS_TYPES_AR_RELEASE_MAJOR_VERSION != FLS_QSPI_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  101. (FLS_TYPES_AR_RELEASE_MINOR_VERSION != FLS_QSPI_TYPES_AR_RELEASE_MINOR_VERSION) || \
  102. (FLS_TYPES_AR_RELEASE_REVISION_VERSION != FLS_QSPI_TYPES_AR_RELEASE_REVISION_VERSION) \
  103. )
  104. #error "AutoSar Version Numbers of Fls_Types.h and Qspi_Ip_Types.h are different"
  105. #endif
  106. /* Check if current file and Qspi_Ip_Types.h header file are of the same software version */
  107. #if ((FLS_TYPES_SW_MAJOR_VERSION != FLS_QSPI_TYPES_SW_MAJOR_VERSION) || \
  108. (FLS_TYPES_SW_MINOR_VERSION != FLS_QSPI_TYPES_SW_MINOR_VERSION) || \
  109. (FLS_TYPES_SW_PATCH_VERSION != FLS_QSPI_TYPES_SW_PATCH_VERSION) \
  110. )
  111. #error "Software Version Numbers of Fls_Types.h and Qspi_Ip_Types.h are different"
  112. #endif
  113. /*==================================================================================================
  114. * DEFINES AND MACROS
  115. ==================================================================================================*/
  116. /*==================================================================================================
  117. STRUCTURES AND OTHER TYPEDEFS
  118. ==================================================================================================*/
  119. /**
  120. @brief Flash sector channel type.
  121. */
  122. typedef enum
  123. {
  124. FLS_CH_INTERN = 0,
  125. FLS_CH_QSPI = 1
  126. } Fls_HwChType;
  127. /**
  128. * @brief Type of job currently executed by Fls_MainFunction.
  129. */
  130. typedef enum
  131. {
  132. /**
  133. * @brief erase one or more complete flash sectors
  134. */
  135. FLS_JOB_ERASE = 0,
  136. /**
  137. * @brief write one or more complete flash pages
  138. */
  139. FLS_JOB_WRITE,
  140. /**
  141. * @brief read one or more bytes from flash memory
  142. */
  143. FLS_JOB_READ,
  144. /**
  145. * @brief compare data buffer with content of flash memory
  146. */
  147. FLS_JOB_COMPARE,
  148. /**
  149. * @brief check content of erased flash memory area
  150. */
  151. FLS_JOB_BLANK_CHECK
  152. } Fls_JobType;
  153. /**
  154. * @brief Result of low-level flash operation.
  155. */
  156. typedef enum
  157. {
  158. FLASH_E_OK = 0, /**< @brief operation succeeded */
  159. FLASH_E_FAILED, /**< @brief operation failed due to hardware error */
  160. FLASH_E_BLOCK_INCONSISTENT, /**< @brief data buffer doesn't match with content of flash memory */
  161. FLASH_E_PENDING, /**< @brief operation is pending */
  162. FLASH_E_PARTITION_ERR /**< @brief FlexNVM partition ratio error */
  163. } Fls_LLDReturnType;
  164. /**
  165. * @brief Type of job currently executed by Fls_LLDMainFunction.
  166. */
  167. typedef enum
  168. {
  169. /**
  170. * @brief no job executed by Fls_LLDMainFunction
  171. */
  172. FLASH_JOB_NONE = 0,
  173. /**
  174. * @brief erase one flash sector
  175. */
  176. FLASH_JOB_ERASE,
  177. /**
  178. * @brief complete erase and start an interleaved erase flash sector
  179. */
  180. FLASH_JOB_ERASE_TEMP,
  181. /**
  182. * @brief write one or more complete flash pages
  183. */
  184. FLASH_JOB_WRITE,
  185. /**
  186. * @brief erase blank check of flash sector
  187. */
  188. FLASH_JOB_ERASE_BLANK_CHECK
  189. } Fls_LLDJobType;
  190. /**
  191. * @brief Size of data to be processeed by CRC.
  192. *
  193. * @implements Fls_CrcDataSizeType_enumeration
  194. */
  195. typedef enum
  196. {
  197. /**
  198. * @brief crc 8 bits
  199. */
  200. FLS_CRC_8_BITS = 0,
  201. /**
  202. * @brief crc 16 bits
  203. */
  204. FLS_CRC_16_BITS
  205. } Fls_CrcDataSizeType;
  206. /**
  207. * @brief Logical sector index.
  208. */
  209. typedef uint32 Fls_SectorIndexType;
  210. /**
  211. * @brief Fls CRC Type.
  212. * @details CRC computed over config set.
  213. * @implements Fls_CrcType_typedef
  214. */
  215. typedef uint16 Fls_CrcType;
  216. /**
  217. * @brief Fls Address Type.
  218. * @details Address offset from the configured flash base address to access a certain flash
  219. * memory area.
  220. * @implements Fls_AddressType_typedef */
  221. typedef uint32 Fls_AddressType;
  222. /**
  223. * @brief Fls Length Type.
  224. * @details Number of bytes to read,write,erase,compare
  225. * @implements Fls_LengthType_typedef */
  226. typedef uint32 Fls_LengthType;
  227. /**
  228. * @brief Fls Sector Count Type
  229. * @details Number of configured sectors
  230. */
  231. typedef uint32 Fls_SectorCountType;
  232. /**
  233. * @brief Fls BLock Count Type
  234. * @details Block number of sectors type
  235. */
  236. typedef uint8 Fls_BlockNumberOfSectorType;
  237. /**
  238. * @brief Fls Internal Flash Type
  239. * @details Configuration structure of internal flash.
  240. */
  241. typedef Ftfc_ConfigType Fls_InternalConfigType;
  242. /**
  243. * @brief Fls Job End Notification Pointer Type
  244. * @details Pointer type of Fls_JobEndNotification function
  245. * @implements Fls_JobEndNotificationPtrType_typedef */
  246. typedef void (*Fls_JobEndNotificationPtrType)(void);
  247. /**
  248. * @brief Fls Job Error Notification Pointer Type
  249. * @details Pointer type of Fls_JobErrorNotification function
  250. * @implements Fls_JobErrorNotificationPtrType_typedef */
  251. typedef void (*Fls_JobErrorNotificationPtrType)(void);
  252. /**
  253. * @brief Pointer type of Fls_AC_Callback function
  254. */
  255. typedef void (*Fls_ACCallbackPtrType) ( void );
  256. /**
  257. @brief Define pointer type of erase access code function
  258. */
  259. typedef void (*Fls_AcErasePtrType) ( void (*CallBack)( void ));
  260. /**
  261. @brief Define pointer type of write access code function
  262. */
  263. typedef void (*Fls_AcWritePtrType) ( void (*CallBack)( void ));
  264. /**
  265. * @brief Pointer type of Fls_ReadFunctionPtrType function
  266. *
  267. * @details The callout for the user to check for ECC errors for Internal Flash memories.
  268. * In this callout, the user can schedule a task that reads from flash memory
  269. * to a read source buffer and check/handle for an ECC exception.
  270. *
  271. *
  272. */
  273. typedef void (*Fls_ReadFunctionPtrType) (void);
  274. /**
  275. @brief FLASH physical sector description
  276. */
  277. typedef struct
  278. {
  279. uint32 pSectorStartAddressPtr; /**< @brief FLASH physical sector start address */
  280. Fls_BlockNumberOfSectorType blockNumberOfSector; /**< @brief block number of sector */
  281. boolean bEccTriggersExc; /**< @brief Triggers reading ECC data exception? */
  282. uint32 u32SectorId; /**< @brief Corresponding number in sector location to calc cfgCRC */
  283. } Fls_Flash_InternalSectorInfoType;
  284. /**
  285. * @brief Fls Qspi CfgConfig Type
  286. * @details Fls Qspi CfgConfig Type
  287. * @implements Fls_QspiCfgConfigType_typedef */
  288. typedef struct
  289. {
  290. /**
  291. * @brief External flash unit assigned to each sector. Size: u32SectorCount
  292. */
  293. const uint8 (*u8SectFlashUnit)[];
  294. /**
  295. * @brief Number of serial flash instances.
  296. */
  297. const uint8 u8FlashUnitsCount;
  298. /**
  299. * @brief Connection for each external memory device to available controllers. Size: u8FlashUnitsCount
  300. */
  301. const Qspi_Ip_MemoryConnectionType (*paFlashConnectionCfg)[];
  302. /**
  303. * @brief Configuration index used for each flash unit. Size: u8FlashUnitsCount
  304. */
  305. const uint8 (*u8FlashConfig)[];
  306. /**
  307. * @brief AHB direct reads configurations. Size: u8FlashUnitsCount
  308. */
  309. const boolean (*paAHBReadCfg)[];
  310. /**
  311. * @brief Number of serial flash configurations.
  312. */
  313. const uint8 u8FlashConfigCount;
  314. /**
  315. * @brief External memory devices configurations. Size: u8FlashConfigCount
  316. */
  317. const Qspi_Ip_MemoryConfigType (*paFlashCfg)[];
  318. /**
  319. * @brief Number of QSPI hardware instances.
  320. */
  321. const uint8 u8QspiUnitsCount;
  322. /**
  323. * @brief Configuration for each QSPI unit. Size: u8QspiUnitsCount ]
  324. */
  325. const uint8 (*u8QspiConfig)[];
  326. /**
  327. * @brief Number of QSPI configurations.
  328. */
  329. const uint8 u8QspiConfigCount;
  330. /**
  331. * @brief QSPI configurations. Size: u8QspiConfigCount
  332. */
  333. const Qspi_Ip_ControllerConfigType (*paQspiUnitCfg)[];
  334. }Fls_QspiCfgConfigType;
  335. /**
  336. * @brief Fls Config Type
  337. * @details Fls module initialization data structure
  338. * @implements Fls_ConfigType_typedef */
  339. typedef struct
  340. {
  341. /**
  342. * @brief pointer to erase access code function in RAM or ROM
  343. */
  344. Fls_AcErasePtrType acErasePtr;
  345. /**
  346. * @brief pointer to write access code function in RAM or ROM
  347. */
  348. Fls_AcWritePtrType acWritePtr;
  349. /**
  350. * @brief pointer to ac callback function
  351. */
  352. Fls_ACCallbackPtrType acCallBackPtr;
  353. /**
  354. * @brief pointer to job end notification function
  355. */
  356. Fls_JobEndNotificationPtrType jobEndNotificationPtr;
  357. /**
  358. * @brief pointer to job error notification function
  359. */
  360. Fls_JobErrorNotificationPtrType jobErrorNotificationPtr;
  361. /**
  362. * @brief pointer to read to flash memory callout
  363. */
  364. Fls_ReadFunctionPtrType FlsReadFunctionCallout;
  365. /**
  366. * @brief default FLS device mode after initialization (MEMIF_MODE_FAST, MEMIF_MODE_SLOW)
  367. */
  368. MemIf_ModeType eDefaultMode;
  369. /**
  370. * @brief max number of bytes to read in one cycle of Fls_MainFunction (fast mode)
  371. */
  372. Fls_LengthType u32MaxReadFastMode;
  373. /**
  374. * @brief max number of bytes to read in one cycle of Fls_MainFunction (normal mode)
  375. */
  376. Fls_LengthType u32MaxReadNormalMode;
  377. /**
  378. * @brief max number of bytes to write in one cycle of Fls_MainFunction (fast mode)
  379. */
  380. Fls_LengthType u32MaxWriteFastMode;
  381. /**
  382. * @brief max number of bytes to write in one cycle of Fls_MainFunction (normal mode)
  383. */
  384. Fls_LengthType u32MaxWriteNormalMode;
  385. /**
  386. * @brief number of configured logical sectors
  387. */
  388. Fls_SectorCountType u32SectorCount;
  389. /**
  390. * @brief pointer to array containing last logical address of each configured sector
  391. */
  392. const Fls_AddressType (*paSectorEndAddr)[];
  393. /**
  394. * @brief pointer to array containing sector size of each configured sector
  395. */
  396. const Fls_LengthType (*paSectorSize)[];
  397. /**
  398. * @brief pointer to array containing physical sector ID of each configured sector
  399. */
  400. const Fls_Flash_InternalSectorInfoType * const (*pSectorList)[];
  401. /**
  402. * @brief pointer to array containing flags set of each configured sector
  403. */
  404. const uint8 (*paSectorFlags)[];
  405. /**
  406. * @brief pointer to array containing page size information of each configured sector
  407. */
  408. const Fls_LengthType (*paSectorPageSize)[];
  409. /**
  410. * @brief Pointer to array containing the hardware channel(internal, external_qspi, external_emmc) of each configured sector.
  411. */
  412. const Fls_HwChType (*paHwCh)[];
  413. /**
  414. * @brief Pointer to array containing the configured hardware start address of each external sector.
  415. */
  416. const uint32 (*paSectorHwAddress)[];
  417. /** @brief Pointer to configuration structure of QSPI. */
  418. const Fls_QspiCfgConfigType * pFlsQspiCfgConfig;
  419. /**
  420. * @brief Pointer to configuration structure internal flash.
  421. */
  422. const Fls_InternalConfigType * pFlsInternalCfgConfig;
  423. /**
  424. * @brief FLS Config Set CRC checksum
  425. */
  426. Fls_CrcType u16ConfigCrc;
  427. } Fls_ConfigType;
  428. #ifdef __cplusplus
  429. }
  430. #endif
  431. /** @}*/
  432. #endif /* FLS_TYPES_H */