1 /*
2  * Copyright 2021-2024 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef QSPI_IP_HYPERFLASH_H
8 #define QSPI_IP_HYPERFLASH_H
9 
10 /**
11 *   @file Qspi_Ip_Hyperflash.h
12 *
13 *   @addtogroup IPV_QSPI
14 *   @{
15 */
16 
17 #ifdef __cplusplus
18 extern "C"{
19 #endif
20 
21 
22 
23 /*==================================================================================================
24  *                                        INCLUDE FILES
25 ==================================================================================================*/
26 #include "Qspi_Ip_Types.h"
27 
28 
29 /*==================================================================================================
30  *                              SOURCE FILE VERSION INFORMATION
31 ==================================================================================================*/
32 #define QSPI_IP_HYPERFLASH_VENDOR_ID_H                    43
33 #define QSPI_IP_HYPERFLASH_AR_RELEASE_MAJOR_VERSION_H     4
34 #define QSPI_IP_HYPERFLASH_AR_RELEASE_MINOR_VERSION_H     7
35 #define QSPI_IP_HYPERFLASH_AR_RELEASE_REVISION_VERSION_H  0
36 #define QSPI_IP_HYPERFLASH_SW_MAJOR_VERSION_H             2
37 #define QSPI_IP_HYPERFLASH_SW_MINOR_VERSION_H             0
38 #define QSPI_IP_HYPERFLASH_SW_PATCH_VERSION_H             0
39 
40 #if (QSPI_IP_MEM_INSTANCE_COUNT > 0)
41 
42 /*==================================================================================================
43  *                                     FILE VERSION CHECKS
44 ==================================================================================================*/
45 /* Check if current file and Qspi_Ip_Types header file are of the same vendor */
46 #if (QSPI_IP_HYPERFLASH_VENDOR_ID_H != QSPI_IP_TYPES_VENDOR_ID_CFG)
47     #error "Qspi_Ip_Hyperflash.h and Qspi_Ip_Types.h have different vendor ids"
48 #endif
49 /* Check if current file and Qspi_Ip_Types header file are of the same Autosar version */
50 #if ((QSPI_IP_HYPERFLASH_AR_RELEASE_MAJOR_VERSION_H    != QSPI_IP_TYPES_AR_RELEASE_MAJOR_VERSION_CFG) || \
51      (QSPI_IP_HYPERFLASH_AR_RELEASE_MINOR_VERSION_H    != QSPI_IP_TYPES_AR_RELEASE_MINOR_VERSION_CFG) || \
52      (QSPI_IP_HYPERFLASH_AR_RELEASE_REVISION_VERSION_H != QSPI_IP_TYPES_AR_RELEASE_REVISION_VERSION_CFG) \
53     )
54     #error "AutoSar Version Numbers of Qspi_Ip_Hyperflash.h and Qspi_Ip_Types.h are different"
55 #endif
56 /* Check if current file and Qspi_Ip_Types header file are of the same Software version */
57 #if ((QSPI_IP_HYPERFLASH_SW_MAJOR_VERSION_H != QSPI_IP_TYPES_SW_MAJOR_VERSION_CFG) || \
58      (QSPI_IP_HYPERFLASH_SW_MINOR_VERSION_H != QSPI_IP_TYPES_SW_MINOR_VERSION_CFG) || \
59      (QSPI_IP_HYPERFLASH_SW_PATCH_VERSION_H != QSPI_IP_TYPES_SW_PATCH_VERSION_CFG) \
60     )
61     #error "Software Version Numbers of Qspi_Ip_Hyperflash.h and Qspi_Ip_Types.h are different"
62 #endif
63 
64 /*******************************************************************************
65  * API
66  ******************************************************************************/
67 
68 #define MEM_43_EXFLS_START_SEC_CODE
69 #include "Mem_43_EXFLS_MemMap.h"
70 
71 
72 /*!
73  * @brief Initializes the hyper flash memory device
74  */
75 Qspi_Ip_StatusType Qspi_Ip_HyperflashInit(uint32 instance);
76 
77 
78 /*!
79  * @brief Erases a specific sector.
80  *
81  */
82 Qspi_Ip_StatusType Qspi_Ip_HyperflashSectorErase(uint32 instance,
83                                                  uint32 sectorAddress
84                                                 );
85 
86 
87 /*!
88  * @brief Chip erase
89  */
90 Qspi_Ip_StatusType Qspi_Ip_HyperflashChipErase(uint32 instance);
91 
92 
93 /*!
94  * @brief Writes between 1 and 512 bytes to write buffer. Addresses should be on the same line of data buffer.
95  */
96 Qspi_Ip_StatusType Qspi_Ip_HyperflashProgram(uint32 instance,
97                                              uint32 address,
98                                              const uint8 * data,
99                                              uint32 size
100                                             );
101 
102 
103 /*!
104  * @brief Read manufacturer ID from hyper flash.
105  */
106 Qspi_Ip_StatusType Qspi_Ip_HyperflashReadId(uint32 instance,
107                                             uint32 wordAddress,
108                                             uint8 * data,
109                                             uint32 size
110                                            );
111 
112 
113 /*!
114  * @brief Checks if the chip or a specific sector is erased
115  */
116 Qspi_Ip_StatusType Qspi_Ip_HyperflashSectorBlankCheck(uint32 instance,
117                                                       uint32 sectorAddress
118                                                      );
119 
120 
121 /*!
122  * @brief Returns the status of the last command
123  */
124 Qspi_Ip_StatusType Qspi_Ip_HyperflashGetMemoryStatus(uint32 instance);
125 
126 
127 /*!
128  * @brief Patch a read command with the configured dummy cycles count
129  */
130 void Qspi_Ip_HyperflashPatchReadCommand(uint32 instance,
131                                         uint16 lut
132                                        );
133 
134 
135 #define MEM_43_EXFLS_STOP_SEC_CODE
136 #include "Mem_43_EXFLS_MemMap.h"
137 
138 
139 #endif /* QSPI_IP_MEM_INSTANCE_COUNT */
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 /** @} */
146 #endif /* QSPI_IP_HYPERFLASH_H */
147 
148 /*******************************************************************************
149  * EOF
150  ******************************************************************************/
151 
152