1 /***************************************************************************//**
2 * \file cy_smif_memslot.h
3 * \version 2.100
4 *
5 * \brief
6 * This file provides the constants and parameter values for the memory-level
7 * APIs of the SMIF driver.
8 *
9 * Note:
10 *
11 ********************************************************************************
12 * \copyright
13 * Copyright 2016-2022 Cypress Semiconductor Corporation
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the "License");
17 * you may not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 *******************************************************************************/
28
29 #if !defined (CY_SMIF_MEMORYSLOT_H)
30 #define CY_SMIF_MEMORYSLOT_H
31
32 #include "cy_device.h"
33
34 #if defined (CY_IP_MXSMIF)
35
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include "cy_syslib.h"
39 #include "cy_smif.h"
40
41 #if defined(__cplusplus)
42 extern "C" {
43 #endif
44
45 /**
46 * \addtogroup group_smif_macros_status
47 * \{
48 */
49
50 /***************************************
51 * Constants
52 ****************************************/
53 #define CY_SMIF_DEVICE_BUSY (1U) /**< The external memory is busy */
54 #define CY_SMIF_DEVICE_READY (0U) /**< The external memory is ready */
55
56 /** \} group_smif_macros_status */
57
58 /**
59 * \addtogroup group_smif_macros_cmd
60 * \{
61 */
62 #define CY_SMIF_CMD_WITHOUT_PARAM (0U) /**< No parameter */
63 #define CY_SMIF_TX_LAST_BYTE (1U) /**< The last byte in the command transmission
64 * (SS is set high after the transmission)
65 */
66 #define CY_SMIF_TX_NOT_LAST_BYTE (0U) /**< Not the last byte in the command transmission
67 * (SS remains low after the transmission)
68 */
69 #define CY_SMIF_READ_ONE_BYTE (1U) /**< Read 1 byte */
70 #define CY_SMIF_WRITE_ONE_BYTE (1U) /**< Write 1 byte */
71 #define CY_SMIF_WRITE_TWO_BYTES (2U) /**< Write 2 bytes */
72 #define CY_SMIF_ONE_WORD (4U) /**< 4 bytes */
73
74 #define CY_SMIF_DUAL_QUAD_DISABLED (0U) /**< The dual quad transmission mode is disabled */
75 #define CY_SMIF_DUAL_QUAD_ENABLED (1U) /**< The dual quad transmission mode is enabled */
76
77
78 /** \} group_smif_macros_status */
79
80 /**
81 * \addtogroup group_smif_macros_flags
82 * \{
83 */
84
85 #define CY_SMIF_FLAG_ALL_DISABLED (0U) /**< All memory configuration flags are disabled */
86 /** Enables the write capability for the memory slave in the memory-mapped
87 * mode. Valid when the memory-mapped mode is enabled */
88 #define CY_SMIF_FLAG_WRITE_ENABLE (1U)
89 /** Determines if the device is memory-mapped. If enabled, this memory slot will
90 * be initialized in System init */
91 #define CY_SMIF_FLAG_MEMORY_MAPPED (2U)
92 #define CY_SMIF_FLAG_DETECT_SFDP (4U) /**< Enables the Autodetect using the SFDP */
93 /** Enables the crypto support for this memory slave. All access to the
94 * memory device goes through the encryption/decryption
95 * Valid when the memory-mapped mode is enabled */
96 #define CY_SMIF_FLAG_CRYPTO_ENABLE (8U)
97
98 #if (CY_IP_MXSMIF_VERSION>=2) || defined (CY_DOXYGEN)
99 /**
100 * \note
101 * This macro is available for CAT1B, CAT1C and CAT1D devices.
102 **/
103 /** Enables IP version 3 features such as octal SPI/DDR mode/ 2 byte addressing
104 */
105 #define CY_SMIF_FLAG_SMIF_REV_3 (16U)
106
107 /** Continuous transfer merge enable.
108 * This skips the overhead (command, address, mode, dummy cycles) for a continuous
109 * (linear sequential) transfer. */
110 #define CY_SMIF_FLAG_MERGE_ENABLE (32U)
111
112 #endif /* CY_IP_MXSMIF_VERSION */
113
114 /** \} group_smif_macros_flags */
115
116 /**
117 * \addtogroup group_smif_macros_sfdp
118 * \{
119 */
120
121 /***************************************
122 * SFDP constants
123 ****************************************/
124 #define CY_SMIF_SFDP_ADDRESS_LENGTH (0x03U) /**< The length of the SFDP address */
125 #define CY_SMIF_SFDP_PARAM_HEADER_LENGTH (0x8U) /**< The length of the Parameter header */
126 #define CY_SMIF_SFDP_PARAMETER_TABLE_LENGTH (0x80U) /**< The length of the Parameter table */
127 #define CY_SMIF_SFDP_LENGTH (CY_SMIF_SFDP_PARAMETER_TABLE_LENGTH) /**< The length of the SFDP */
128 #define CY_SMIF_SFDP_SIGNATURE_BYTE_00 (0x00U) /**< The SFDP Signature byte 0x00. Should be "S" */
129 #define CY_SMIF_SFDP_SIGNATURE_BYTE_01 (0x01U) /**< The SFDP Signature byte 0x01. Should be "F" */
130 #define CY_SMIF_SFDP_SIGNATURE_BYTE_02 (0x02U) /**< The SFDP Signature byte 0x02. Should be "D" */
131 #define CY_SMIF_SFDP_SIGNATURE_BYTE_03 (0x03U) /**< The SFDP Signature byte 0x03. Should be "P" */
132 #define CY_SMIF_SFDP_MINOR_REV (0x04U) /**< The SFDP Header byte 0x04. Defines the JEDEC JESD216 Revision */
133 #define CY_SMIF_SFDP_MAJOR_REV (0x05U) /**< The SFDP Header byte 0x05. Defines the SFDP Major Revision */
134 #define CY_SMIF_SFDP_MAJOR_REV_1 (0x01U) /**< The SFDP Major Revision is 1 */
135 #define CY_SMIF_SFDP_JEDEC_REV_0 (0x00U) /**< The JEDEC JESD216 Revision is 0 */
136 #define CY_SMIF_SFDP_JEDEC_REV_B (0x06U) /**< The JEDEC JESD216 Revision is B */
137 #define CY_SMIF_SFDP_PARAM_TABLE_PTR (0x0CU) /**< Specifies the start of the JEDEC Basic Flash
138 * Parameter Table in the SFDP structure
139 */
140 #define CY_SMIF_SFDP_THREE_BYTES_ADDR_CODE (0x00U) /**< Code for the SFDP Address Bytes Number 3 */
141 #define CY_SMIF_SFDP_THREE_OR_FOUR_BYTES_ADDR_CODE (0x01U) /**< Code for the SFDP Address Bytes Number 3 or 4 */
142 #define CY_SMIF_SFDP_FOUR_BYTES_ADDR_CODE (0x02U) /**< Code for the SFDP Address Bytes Number 4 */
143 #define CY_SMIF_THREE_BYTES_ADDR (0x03U) /**< The address Bytes Number is 3 */
144 #define CY_SMIF_FOUR_BYTES_ADDR (0x04U) /**< The address Bytes Number is 4 */
145 #define CY_SMIF_READ_MODE_BYTE (0x5AU) /**< The mode byte for the SMIF read */
146 #define CY_SMIF_WRITE_STATUS_REG1_CMD (0x01U) /**< The write status register 1 command */
147 #define CY_SMIF_SINGLE_PROGRAM_CMD (0x02U) /**< The command for a single SMIF program */
148 #define CY_SMIF_SINGLE_READ_CMD (0x03U) /**< The command for a single SMIF read */
149 #define CY_SMIF_WRITE_DISABLE_CMD (0x04U) /**< The Write Disable command */
150 #define CY_SMIF_READ_STATUS_REG1_CMD (0x05U) /**< The read status register 1 command */
151 #define CY_SMIF_WRITE_ENABLE_CMD (0x06U) /**< The Write Enable command */
152 #define CY_SMIF_READ_STATUS_REG2_T1_CMD (0x35U) /**< The read status register 2 type 1 command */
153 #define CY_SMIF_WRITE_STATUS_REG2_T1_CMD (0x3EU) /**< The write status register 2 type 1 command */
154 #define CY_SMIF_WRITE_STATUS_REG2_T2_CMD (0x31U) /**< The write status register 2 type 2 command */
155 #define CY_SMIF_READ_STATUS_REG2_T2_CMD (0x3FU) /**< The read status register 2 type 2 command */
156 #define CY_SMIF_CHIP_ERASE_CMD (0x60U) /**< The Chip Erase command */
157 #define CY_SMIF_POWER_DOWN_CMD (0xB9U) /**< The Power-down command */
158 #define CY_SMIF_RELEASE_POWER_DOWN_CMD (0xABU) /**< The Release Power-down command */
159 #define CY_SMIF_QE_BIT_STATUS_REG2_T1 (0x02U) /**< The QE bit is in status register 2 type 1.
160 * It should be written as the second byte.
161 */
162 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_1S_1S (0x0CU) /**< The command for a 1S-1S-1S SMIF fast read with 4-byte addressing */
163 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_1S_2S (0x3CU) /**< The command for a 1S-1S-2S SMIF fast read with 4-byte addressing */
164 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_2S_2S (0xBCU) /**< The command for a 1S-2S-2S SMIF fast read with 4-byte addressing */
165 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_1S_4S (0x6CU) /**< The command for a 1S-1S-4S SMIF fast read with 4-byte addressing */
166 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_4S_4S (0xECU) /**< The command for a 1S-4S-4S SMIF fast read with 4-byte addressing */
167 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_1S_8S (0x7CU) /**< The command for a 1S-1S-8S SMIF fast read with 4-byte addressing */
168 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_8S_8S (0xCCU) /**< The command for a 1S-8S-8S SMIF fast read with 4-byte addressing */
169
170 #if (CY_IP_MXSMIF_VERSION>=2) || defined (CY_DOXYGEN)
171 /**
172 * \note
173 * This macro is available for CAT1B, CAT1C and CAT1D devices.
174 **/
175 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_4D_4D (0xEEU) /**< The command for a 1S-4D-4D SMIF fast read with 4-byte addressing */
176 #define CY_SMIF_FAST_READ_4_BYTES_CMD_1S_8D_8D (0xFDU) /**< The command for a 1S-8D-8D SMIF fast read with 4-byte addressing */
177 #endif /* CY_IP_MXSMIF_VERSION */
178
179 #define CY_SMIF_PAGE_PROGRAM_4_BYTES_CMD_1S_1S_1S (0x12U) /**< The command for a 1S-1S-1S SMIF page program with 4-byte addressing */
180 #define CY_SMIF_PAGE_PROGRAM_4_BYTES_CMD_1S_1S_4S (0x34U) /**< The command for a 1S-1S-4S SMIF page program with 4-byte addressing */
181 #define CY_SMIF_PAGE_PROGRAM_4_BYTES_CMD_1S_4S_4S (0x3EU) /**< The command for a 1S-4S-4S SMIF page program with 4-byte addressing */
182 #define CY_SMIF_PAGE_PROGRAM_4_BYTES_CMD_1S_1S_8S (0x84U) /**< The command for a 1S-1S-8S SMIF page program with 4-byte addressing */
183 #define CY_SMIF_PAGE_PROGRAM_4_BYTES_CMD_1S_8S_8S (0x8EU) /**< The command for a 1S-8S-8S SMIF page program with 4-byte addressing */
184
185 #define CY_SMIF_BRWR_EXTADD_MASK (0x80U) /**< The Extended Address Enable (EXTADD) mask */
186
187 #define CY_SMIF_SFDP_ERASE_TIME_1MS (1U) /**< Units of Erase Typical Time in ms */
188 #define CY_SMIF_SFDP_ERASE_TIME_16MS (16U) /**< Units of Erase Typical Time in ms */
189 #define CY_SMIF_SFDP_ERASE_TIME_128MS (128U) /**< Units of Erase Typical Time in ms */
190 #define CY_SMIF_SFDP_ERASE_TIME_1S (1000U) /**< Units of Erase Typical Time in ms */
191
192 #define CY_SMIF_SFDP_CHIP_ERASE_TIME_16MS (16U) /**< Units of Chip Erase Typical Time in ms */
193 #define CY_SMIF_SFDP_CHIP_ERASE_TIME_256MS (256U) /**< Units of Chip Erase Typical Time in ms */
194 #define CY_SMIF_SFDP_CHIP_ERASE_TIME_4S (4000U) /**< Units of Chip Erase Typical Time in ms */
195 #define CY_SMIF_SFDP_CHIP_ERASE_TIME_64S (64000U) /**< Units of Chip Erase Typical Time in ms */
196
197 #define CY_SMIF_SFDP_PROG_TIME_8US (8U) /**< Units of Page Program Typical Time in us */
198 #define CY_SMIF_SFDP_PROG_TIME_64US (64U) /**< Units of Page Program Typical Time in us */
199
200 #define CY_SMIF_SFDP_PROG_TIME_DEFAULT (100000U) /**< Default Page Program Time in us - 100 ms */
201 #define CY_SMIF_SFDP_PAGE_SIZE_DEFAULT (256U) /**< Default Page size used for SFDP 1.0 devices */
202
203 #define CY_SMIF_SFDP_UNIT_0 (0U) /**< Units of Basic Flash Parameter Table Time Parameters */
204 #define CY_SMIF_SFDP_UNIT_1 (1U) /**< Units of Basic Flash Parameter Table Time Parameters */
205 #define CY_SMIF_SFDP_UNIT_2 (2U) /**< Units of Basic Flash Parameter Table Time Parameters */
206 #define CY_SMIF_SFDP_UNIT_3 (3U) /**< Units of Basic Flash Parameter Table Time Parameters */
207
208
209 #define CY_SMIF_STATUS_REG_BUSY_MASK (0x01U) /**< The busy mask for the status registers */
210 #define CY_SMIF_NO_COMMAND_OR_MODE (0xFFFFFFFFUL) /**< No command or mode present */
211 #define CY_SMIF_SFDP_QE_BIT_1_OF_SR_2 (0x02UL) /**< The QE is bit 1 of the status register 2 */
212 #define CY_SMIF_SFDP_QE_BIT_6_OF_SR_1 (0x40UL) /**< The QE is bit 6 of the status register 1 */
213 #define CY_SMIF_SFDP_QE_BIT_7_OF_SR_2 (0x80UL) /**< The QE is bit 7 of the status register 2 */
214 #define CY_SMIF_SFDP_BFPT_BYTE_02 (0x02U) /**< The byte 0x02 of the JEDEC Basic Flash Parameter Table */
215 #define CY_SMIF_SFDP_BFPT_BYTE_04 (0x04U) /**< The byte 0x04 of the JEDEC Basic Flash Parameter Table */
216 #define CY_SMIF_SFDP_BFPT_BYTE_05 (0x05U) /**< The byte 0x05 of the JEDEC Basic Flash Parameter Table */
217 #define CY_SMIF_SFDP_BFPT_BYTE_06 (0x06U) /**< The byte 0x06 of the JEDEC Basic Flash Parameter Table:
218 * number of Parameter Headers (zero based, 05h = 6 parameters)
219 */
220 #define CY_SMIF_SFDP_BFPT_BYTE_08 (0x08U) /**< The byte 0x08 of the JEDEC Basic Flash Parameter Table */
221 #define CY_SMIF_SFDP_BFPT_BYTE_09 (0x09U) /**< The byte 0x09 of the JEDEC Basic Flash Parameter Table */
222 #define CY_SMIF_SFDP_BFPT_BYTE_0A (0x0AU) /**< The byte 0x0A of the JEDEC Basic Flash Parameter Table */
223 #define CY_SMIF_SFDP_BFPT_BYTE_0B (0x0BU) /**< The byte 0x0B of the JEDEC Basic Flash Parameter Table */
224 #define CY_SMIF_SFDP_BFPT_BYTE_0C (0x0CU) /**< The byte 0x0C of the JEDEC Basic Flash Parameter Table */
225 #define CY_SMIF_SFDP_BFPT_BYTE_0D (0x0DU) /**< The byte 0x0D of the JEDEC Basic Flash Parameter Table */
226 #define CY_SMIF_SFDP_BFPT_BYTE_0E (0x0EU) /**< The byte 0x0E of the JEDEC Basic Flash Parameter Table */
227 #define CY_SMIF_SFDP_BFPT_BYTE_0F (0x0FU) /**< The byte 0x0F of the JEDEC Basic Flash Parameter Table */
228 #define CY_SMIF_SFDP_BFPT_BYTE_1C (0x1CU) /**< The byte 0x1C of the JEDEC Basic Flash Parameter Table */
229 #define CY_SMIF_SFDP_BFPT_BYTE_1D (0x1DU) /**< The byte 0x1D of the JEDEC Basic Flash Parameter Table */
230 #define CY_SMIF_SFDP_BFPT_BYTE_23 (0x23U) /**< The byte 0x23 of the JEDEC Basic Flash Parameter Table */
231 #define CY_SMIF_SFDP_BFPT_BYTE_28 (0x28U) /**< The byte 0x28 of the JEDEC Basic Flash Parameter Table */
232 #define CY_SMIF_SFDP_BFPT_BYTE_3A (0x3AU) /**< The byte 0x3A of the JEDEC Basic Flash Parameter Table */
233 #define CY_SMIF_SFDP_BFPT_BYTE_3C (0x3CU) /**< The byte 0x3C of the JEDEC Basic Flash Parameter Table */
234 #define CY_SMIF_SFDP_BFPT_BYTE_3F (0x3FU) /**< The byte 0x3F of the JEDEC Basic Flash Parameter Table */
235 #define CY_SMIF_SFDP_BFPT_BYTE_40 (0x40U) /**< The byte 0x40 of the JEDEC Basic Flash Parameter Table */
236 #define CY_SMIF_SFDP_BFPT_BYTE_41 (0x41U) /**< The byte 0x41 of the JEDEC Basic Flash Parameter Table */
237 #define CY_SMIF_SFDP_BFPT_BYTE_42 (0x42U) /**< The byte 0x42 of the JEDEC Basic Flash Parameter Table */
238 #define CY_SMIF_SFDP_BFPT_BYTE_43 (0x43U) /**< The byte 0x43 of the JEDEC Basic Flash Parameter Table */
239
240 #define CY_SMIF_SFDP_BFPT_ERASE_BYTE (36U) /**< The byte 36 of the JEDEC Basic Flash Parameter Table */
241
242 #define CY_SMIF_JEDEC_BFPT_10TH_DWORD (9U) /**< Offset to JEDEC Basic Flash Parameter Table: 10th DWORD */
243 #define CY_SMIF_JEDEC_BFPT_11TH_DWORD (10U) /**< Offset to JEDEC Basic Flash Parameter Table: 11th DWORD */
244
245 #define CY_SMIF_SFDP_SCCR_MAP_BYTE_3B (0x3BU) /**< DWORD-16 of SCCR Map SPI table */
246 #define CY_SMIF_SFDP_OCTAL_ENABLE_WRITE_CMD_Pos (0U) /**< SCCR Map DWORD-16 Octal mode enable write command position */
247 #define CY_SMIF_SFDP_OCTAL_ENABLE_WRITE_CMD_Msk (0xFFU) /**< SCCR Map DWORD-16 Octal mode enable write command mask */
248 #define CY_SMIF_SFDP_OCTAL_ENABLE_READ_CMD_Pos (8U) /**< SCCR Map DWORD-16 Octal mode enable read command position */
249 #define CY_SMIF_SFDP_OCTAL_ENABLE_READ_CMD_Msk (0xFF00U) /**< SCCR Map DWORD-16 Octal mode enable read command mask */
250 #define CY_SMIF_SFDP_OCTAL_ENABLE_REG_ADDR_Pos (16U) /**< SCCR Map DWORD-16 Octal mode enable register address position */
251 #define CY_SMIF_SFDP_OCTAL_ENABLE_REG_ADDR_Msk (0xFF0000U) /**< SCCR Map DWORD-16 Octal mode enable register address mask */
252 #define CY_SMIF_SFDP_OCTAL_ENABLE_BIT_Pos (24U) /**< SCCR Map DWORD-16 Octal mode enable bit position */
253 #define CY_SMIF_SFDP_OCTAL_ENABLE_BIT_Msk (0x7000000U) /**< SCCR Map DWORD-16 Octal mode enable bit mask */
254 #define CY_SMIF_SFDP_OCTAL_ENABLE_USE_ADDRESS_Pos (28U) /**< SCCR Map DWORD-16 Octal mode enable uses address to set/clear position */
255 #define CY_SMIF_SFDP_OCTAL_ENABLE_USE_ADDRESS_Msk (0x10000000U) /**< SCCR Map DWORD-16 Octal mode enable uses address to set/clear mask */
256 #define CY_SMIF_SFDP_OCTAL_ENABLE_BIT_SUPPORT_Pos (31U) /**< SCCR Map DWORD-16 Octal mode enable bit support position */
257 #define CY_SMIF_SFDP_OCTAL_ENABLE_BIT_SUPPORT_Msk (0x80000000U) /**< SCCR Map DWORD-16 Octal mode enable bit support mask */
258
259 #define CY_SMIF_SFDP_SECTOR_MAP_CMD_OFFSET (1UL) /**< The offset for the detection command instruction in the Sector Map command descriptor */
260 #define CY_SMIF_SFDP_SECTOR_MAP_ADDR_LEN_OFFSET (2UL) /**< The offset for the detection command address length in the Sector Map command descriptor */
261 #define CY_SMIF_SFDP_SECTOR_MAP_REG_MSK_OFFSET (3UL) /**< The offset for the read data mask in the Sector Map command descriptor */
262 #define CY_SMIF_SFDP_SECTOR_MAP_REG_ADDR_OFFSET (4UL) /**< The offset for the detection command address in the Sector Map command descriptor */
263 #define CY_SMIF_SFDP_SECTOR_MAP_REGION_COUNT_OFFSET (2UL) /**< The offset for the regions count in the Sector Map descriptor */
264 #define CY_SMIF_SFDP_SECTOR_MAP_CONFIG_ID_OFFSET (2UL) /**< The offset for the configuration ID in the Sector Map descriptor */
265 #define CY_SMIF_SFDP_SECTOR_MAP_SUPPORTED_ET_MASK (0xFU) /**< The mask for the supported erase type code in the Sector Map descriptor */
266 #define CY_SMIF_SFDP_SECTOR_MAP_ADDR_BYTES_Msk (0xC0UL) /**< The mask for the configuration detection command address bytes in the Sector Map descriptor */
267 #define CY_SMIF_SFDP_SECTOR_MAP_ADDR_BYTES_Pos (6UL) /**< The position of the configuration detection command address bytes in the Sector Map descriptor */
268 #define CY_SMIF_SFDP_SECTOR_MAP_DUMMY_CYCLES_Msk (0xFUL) /**< The mask for the configuration detection command read latency cycles in the Sector Map descriptor */
269 #define CY_SMIF_SFDP_SECTOR_MAP_DUMMY_CYCLES_Pos (0UL) /**< The position of the configuration detection command read latency cycles in the Sector Map descriptor */
270
271 #define FOUR_BYTE_ADDRESS_TABLE_BYTE_0 (0U) /**< Byte 0x00 of the JEDEC 4-byte Address Instruction Table */
272 #define FOUR_BYTE_ADDRESS_TABLE_BYTE_1 (1U) /**< Byte 0x01 of the JEDEC 4-byte Address Instruction Table */
273
274
275 /* ---------------------------- 1st DWORD ---------------------------- */
276 #define CY_SMIF_SFDP_FAST_READ_1_1_4_Pos (6UL) /**< The SFDP 1-1-4 fast read support (Bit 6) */
277 #define CY_SMIF_SFDP_FAST_READ_1_1_4_Msk (0x40UL) /**< The SFDP 1-1-4 fast read support (Bitfield-Mask: 0x01) */
278 #define CY_SMIF_SFDP_FAST_READ_1_4_4_Pos (5UL) /**< The SFDP 1-4-4 fast read support (Bit 5) */
279 #define CY_SMIF_SFDP_FAST_READ_1_4_4_Msk (0x20UL) /**< The SFDP 1-4-4 fast read support (Bitfield-Mask: 0x01) */
280 #define CY_SMIF_SFDP_FAST_READ_1_2_2_Pos (4UL) /**< The SFDP 1-2-2 fast read support (Bit 4) */
281 #define CY_SMIF_SFDP_FAST_READ_1_2_2_Msk (0x10UL) /**< The SFDP 1-2-2 fast read support (Bitfield-Mask: 0x01) */
282
283 #if (CY_IP_MXSMIF_VERSION>=2) || defined (CY_DOXYGEN)
284 /**
285 * \note
286 * This macro is available for CAT1B, CAT1C and CAT1D devices.
287 **/
288 #define CY_SMIF_SFDP_DTR_SUPPORT_Pos (3UL) /**< The SFDP DTR support (Bit 3) */
289 /**
290 * \note
291 * This macro is available for CAT1B, CAT1C and CAT1D devices.
292 **/
293 #define CY_SMIF_SFDP_DTR_SUPPORT_Msk (0x08UL) /**< The SFDP DTR support (Bitfield-Mask: 0x08) */
294 #endif /* CY_IP_MXSMIF_VERSION */
295
296 #define CY_SMIF_SFDP_ADDRESS_BYTES_Pos (1UL) /**< The SFDP number of address bytes (Bit 1) */
297 #define CY_SMIF_SFDP_ADDRESS_BYTES_Msk (0x06UL) /**< The SFDP number of address bytes (Bitfield-Mask: 0x03) */
298 #define CY_SMIF_SFDP_FAST_READ_1_1_2_Pos (0UL) /**< The SFDP 1-1-2 fast read support (Bit 0) */
299 #define CY_SMIF_SFDP_FAST_READ_1_1_2_Msk (0x01UL) /**< The SFDP 1-1-2 fast read support (Bitfield-Mask: 0x01) */
300
301 /* ---------------------------- 2nd DWORD ---------------------------- */
302 #define CY_SMIF_SFDP_SIZE_ABOVE_4GB_Msk (0x80000000UL) /**< Flash memory density bit define if it >= 4 Gbit or <= 2Gbit */
303
304 /* ---------------------------- 3rd DWORD ---------------------------- */
305 #define CY_SMIF_SFDP_1_4_4_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1-4-4 fast read dummy cycles (Bit 0) */
306 #define CY_SMIF_SFDP_1_4_4_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1-4-4 fast read dummy cycles (Bitfield-Mask: 0x1F) */
307 #define CY_SMIF_SFDP_1_4_4_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1-4-4 fast read mode cycles (Bit 5) */
308 #define CY_SMIF_SFDP_1_4_4_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1-4-4 fast read mode cycles (Bitfield-Mask: 0x07) */
309 #define CY_SMIF_SFDP_1_1_4_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1-1-4 fast read dummy cycles (Bit 0) */
310 #define CY_SMIF_SFDP_1_1_4_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1-1-4 fast read dummy cycles (Bitfield-Mask: 0x1F) */
311 #define CY_SMIF_SFDP_1_1_4_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1-1-4 fast read mode cycles (Bit 5) */
312 #define CY_SMIF_SFDP_1_1_4_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1-1-4 fast read mode cycles (Bitfield-Mask: 0x07) */
313
314 /* ---------------------------- 4th DWORD ---------------------------- */
315 #define CY_SMIF_SFDP_1_1_2_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1_1_2 fast read dummy cycles (Bit 0) */
316 #define CY_SMIF_SFDP_1_1_2_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1_1_2 fast read dummy cycles (Bitfield-Mask: 0x1F) */
317 #define CY_SMIF_SFDP_1_1_2_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1_1_2 fast read mode cycles (Bit 5) */
318 #define CY_SMIF_SFDP_1_1_2_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1_1_2 fast read mode cycles (Bitfield-Mask: 0x07) */
319 #define CY_SMIF_SFDP_1_2_2_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1_2_2 fast read dummy cycles (Bit 0) */
320 #define CY_SMIF_SFDP_1_2_2_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1_2_2 fast read dummy cycles (Bitfield-Mask: 0x1F) */
321 #define CY_SMIF_SFDP_1_2_2_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1_2_2 fast read mode cycles (Bit 5) */
322 #define CY_SMIF_SFDP_1_2_2_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1_2_2 fast read mode cycles (Bitfield-Mask: 0x07) */
323
324 /* ---------------------------- 10th DWORD --------------------------- */
325 #define CY_SMIF_SFDP_ERASE_T1_COUNT_Pos (4UL) /**< Erase Type 1 Erase, Typical time: count (Bits 8:4) */
326 #define CY_SMIF_SFDP_ERASE_T1_COUNT_Msk (0x1F0UL) /**< Erase Type 1 Erase, Typical time: count (Bitfield-Mask ) */
327 #define CY_SMIF_SFDP_ERASE_T1_UNITS_Pos (9UL) /**< Erase Type 1 Erase, Typical time: units (Bits 10:9) */
328 #define CY_SMIF_SFDP_ERASE_T1_UNITS_Msk (0x600UL) /**< Erase Type 1 Erase, Typical time: units (Bitfield-Mask ) */
329 #define CY_SMIF_SFDP_ERASE_MUL_COUNT_Pos (0UL) /**< Multiplier from typical erase time to maximum erase time (Bits 3:0) */
330 #define CY_SMIF_SFDP_ERASE_MUL_COUNT_Msk (0x0FUL) /**< Multiplier from typical erase time to maximum erase time (Bitfield-Mask ) */
331
332
333 /* ---------------------------- 11th DWORD --------------------------- */
334 #define CY_SMIF_SFDP_PAGE_SIZE_Pos (4UL) /**< The SFDP page size (Bit 4) */
335 #define CY_SMIF_SFDP_PAGE_SIZE_Msk (0xF0UL) /**< The SFDP page size (Bitfield-Mask: 0x0F) */
336 #define CY_SMIF_SFDP_PAGE_PROG_COUNT_Pos (8UL) /**< The SFDP Chip Page Program Typical time: count (Bits 12:8) */
337 #define CY_SMIF_SFDP_PAGE_PROG_COUNT_Msk (0x1F00UL) /**< The SFDP Chip Page Program Typical time: count (Bitfield-Mask)*/
338 #define CY_SMIF_SFDP_PAGE_PROG_UNITS_Pos (13UL) /**< The SFDP Chip Page Program Typical time: units (Bit 13) */
339 #define CY_SMIF_SFDP_PAGE_PROG_UNITS_Msk (0x2000UL) /**< The SFDP Chip Page Program Typical time: units (Bitfield-Mask)*/
340 #define CY_SMIF_SFDP_CHIP_ERASE_COUNT_Pos (24UL) /**< The SFDP Chip Erase Typical time: count (Bits 28:24) */
341 #define CY_SMIF_SFDP_CHIP_ERASE_COUNT_Msk (0x1F000000UL) /**< The SFDP Chip Erase Typical time: count (Bitfield-Mask) */
342 #define CY_SMIF_SFDP_CHIP_ERASE_UNITS_Pos (29UL) /**< The SFDP Chip Erase Typical time: units (Bits 29:30) */
343 #define CY_SMIF_SFDP_CHIP_ERASE_UNITS_Msk (0x60000000UL) /**< The SFDP Chip Erase Typical time: units (Bitfield-Mask) */
344 #define CY_SMIF_SFDP_PROG_MUL_COUNT_Pos (0UL) /**< Multiplier from typical time to max time for Page or byte program (Bits 3:0) */
345 #define CY_SMIF_SFDP_PROG_MUL_COUNT_Msk (0x0FUL) /**< Multiplier from typical time to max time for Page or byte program (Bitfield-Mask) */
346
347 /* ---------------------------- 15th DWORD --------------------------- */
348 #define CY_SMIF_SFDP_QE_REQUIREMENTS_Pos (4UL) /**< The SFDP quad enable requirements field (Bit 4) */
349 #define CY_SMIF_SFDP_QE_REQUIREMENTS_Msk (0x70UL) /**< The SFDP quad enable requirements field (Bitfield-Mask: 0x07) */
350
351
352 /* ---------------------------- 16th DWORD --------------------------- */
353 #define CY_SMIF_SFDP_ENTER_4_BYTE_METHOD_B7 (1U) /**< Issue 0xB7 instruction */
354 #define CY_SMIF_SFDP_ENTER_4_BYTE_METHOD_WR_EN_B7 (2U) /**< Issue write enable instruction followed with 0xB7 */
355 #define CY_SMIF_SFDP_ENTER_4_BYTE_METHOD_ALWAYS_4_BYTE (0x40U) /**< Memory always operates in 4-byte mode */
356 #define CY_SMIF_SFDP_ENTER_4_BYTE_METHOD_B7_CMD (0xB7U) /**< The instruction required to enter 4-byte addressing mode */
357 #define CY_SMIF_SFDP_ENTER_4_BYTE_METHOD_SUPPORTED_MASK (0x7FU) /**< Mask indicating 4-byte address mode entry supported */
358
359 /* ---------------------------- 17th DWORD --------------------------- */
360 #define CY_SMIF_SFDP_FAST_READ_1_1_8_Pos (0UL) /**< The SFDP 1-1-8 fast read support (Bitfield 24:31) */
361 #define CY_SMIF_SFDP_FAST_READ_1_1_8_Msk (0xFFUL) /**< The SFDP 1-1-8 fast read support (Bitfield-Mask: 0xFF) */
362 #define CY_SMIF_SFDP_1_1_8_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1-1-8 fast read mode cycles (Bitfield 21:23) */
363 #define CY_SMIF_SFDP_1_1_8_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1-1-8 fast read mode cycles (Bitfield-Mask: 0xE) */
364 #define CY_SMIF_SFDP_1_1_8_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1_1_8 fast read dummy cycles (Bit 16:19) */
365 #define CY_SMIF_SFDP_1_1_8_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1_1_8 fast read dummy cycles (Bitfield-Mask: 0x1F) */
366 #define CY_SMIF_SFDP_FAST_READ_1_8_8_Pos (0UL) /**< The SFDP 1-8-8 fast read support (Bitfield 8:15) */
367 #define CY_SMIF_SFDP_FAST_READ_1_8_8_Msk (0xFFUL) /**< The SFDP 1-8-8 fast read support (Bitfield-Mask: 0xFF) */
368 #define CY_SMIF_SFDP_1_8_8_MODE_CYCLES_Pos (5UL) /**< The SFDP number of 1-8-8 fast read mode cycles (Bitfield 5:7) */
369 #define CY_SMIF_SFDP_1_8_8_MODE_CYCLES_Msk (0xE0UL) /**< The SFDP number of 1-8-8 fast read mode cycles (Bitfield-Mask: 0xE) */
370 #define CY_SMIF_SFDP_1_8_8_DUMMY_CYCLES_Pos (0UL) /**< The SFDP number of 1_8_8 fast read dummy cycles (Bit 0:4) */
371 #define CY_SMIF_SFDP_1_8_8_DUMMY_CYCLES_Msk (0x1FUL) /**< The SFDP number of 1_8_8 fast read dummy cycles (Bitfield-Mask: 0x1F) */
372
373 /* ---------------------------- 19th DWORD --------------------------- */
374 #define CY_SMIF_SFDP_OCTAL_ENABE_BIT_Pos (20UL) /**< Octal Enable bit present in the flash or not (Bitfiled 20:22)*/
375 #define CY_SMIF_SFDP_OCTAL_ENABE_BIT_Msk (0x700000) /**< Octal Enable bit present Mask (Bitfiled-Mask 0x7)*/
376
377 /* ---------------------------- xSPI Profile 1.0 ------------------------ */
378 #define XSPI_PROFILE_1_TABLE_BYTE_0 (0U) /**< Byte 0x00 of the JEDEC xSPI Profile 1.0 */
379 #define XSPI_PROFILE_1_TABLE_BYTE_1 (1U) /**< Byte 0x01 of the JEDEC xSPI Profile 1.0 */
380 #define XSPI_PROFILE_1_TABLE_BYTE_16 (0x10U) /**< DWORD 5 => Byte 16 of the JEDEC xSPI Profile 1.0 */
381
382 /* ---------------------------- 1st DWORD --------------------------- */
383 #define CY_SMIF_SFDP_OCTAL_DDR_READ_CMD_Pos (0UL) /**< Octal DDR 8D-8D-8D read command support position (Bitfield 8:15) */
384 #define CY_SMIF_SFDP_OCTAL_DDR_READ_CMD_Msk (0xFFUL) /**< Octal DDR 8D-8D-8D read command support Mask Bitfield-Mask: 0xFF00) */
385 #define CY_SMIF_SFDP_ODDR_166MHZ_DUMMY_CYCLES_Pos (27UL) /**< Octal DDR 8D-8D-8D dummy cycles for 166 Mhz (Bitfield 27:31) */
386 #define CY_SMIF_SFDP_ODDR_166MHZ_DUMMY_CYCLES_Msk (0xF8000000UL) /**< Octal DDR 8D-8D-8D dummy cycles for 166 Mhz Mask */
387 #define CY_SMIF_SFDP_ODDR_200MHZ_DUMMY_CYCLES_Pos (7UL) /**< Octal DDR 8D-8D-8D dummy cycles for 200 Mhz (Bitfield 7:11) */
388 #define CY_SMIF_SFDP_ODDR_200MHZ_DUMMY_CYCLES_Msk (0xF80UL) /**< Octal DDR 8D-8D-8D dummy cycles for 200 Mhz Mask */
389
390 /* ---------------------------- Command Sequence to Change to Octal DDR ------------------------ */
391 #define CMD_SEQ_OCTAL_DDR_CMD1_LEN_BYTE_OFFSET (3U) /**< Octal DDR enable command 1 sequence length byte offset */
392 #define CMD_SEQ_OCTAL_DDR_CMD2_LEN_BYTE_OFFSET (11U) /**< Octal DDR enable command 1 sequence length byte offset */
393 #define CY_SMIF_SFDP_ODDR_CMD_SEQ_MAX_LEN (8U) /**< Octal DDR enable command sequence maximum length */
394
395 /* --------------------------------- HyperBus Macros ------------------------------------------- */
396 #if (CY_IP_MXSMIF_VERSION>=2)
397 /** Following Hyperbus commands are to be used in a sequence as specified in the Hyper Flash/RAM data sheet.
398 Please check the Command Summery section in the respective data sheet for the sequence to be followed. */
399 /** LLD Command Definition */
400 #define CY_SMIF_NOR_CFI_QUERY_CMD (0x98) /**< HyperBus NOR CFI Query Command */
401 #define CY_SMIF_NOR_CHIP_ERASE_CMD (0x10) /**< HyperBus NOR Chip Erase Command */
402 #define CY_SMIF_NOR_ERASE_SETUP_CMD (0x80) /**< HyperBus NOR Erase Setup Command */
403 #define CY_SMIF_NOR_RESET_CMD (0xF0) /**< HyperBus NOR Reset Command */
404 #define CY_SMIF_NOR_SECSI_SECTOR_ENTRY_CMD (0x88) /**< HyperBus NOR SECI Sector Entry Command */
405 #define CY_SMIF_NOR_SECTOR_ERASE_CMD (0x30) /**< HyperBus NOR Sector Erase Command */
406 #define CY_SMIF_NOR_WRITE_BUFFER_LOAD_CMD (0x25) /**< HyperBus NOR Write Buffer load Command */
407 #define CY_SMIF_NOR_WRITE_BUFFER_PGM_CONFIRM_CMD (0x29) /**< HyperBus NOR Write Buffer Program Confirm Command */
408 #define CY_SMIF_NOR_SET_CONFIG_CMD (0xD0) /**< HyperBus NOR Set Config Command */
409 #define CY_SMIF_NOR_BIT_FIELD_CMD (0xBF) /**< HyperBus NOR Bit Field Command */
410
411 #define CY_SMIF_NOR_ERASE_SUSPEND_CMD (0xB0) /**< HyperBus NOR Erase Suspend Command */
412 #define CY_SMIF_NOR_ERASE_RESUME_CMD (0x30) /**< HyperBus NOR Erase Resume Command */
413 #define CY_SMIF_NOR_PROGRAM_SUSPEND_CMD (0x51) /**< HyperBus NOR Program Suspend Command */
414 #define CY_SMIF_NOR_PROGRAM_RESUME_CMD (0x50) /**< HyperBus NOR Program Resume Command */
415 #define CY_SMIF_NOR_STATUS_REG_READ_CMD (0x70) /**< HyperBus NOR Status Register Read Command */
416 #define CY_SMIF_NOR_STATUS_REG_CLEAR_CMD (0x71) /**< HyperBus NOR Status Register Clear Command */
417 #define CY_SMIF_NOR_BLANK_CHECK_CMD (0x33) /**< HyperBus NOR Blank Check Command */
418
419 #define CY_SMIF_ENTER_SPI_MODE_CMD (0xF5) /**< HyperBus NOR Enter SPI Mode Command */
420
421 /** Command code definition */
422 #define CY_SMIF_NOR_AUTOSELECT_CMD (0x90) /**< HyperBus NOR Auto Select Command */
423 #define CY_SMIF_NOR_PROGRAM_CMD (0xA0) /**< HyperBus NOR Program Command */
424 #define CY_SMIF_NOR_SECSI_SECTOR_EXIT_SETUP_CMD (0x90) /**< HyperBus NOR SECSI Sector Exit Setup Command */
425 #define CY_SMIF_NOR_SECSI_SECTOR_EXIT_CMD (0x00) /**< HyperBus NOR SECSI Sector Exit Command */
426 #define CY_SMIF_NOR_UNLOCK_BYPASS_ENTRY_CMD (0x20) /**< HyperBus NOR Unlock Bypass Entry Command */
427 #define CY_SMIF_NOR_UNLOCK_BYPASS_PROGRAM_CMD (0xA0) /**< HyperBus NOR Unlock Bypass Program Command */
428 #define CY_SMIF_NOR_UNLOCK_BYPASS_RESET_CMD1 (0x90) /**< HyperBus NOR Unlock Bypass Reset Command One */
429 #define CY_SMIF_NOR_UNLOCK_BYPASS_RESET_CMD2 (0x00) /**< HyperBus NOR Unlock Bypass Reset Command Two*/
430 #define CY_SMIF_NOR_UNLOCK_DATA1 (0xAA) /**< HyperBus NOR Unlock Data One */
431 #define CY_SMIF_NOR_UNLOCK_DATA2 (0x55) /**< HyperBus NOR Unlock Data Two */
432 #define CY_SMIF_NOR_SUSPEND_CMD (0xB0) /**< HyperBus NOR Suspend Command */
433 #define CY_SMIF_NOR_RESUME_CMD (0x30) /**< HyperBus NOR Resume Command */
434 #define CY_SMIF_NOR_READ_CONFIG_CMD (0xC6) /**< HyperBus NOR Read Config Command */
435 #define CY_SMIF_NOR_WRITE_BUFFER_ABORT_RESET_CMD (0xF0) /**< HyperBus NOR Write Buffer Abort Reset Command */
436
437 /** ---------------------------- Hyperbus Devise status register information -------------------- */
438
439 #define CY_SMIF_DEV_RDY_MASK (0x80) /**< Device Ready Bit */
440 #define CY_SMIF_DEV_ERASE_SUSP_MASK (0x40) /**< Erase Suspend Bit */
441 #define CY_SMIF_DEV_ERASE_MASK (0x20) /**< Erase Status Bit */
442 #define CY_SMIF_DEV_PROGRAM_MASK (0x10) /**< Program Status Bit */
443 #define CY_SMIF_DEV_RFU_MASK (0x08) /**< Reserved */
444 #define CY_SMIF_DEV_PROGRAM_SUSP_MASK (0x04) /**< Program Suspend Bit */
445 #define CY_SMIF_DEV_SEC_LOCK_MASK (0x02) /**< Sector lock Bit */
446 #define CY_SMIF_DEV_BANK_MASK (0x01) /**< Operation in current bank */
447 #define CY_SMIF_DEV_CRCSSB_MASK (0x0100) /**< CRC Suspend Bit, 1: suspend, 0: no suspend*/
448 #define CY_SMIF_DEV_ESTAT_MASK (0x01) /**< Sector Erase Status Bit (for Evaluate Erase Status)*/
449 /**<0=previous erase did not complete successfully*/
450 /**<1=previous erase completed successfully*/
451
452
453 #define CY_SMIF_HB_FLASH_UNLOCK_ADDR1 0x00000555 /**< HyperBus Unlock Address One */
454 #define CY_SMIF_HB_FLASH_UNLOCK_ADDR2 0x000002AA /**< HyperBus Unlock Address Two */
455 #define CY_SMIF_HB_FLASH_CFI_UNLOCK_ADDR1 0x00000055 /**< HyperBus CFI Unlock Address One */
456 typedef uint32_t CY_SMIF_FLASHDATA; /**< HyperBus Flash Data Type */
457 #endif /* (CY_IP_MXSMIF_VERSION>=2) */
458
459
460 /** \cond INTERNAL */
461
462 #if (CY_IP_MXSMIF_VERSION>=2)
463 /*****************************************************
464 * Define Hyper Flash/RAM read/write macro to be used by LLD *
465 *****************************************************/
466 #define CY_SMIF_FLASH_OFFSET(b,o) (*(( (volatile CY_SMIF_FLASHDATA*)(b) ) + (o)))
467
468 #if (CY_CPU_CORTEX_M7)
469 #define CY_SMIF_FLASH_WR(b,o,d)\
470 {\
471 __DMB();\
472 CY_SMIF_FLASH_OFFSET((b),(o)) = (d);\
473 }
474 #else
475 #define CY_SMIF_FLASH_WR(b,o,d) CY_SMIF_FLASH_OFFSET((b),(o)) = (d)
476 #endif
477 #define CY_SMIF_FLASH_RD(b,o) CY_SMIF_FLASH_OFFSET((b),(o))
478
479 #define CY_SMIF_HB_FLASH_BUF_SIZE_MULTIPLIER 1
480 #define HB_REG_SIZE_IN_HALFWORD 1
481
482 #endif /* (CY_IP_MXSMIF_VERSION>=2) */
483
484
485 /*******************************************************************************
486 * These are legacy constants and API. They are left here just
487 * for backward compatibility.
488 * Do not use them in new designs.
489 *******************************************************************************/
490
491 #define CY_SMIF_FLAG_WR_EN CY_SMIF_FLAG_WRITE_ENABLE
492 #define CY_SMIF_FLAG_CRYPTO_EN CY_SMIF_FLAG_CRYPTO_ENABLE
493 #define CY_SMIF_SFDP_SING_BYTE_00 CY_SMIF_SFDP_SIGNATURE_BYTE_00
494 #define CY_SMIF_SFDP_SING_BYTE_01 CY_SMIF_SFDP_SIGNATURE_BYTE_01
495 #define CY_SMIF_SFDP_SING_BYTE_02 CY_SMIF_SFDP_SIGNATURE_BYTE_02
496 #define CY_SMIF_SFDP_SING_BYTE_03 CY_SMIF_SFDP_SIGNATURE_BYTE_03
497 #define CY_SMIF_WR_STS_REG1_CMD CY_SMIF_WRITE_STATUS_REG1_CMD
498 #define CY_SMIF_WR_DISABLE_CMD CY_SMIF_WRITE_DISABLE_CMD
499 #define CY_SMIF_RD_STS_REG1_CMD CY_SMIF_READ_STATUS_REG1_CMD
500 #define CY_SMIF_WR_ENABLE_CMD CY_SMIF_WRITE_ENABLE_CMD
501 #define CY_SMIF_RD_STS_REG2_T1_CMD CY_SMIF_READ_STATUS_REG2_T1_CMD
502 #define CY_SMIF_WR_STS_REG2_CMD CY_SMIF_WRITE_STATUS_REG2_CMD
503 #define CY_SMIF_RD_STS_REG2_T2_CMD CY_SMIF_READ_STATUS_REG2_T2_CMD
504 #define CY_SMIF_QE_BIT_STS_REG2_T1 CY_SMIF_QE_BIT_STATUS_REG2_T1
505 #define CY_SMIF_STS_REG_BUSY_MASK CY_SMIF_STATUS_REG_BUSY_MASK
506
507 #define Cy_SMIF_Memslot_Init Cy_SMIF_MemInit
508 #define Cy_SMIF_Memslot_DeInit Cy_SMIF_MemDeInit
509 #define Cy_SMIF_Memslot_CmdWriteEnable Cy_SMIF_MemCmdWriteEnable
510 #define Cy_SMIF_Memslot_CmdWriteDisable Cy_SMIF_MemCmdWriteDisable
511 #define Cy_SMIF_Memslot_IsBusy Cy_SMIF_MemIsBusy
512 #define Cy_SMIF_Memslot_QuadEnable Cy_SMIF_MemQuadEnable
513 #define Cy_SMIF_Memslot_CmdReadSts Cy_SMIF_MemCmdReadStatus
514 #define Cy_SMIF_Memslot_CmdWriteSts Cy_SMIF_MemCmdWriteStatus
515 #define Cy_SMIF_Memslot_CmdChipErase Cy_SMIF_MemCmdChipErase
516 #define Cy_SMIF_Memslot_CmdSectorErase Cy_SMIF_MemCmdSectorErase
517 #define Cy_SMIF_Memslot_SfdpDetect Cy_SMIF_MemSfdpDetect
518 #define Cy_SMIF_Memslot_CmdProgram Cy_SMIF_MemCmdProgram
519 #define Cy_SMIF_Memslot_CmdRead Cy_SMIF_MemCmdRead
520
521 #define PARAM_ID_MSB_OFFSET (0x08U) /* The offset of Parameter ID MSB */
522 #define PARAM_ID_LSB_MASK (0xFFUL) /* The mask of Parameter ID LSB */
523 #define MEM_ADDR_VALID(addr, size) (0U == ((addr)%(size))) /* This address must be a multiple of
524 * the SMIF XIP memory size
525 */
526 #define MEM_MAPPED_SIZE_VALID(size) (((size) >= 0x10000U) && (0U == ((size)&((size)-1U))) )
527 #define MEM_ADDR_SIZE_VALID(addrSize) ((0U < (addrSize)) && ((addrSize) <= CY_SMIF_FOUR_BYTES_ADDR))
528
529 /* ----------------------------------------- HyperBus Internal definitions ----------------------------------- */
530 #if (CY_IP_MXSMIF_VERSION>=2)
531
532
533 /* Hyperbus address format
534 *
535 */
536
537 #define SMIF_HYPERBUS_ADR_LOWER_COL_ADDRESS_Pos 0UL
538 #define SMIF_HYPERBUS_ADR_LOWER_COL_ADDRESS_Msk 0x7UL
539 #define SMIF_HYPERBUS_ADR_BYTE_ENABLE_Pos 13UL
540 #define SMIF_HYPERBUS_ADR_BYTE_ENABLE_Msk 0x6000UL
541 #define SMIF_HYPERBUS_ADR_ROW_AND_UPPER_COL_ADDRESS_Pos 16UL
542 #define SMIF_HYPERBUS_ADR_ROW_AND_UPPER_COL_ADDRESS_Msk 0xFFFF0000UL
543
544 #define SMIF_HYPERBUS_CMD_ADDRESS_LAST_BYTE_Pos 0UL
545 #define SMIF_HYPERBUS_CMD_ADDRESS_LAST_BYTE_Msk 0x3FUL
546 #define SMIF_HYPERBUS_CMD_BURST_TYPE_Pos 13UL
547 #define SMIF_HYPERBUS_CMD_BURST_TYPE_Msk 0x2000UL
548 #define SMIF_HYPERBUS_CMD_TARGET_TYPE_Pos 14UL
549 #define SMIF_HYPERBUS_CMD_TARGET_TYPE_Msk 0x4000UL
550 #define SMIF_HYPERBUS_CMD_READ_WRITE_Pos 15UL
551 #define SMIF_HYPERBUS_CMD_READ_WRITE_Msk 0x8000UL
552 #endif /* (CY_IP_MXSMIF_VERSION>=2) */
553
554 /** \endcond */
555 /** \} group_smif_macros_sfdp */
556
557
558 /**
559 * \addtogroup group_smif_data_structures_memslot
560 * \{
561 */
562
563 /** This command structure is used to store the Read/Write command
564 * configuration. */
565 typedef struct
566 {
567 uint32_t command; /**< The 8-bit command. This value is 0xFFFFFFFF when there is no command present */
568 cy_en_smif_txfr_width_t cmdWidth; /**< The width of the command transfer */
569 cy_en_smif_txfr_width_t addrWidth; /**< The width of the address transfer */
570 uint32_t mode; /**< The 8-bit mode byte. This value is 0xFFFFFFFF when there is no mode present */
571 cy_en_smif_txfr_width_t modeWidth; /**< The width of the mode transfer */
572 uint32_t dummyCycles; /**< The number of the dummy cycles. A zero value suggests no dummy cycles */
573 cy_en_smif_txfr_width_t dataWidth; /**< The width of the data transfer */
574 #if (CY_IP_MXSMIF_VERSION>=2) || defined (CY_DOXYGEN)
575 /**
576 * \note
577 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
578 **/
579 cy_en_smif_data_rate_t dataRate; /**< The Data rate of data */
580 /**
581 * \note
582 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
583 **/
584 cy_en_smif_field_presence_t dummyCyclesPresence; /**< This specifies the presence of the dummy field */
585 /**
586 * \note
587 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
588 **/
589 cy_en_smif_field_presence_t modePresence; /**< This specifies the presence of the mode field */
590 /**
591 * \note
592 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
593 **/
594 uint32_t modeH; /**< The 8-bit command. This value is 0x0 when there is no higher byte mode present */
595 /**
596 * \note
597 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
598 **/
599 cy_en_smif_data_rate_t modeRate; /**< The Data rate of mode */
600 /**
601 * \note
602 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
603 **/
604 cy_en_smif_data_rate_t addrRate; /**< The Data rate of address */
605 /**
606 * \note
607 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
608 **/
609 cy_en_smif_field_presence_t cmdPresence; /**< This specifies the presence of the command field */
610 /**
611 * \note
612 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
613 **/
614 uint32_t commandH; /**< The 8-bit command. This value is 0x0 when there is no higher byte command present */
615 /**
616 * \note
617 * This parameter is available for CAT1B, CAT1C and CAT1D devices.
618 **/
619 cy_en_smif_data_rate_t cmdRate; /**< The Data rate of command */
620 #endif /* CY_IP_MXSMIF_VERSION */
621 } cy_stc_smif_mem_cmd_t;
622
623 /** This structure specifies data used for memory with hybrid sectors */
624 typedef struct
625 {
626 uint32_t regionAddress; /**< This specifies the address where a region starts */
627 uint32_t sectorsCount; /**< This specifies the number of sectors in the region */
628 uint32_t eraseCmd; /**< This specifies the region specific erase instruction */
629 uint32_t eraseSize; /**< This specifies the size of one sector */
630 uint32_t eraseTime; /**< Max time for sector erase type 1 cycle time in ms */
631 } cy_stc_smif_hybrid_region_info_t;
632
633 #if(CY_IP_MXSMIF_VERSION>=2)
634 /** This structure specifies data used for memory with hybrid sectors */
635 typedef struct
636 {
637 uint8_t cmdSeq1Len; /**< This specifies command sequence 1 length. */
638 uint8_t cmdSeq2Len; /**< This specifies command sequence 2 length. */
639 uint8_t cmdSeq1[CY_SMIF_SFDP_ODDR_CMD_SEQ_MAX_LEN]; /**< This specifies command sequence 1. */
640 uint8_t cmdSeq2[CY_SMIF_SFDP_ODDR_CMD_SEQ_MAX_LEN]; /**< This specifies command sequence 2. */
641 } cy_stc_smif_octal_ddr_en_seq_t;
642 #endif
643
644
645 /* ------------------------------------------------- HyperBus Enums ---------------------------------------------- */
646 #if (CY_IP_MXSMIF_VERSION>=2)
647
648 /** Specifies top 8 bit of read/write sequence (bit 47 ~ bit 40). only top 3 bits have meaning */
649 /** bit 47: Identifies the transaction as a Read or Write. R/W#=1 indicates a Read operation and R/W#=0 indicates a Write operation. */
650 /** bit 46: Indicates whether the Read or Write operation accesses the memory or register spaces. */
651 /** bit 45: Indicates whether the burst will be continuous or wrapped. Burst Type=0 indicates Wrapped Burst, Burst Type=1 indicates Continuous Burst. */
652 /** bit 46 is always 0, since this drive assumes accessing memory space in XIP mode */
653 typedef enum
654 {
655 CY_SMIF_HB_READ_WRAPPED_BURST = 0x80, /**< bit 47 = 1: read, bit 45 = 0: wrapped burst */
656 CY_SMIF_HB_READ_CONTINUOUS_BURST = 0xA0, /**< bit 47 = 1: read, bit 45 = 1: continuous burst */
657 } cy_en_smif_hb_rd_cmd_t;
658
659 /** see \ref cy_en_smif_hb_rd_cmd_t */
660 typedef enum
661 {
662 CY_SMIF_HB_WRITE_WRAPPED_BURST = 0x00, /**< bit 47 = 0: write, bit 45 = 0: wrapped burst */
663 CY_SMIF_HB_WRITE_CONTINUOUS_BURST = 0x20, /**< bit 47 = 0: write, bit 45 = 1: continuous burst */
664 } cy_en_smif_hb_wt_cmd_t;
665
666 /** Specifies hyper bus device type. FLASH or SRAM */
667 typedef enum
668 {
669 CY_SMIF_HB_FLASH = 0, /**< Hyper bus FLASH */
670 CY_SMIF_HB_SRAM = 1, /**< Hyper bus SRAM */
671 } cy_en_smif_hb_dev_type_t;
672
673 /** The size of the device region specified by DEVICE_MASK register */
674 typedef enum // casting int32_t is to avoid compiler error.
675 {
676 CY_SMIF_DEVICE_1M_BYTE = (int32_t)(0xFFF00000UL), /**< for 1M size device */
677 CY_SMIF_DEVICE_2M_BYTE = (int32_t)(0xFFE00000UL), /**< for 2M size device */
678 CY_SMIF_DEVICE_4M_BYTE = (int32_t)(0xFFC00000UL), /**< for 4M size device */
679 CY_SMIF_DEVICE_8M_BYTE = (int32_t)(0xFF800000UL), /**< for 8M size device */
680 CY_SMIF_DEVICE_16M_BYTE = (int32_t)(0xFF000000UL), /**< for 16M size device */
681 CY_SMIF_DEVICE_32M_BYTE = (int32_t)(0xFE000000UL), /**< for 32M size device */
682 CY_SMIF_DEVICE_64M_BYTE = (int32_t)(0xFC000000UL), /**< for 64M size device */
683 CY_SMIF_DEVICE_128M_BYTE = (int32_t)(0xF8000000UL), /**< for 128M size device */
684 CY_SMIF_DEVICE_256M_BYTE = (int32_t)(0xF0000000UL), /**< for 256M size device */
685 CY_SMIF_DEVICE_512M_BYTE = (int32_t)(0xE0000000UL), /**< for 512M size device */
686 CY_SMIF_DEVICE_1G_BYTE = (int32_t)(0xC0000000UL), /**< for 1G size device */
687 CY_SMIF_DEVICE_2G_BYTE = (int32_t)(0x80000000UL), /**< for 2G size device */
688 CY_SMIF_DEVICE_4G_BYTE = (int32_t)(0x00000000UL), /**< for 4G size device */
689 } cy_en_device_size_t;
690
691 /** Specifies the size of a memory sub page */
692 typedef enum
693 {
694 SUB_PAGE_SIZE_8BYTE = 0, /**< sub_page_size = 8 words = 16 bytes (default) */
695 SUB_PAGE_SIZE_16BYTE = 1, /**< sub_page_size = 16 words = 32 bytes */
696 SUB_PAGE_SIZE_32BYTE = 2, /**< sub_page_size = 32 words = 64 bytes */
697 SUB_PAGE_SIZE_64BYTE = 3,/**< sub_page_size = 64 words = 128 bytes */
698 } en_cy_sub_page_size_t;
699
700 /** Specifies the number of sub pages per page */
701 typedef enum
702 {
703 SUB_PAGE_1_PER_PAGE = 0, /**< 1 sub pages per page, i.e. page_size = sub_page_size */
704 SUB_PAGE_2_PER_PAGE = 1, /**< 2 sub pages per page, i.e. page_size = 2 x sub_page_size */
705 SUB_PAGE_4_PER_PAGE = 2, /**< 4 sub pages per page, i.e. page_size = 4 x sub_page_size */
706 SUB_PAGE_8_PER_PAGE = 3, /**< 8 sub pages per page, i.e. page_size = 8 x sub_page_size */
707 } en_cy_sub_page_nr_t;
708
709 /** Specifies the size of the XIP device address in Bytes */
710 typedef enum
711 {
712 CY_SMIF_XIP_ADDRESS_1_BYTE = 0, /**< 1 Byte address */
713 CY_SMIF_XIP_ADDRESS_2_BYTE = 1, /**< 2 Byte address */
714 CY_SMIF_XIP_ADDRESS_3_BYTE = 2, /**< 3 Byte address */
715 CY_SMIF_XIP_ADDRESS_4_BYTE = 3, /**< 4 Byte address */
716 CY_SMIF_XIP_ADDRESS_5_BYTE = 7, /**< 4 Byte address (spread over 5 bytes) according to Hyperbus protocol */
717 } cy_en_smif_xip_addr_byte_t;
718
719 /** Specify whether command to be transmitted is last one or not */
720 typedef enum
721 {
722 NOT_LAST_COMMAND = 0, /**< not last command */
723 LAST_COMMAND_BYTE = 1,/**< last command */
724 } cy_en_smif_cmd_last_t;
725
726 typedef enum
727 {
728 CY_SMIF_HB_WRAPPED_BURST = 0, /**< continue to wrap within the burst length */
729 CY_SMIF_HB_COUTINUOUS_BURST = 1, /**< output data in a sequential manner across page boundaries */
730 } cy_en_hb_burst_type_t;
731
732 /** read target. memory or register */
733 typedef enum
734 {
735 CY_SMIF_HB_TARGET_MEMORY = 0, /**< memory */
736 CY_SMIF_HB_TARGET_REGISTER = 1, /**< register. it is used only for hyper SRAM */
737 } cy_en_hb_target_t;
738
739 /** read or write */
740 typedef enum
741 {
742 CY_SMIF_HB_WRITE = 0, /**< write */
743 CY_SMIF_HB_READ = 1, /**< read */
744 } cy_en_hb_read_write_t;
745
746
747 /* ----------------------------------------------------- HyperBus Data Structures ----------------------------------- */
748
749
750 typedef struct
751 {
752 cy_en_smif_hb_rd_cmd_t xipReadCmd; /**< read command value \ref cy_en_smif_hb_rd_cmd_t */
753 cy_en_smif_hb_wt_cmd_t xipWriteCmd; /**< write command value \ref cy_en_smif_hb_rd_cmd_t */
754 cy_en_smif_hb_dev_type_t hbDevType; /**< hyper bus device type \ref cy_en_smif_hb_dev_type_t */
755 cy_en_device_size_t memSize; /**< The memory size: For densities of 2 gigabits or less - the size in bytes;
756 * For densities 4 gigabits and above - bit-31 is set to 1b to define that
757 * this memory is 4 gigabits and above; and other 30:0 bits define N where
758 * the density is computed as 2^N bytes.
759 * For example, 0x80000021 corresponds to 2^30 = 1 gigabyte.
760 */
761 uint32_t dummyCycles; /**< dummy Cycles based on Frequency of operation */
762 } cy_stc_smif_hbmem_device_config_t;
763 #endif /* (CY_IP_MXSMIF_VERSION>=2) */
764 /**
765 *
766 * This configuration structure of the SMIF memory device is used to store
767 * device-specific parameters.
768 * These parameters are used to set up the memory mode initialization and the
769 * memory API.
770 */
771 typedef struct
772 {
773 uint32_t numOfAddrBytes; /**< This specifies the number of address bytes used by the
774 * memory slave device, valid values 1-4 */
775 uint32_t memSize; /**< The memory size: For densities of 2 gigabits or less - the size in bytes;
776 * For densities 4 gigabits and above - bit-31 is set to 1b to define that
777 * this memory is 4 gigabits and above; and other 30:0 bits define N where
778 * the density is computed as 2^N bytes.
779 * For example, 0x80000021 corresponds to 2^30 = 1 gigabyte.
780 */
781 cy_stc_smif_mem_cmd_t* readCmd; /**< This specifies the Read command */
782 cy_stc_smif_mem_cmd_t* writeEnCmd; /**< This specifies the Write Enable command */
783 cy_stc_smif_mem_cmd_t* writeDisCmd; /**< This specifies the Write Disable command */
784 cy_stc_smif_mem_cmd_t* eraseCmd; /**< This specifies the Erase command */
785 uint32_t eraseSize; /**< This specifies the sector size of each Erase */
786 cy_stc_smif_mem_cmd_t* chipEraseCmd; /**< This specifies the Chip Erase command */
787 cy_stc_smif_mem_cmd_t* programCmd; /**< This specifies the Program command */
788 uint32_t programSize; /**< This specifies the page size for programming */
789 cy_stc_smif_mem_cmd_t* readStsRegWipCmd; /**< This specifies the command to read the WIP-containing status register */
790 cy_stc_smif_mem_cmd_t* readStsRegQeCmd; /**< This specifies the command to read the QE-containing status register */
791 cy_stc_smif_mem_cmd_t* writeStsRegQeCmd; /**< This specifies the command to write into the QE-containing status register */
792 cy_stc_smif_mem_cmd_t* readSfdpCmd; /**< This specifies the read SFDP command */
793 uint32_t stsRegBusyMask; /**< The Busy mask for the status registers */
794 uint32_t stsRegQuadEnableMask; /**< The QE mask for the status registers */
795 uint32_t eraseTime; /**< Max time for erase type 1 cycle time in ms */
796 uint32_t chipEraseTime; /**< Max time for chip erase cycle time in ms */
797 uint32_t programTime; /**< Max time for page program cycle time in us */
798 uint32_t hybridRegionCount; /**< This specifies the number of regions for memory with hybrid sectors */
799 cy_stc_smif_hybrid_region_info_t** hybridRegionInfo; /**< This specifies data for memory with hybrid sectors */
800 cy_stc_smif_mem_cmd_t* readLatencyCmd; /**< This specifies the command to read variable latency cycles configuration register */
801 cy_stc_smif_mem_cmd_t* writeLatencyCmd; /**< This specifies the command to write variable latency cycles configuration register */
802 uint32_t latencyCyclesRegAddr; /**< This specifies the address for variable latency cycle address */
803 uint32_t latencyCyclesMask; /**< This specifies variable latency cycles Mask */
804 #if(CY_IP_MXSMIF_VERSION>=2)
805 cy_stc_smif_octal_ddr_en_seq_t* octalDDREnableSeq; /**< This specifies data for memory with hybrid sectors */
806 cy_stc_smif_mem_cmd_t* readStsRegOeCmd; /**< This specifies the command to read the OE-containing status register */
807 cy_stc_smif_mem_cmd_t* writeStsRegOeCmd; /**< This specifies the command to write into the OE-containing status register */
808 uint32_t stsRegOctalEnableMask; /**< The QE mask for the status registers */
809 uint32_t octalEnableRegAddr; /**< Octal enable register address */
810 cy_en_smif_interface_freq_t freq_of_operation; /**< Frequency of operation used in Octal mode */
811 #endif
812 } cy_stc_smif_mem_device_cfg_t;
813
814
815 /**
816 *
817 * This SMIF memory configuration structure is used to store the memory configuration for the memory mode of operation.
818 * This data structure is stored in a fixed location in the flash. The data structure is required
819 * for the initialization of the SMIF in the SystemInit.
820 */
821 typedef struct
822 {
823 /** Determines the slave select where the memory device is placed */
824 cy_en_smif_slave_select_t slaveSelect;
825 /** Determines if the device is memory-mapped, enables the Autodetect
826 * using the SFDP, enables the write capability, or enables the crypto
827 * support for this memory slave */
828 uint32_t flags;
829 /** The data-line selection options for a slave device */
830 cy_en_smif_data_select_t dataSelect;
831 /** The base address the memory slave is mapped to in the PSoC memory map.
832 * This address must be a multiple of the SMIF XIP memory size/capacity. The
833 * SMIF XIP memory region should NOT overlap with other memory regions
834 * (with exception to dual quad mode). Valid when the memory-mapped mode is
835 * enabled.
836 */
837 uint32_t baseAddress;
838 /** The size/capacity allocated in the PSoC memory map for the memory slave
839 * device. The capacity is allocated from the base address. The capacity
840 * must be a power of 2 and greater or equal than 64 KB. Valid when
841 * memory-mapped mode is enabled
842 */
843 uint32_t memMappedSize;
844 /** Defines if this memory device is one of the devices in the dual quad SPI
845 * configuration. Equals the sum of the slave-slot numbers. */
846 uint32_t dualQuadSlots;
847 cy_stc_smif_mem_device_cfg_t* deviceCfg; /**< The configuration of the device */
848 #if(CY_IP_MXSMIF_VERSION>=2)
849 /** Continuous transfer merge timeout.
850 * After this period the memory device is deselected. A later transfer, even from a
851 * continuous address, starts with the overhead phases (command, address, mode, dummy cycles).
852 * This configuration parameter is available for CAT1B, CAT1C and CAT1D devices. */
853 cy_en_smif_merge_timeout_t mergeTimeout;
854
855 cy_stc_smif_hbmem_device_config_t* hbdeviceCfg; /**< The configuration of the hyperbus device */
856 #endif /* CY_IP_MXSMIF_VERSION */
857
858 } cy_stc_smif_mem_config_t;
859
860
861 /**
862 *
863 * This SMIF memory configuration structure is used to store the memory configuration for the memory mode of operation.
864 * This data structure is stored in a fixed location in the flash. The data structure is required
865 * for the initialization of the SMIF in the SystemInit.
866 */
867 typedef struct
868 {
869 uint32_t memCount; /**< The number of SMIF memory defined */
870 cy_stc_smif_mem_config_t** memConfig; /**< The pointer to the array of the memory configuration structures of size Memory_count */
871 uint32_t majorVersion; /**< The version of the SMIF driver */
872 uint32_t minorVersion; /**< The version of the SMIF Driver */
873 } cy_stc_smif_block_config_t;
874
875
876 /** \} group_smif_data_structures_memslot */
877
878
879 /**
880 * \addtogroup group_smif_mem_slot_functions
881 * \{
882 */
883 cy_en_smif_status_t Cy_SMIF_MemInit(SMIF_Type *base,
884 cy_stc_smif_block_config_t const * blockConfig,
885 cy_stc_smif_context_t *context);
886 void Cy_SMIF_MemDeInit(SMIF_Type *base);
887 cy_en_smif_status_t Cy_SMIF_MemCmdWriteEnable( SMIF_Type *base,
888 cy_stc_smif_mem_config_t const *memDevice,
889 cy_stc_smif_context_t const *context);
890 cy_en_smif_status_t Cy_SMIF_MemCmdWriteDisable(SMIF_Type *base,
891 cy_stc_smif_mem_config_t const *memDevice,
892 cy_stc_smif_context_t const *context);
893 bool Cy_SMIF_MemIsBusy(SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice,
894 cy_stc_smif_context_t const *context);
895 cy_en_smif_status_t Cy_SMIF_MemQuadEnable(SMIF_Type *base,
896 cy_stc_smif_mem_config_t const *memDevice,
897 cy_stc_smif_context_t const *context);
898 #if (CY_IP_MXSMIF_VERSION>=2) || defined (CY_DOXYGEN)
899 cy_en_smif_status_t Cy_SMIF_MemOctalEnable(SMIF_Type *base,
900 cy_stc_smif_mem_config_t const *memDevice,
901 cy_en_smif_data_rate_t dataRate,
902 cy_stc_smif_context_t const *context);
903 #endif
904
905 cy_en_smif_status_t Cy_SMIF_MemCmdReadStatus(SMIF_Type *base,
906 cy_stc_smif_mem_config_t const *memDevice,
907 uint8_t *status, uint8_t command,
908 cy_stc_smif_context_t const *context);
909 cy_en_smif_status_t Cy_SMIF_MemCmdWriteStatus(SMIF_Type *base,
910 cy_stc_smif_mem_config_t const *memDevice,
911 void const *status, uint8_t command,
912 cy_stc_smif_context_t const *context);
913 cy_en_smif_status_t Cy_SMIF_MemCmdChipErase(SMIF_Type *base,
914 cy_stc_smif_mem_config_t const *memDevice,
915 cy_stc_smif_context_t const *context);
916 cy_en_smif_status_t Cy_SMIF_MemCmdSectorErase(SMIF_Type *base,
917 cy_stc_smif_mem_config_t const *memDevice,
918 uint8_t const *sectorAddr,
919 cy_stc_smif_context_t const *context);
920 cy_en_smif_status_t Cy_SMIF_MemCmdProgram(SMIF_Type *base,
921 cy_stc_smif_mem_config_t const *memDevice,
922 uint8_t const *addr,
923 uint8_t const *writeBuff,
924 uint32_t size,
925 cy_smif_event_cb_t cmdCompleteCb,
926 cy_stc_smif_context_t *context);
927 cy_en_smif_status_t Cy_SMIF_MemCmdRead(SMIF_Type *base,
928 cy_stc_smif_mem_config_t const *memDevice,
929 uint8_t const *addr,
930 uint8_t *readBuff,
931 uint32_t size,
932 cy_smif_event_cb_t cmdCompleteCb,
933 cy_stc_smif_context_t *context);
934 cy_en_smif_status_t Cy_SMIF_MemSfdpDetect(SMIF_Type *base,
935 cy_stc_smif_mem_device_cfg_t *device,
936 cy_en_smif_slave_select_t slaveSelect,
937 cy_en_smif_data_select_t dataSelect,
938 cy_stc_smif_context_t *context);
939
940 void Cy_SMIF_Reset_Memory(SMIF_Type *base, cy_en_smif_slave_select_t slaveSelect);
941
942 cy_en_smif_status_t Cy_SMIF_MemInitSfdpMode(SMIF_Type *base,
943 const cy_stc_smif_mem_config_t *memCfg,
944 cy_en_smif_txfr_width_t maxdataWidth,
945 cy_en_smif_qer_t qer_id,
946 cy_stc_smif_context_t *context);
947
948 cy_en_smif_status_t Cy_SMIF_MemIsReady(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
949 uint32_t timeoutUs, cy_stc_smif_context_t const *context);
950 cy_en_smif_status_t Cy_SMIF_MemIsQuadEnabled(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
951 bool *isQuadEnabled, cy_stc_smif_context_t const *context);
952 cy_en_smif_status_t Cy_SMIF_MemEnableQuadMode(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
953 uint32_t timeoutUs, cy_stc_smif_context_t const *context);
954 cy_en_smif_status_t Cy_SMIF_MemRead(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
955 uint32_t address, uint8_t rxBuffer[],
956 uint32_t length, cy_stc_smif_context_t const *context);
957 cy_en_smif_status_t Cy_SMIF_MemWrite(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
958 uint32_t address, uint8_t const txBuffer[],
959 uint32_t length, cy_stc_smif_context_t const *context);
960 cy_en_smif_status_t Cy_SMIF_MemEraseSector(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
961 uint32_t address, uint32_t length,
962 cy_stc_smif_context_t const *context);
963 cy_en_smif_status_t Cy_SMIF_MemEraseChip(SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig,
964 cy_stc_smif_context_t const *context);
965 cy_en_smif_status_t Cy_SMIF_MemLocateHybridRegion(cy_stc_smif_mem_config_t const *memDevice,
966 cy_stc_smif_hybrid_region_info_t** regionInfo, uint32_t address);
967 void Cy_SMIF_SetReadyPollingDelay(uint16_t pollTimeoutUs,
968 cy_stc_smif_context_t *context);
969 cy_en_smif_status_t Cy_SMIF_MemCmdPowerDown(SMIF_Type *base,
970 cy_stc_smif_mem_config_t const *memDevice,
971 cy_stc_smif_context_t const *context);
972
973 cy_en_smif_status_t Cy_SMIF_MemCmdReleasePowerDown(SMIF_Type *base,
974 cy_stc_smif_mem_config_t const *memDevice,
975 cy_stc_smif_context_t const *context);
976
977 #if (CY_IP_MXSMIF_VERSION>=2)
978
979 /*******************************************************************************
980 * Function Name: Cy_SMIF_HyperBus_InitDevice
981 ****************************************************************************//**
982 *
983 * This function sets up SMIF registers for hyper bus memory.
984 *
985 * \param device
986 * Holds the base address of the SMIF Device registers.
987 *
988 * \param memCfg
989 * Configuration to be applied to the SMIF device \ref cy_stc_smif_mem_config_t
990 *
991 * \param context
992 * This is the pointer to the context structure \ref cy_stc_smif_context_t
993 * allocated by the user. The structure is used during the SMIF
994 * operation for internal configuration and data retention. The user must not
995 * modify anything in this structure.
996 *
997 * \return
998 * - \ref CY_SMIF_BAD_PARAM
999 * - \ref CY_SMIF_SUCCESS
1000 *
1001 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1002 *
1003 *******************************************************************************/
1004 cy_en_smif_status_t Cy_SMIF_HyperBus_InitDevice(SMIF_Type *base, const cy_stc_smif_mem_config_t *memCfg, cy_stc_smif_context_t *context);
1005
1006 /*******************************************************************************
1007 * Function Name: Cy_SMIF_HyperBus_CalibrateDelay
1008 ****************************************************************************//**
1009 *
1010 * This function reads the calibration data pattern in the Hyper memory for every
1011 * delay tap of the currently selected delay line and records whether it matches
1012 * the reference pattern. After all taps have been scanned, it determines the
1013 * center tap of the longest sequence of matches and applies this tap.
1014 *
1015 * \note Function assumes that any SMIF has the same number of delay taps
1016 *
1017 * \param base
1018 * Holds the base address of the SMIF Device registers.
1019 *
1020 * \param memConfig
1021 * SMIF memory configuration structure for memory mode of operation.
1022 *
1023 * \param dummyCycles
1024 * Dummy Cycles based on Frequency of operation
1025 *
1026 * \param calibrationDataOffsetFromBase
1027 * Address offset of the calibration data from the device's XIP base address
1028 *
1029 * \param context
1030 * Current SMIF driver context
1031 *
1032 * \return \ref cy_en_smif_status_t
1033 *
1034 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1035 *
1036 *******************************************************************************/
1037 cy_en_smif_status_t Cy_SMIF_HyperBus_CalibrateDelay(SMIF_Type *base, cy_stc_smif_mem_config_t *memConfig, uint8_t dummyCycles, uint32_t calibrationDataOffsetAddress, cy_stc_smif_context_t *context);
1038
1039 /*******************************************************************************
1040 * Function Cy_SMIF_HyperBus_Read
1041 ****************************************************************************//**
1042 *
1043 * This function reads data from hyper bus memory in MMIO mode.
1044 *
1045 * \param base
1046 * Holds the base address of the SMIF block registers.
1047 *
1048 * \param memConfig
1049 * SMIF memory configuration structure for memory mode of operation.
1050 *
1051 * \param burstType
1052 * Specifies wrapped or continuous burst. \ref en_hb_bust_type_t
1053 *
1054 * \param readAddress
1055 * Specifies address of external device to be read.
1056 *
1057 * \param sizeInHalfWord
1058 * Specifies memory size to be read.
1059 * Note hyper bus memory have 16bit data per each address.
1060 *
1061 * \param buf
1062 * Pointer to buffer where read data to be stored
1063 *
1064 * \param dummyCycles
1065 * Dummy Cycles based on Frequency of operation
1066 *
1067 * \param doubleLat
1068 * double initial latency or single initial latency
1069 *
1070 * \param isblockingMode
1071 * Blocking mode or not. if this is true, process waits for the read finished in this
1072 * function. unless, the process does not wait and exit function.
1073 *
1074 * \param context
1075 * Passes a configuration structure that contains the transfer parameters of the
1076 * SMIF block.
1077 *
1078 * \return \ref cy_en_smif_status_t
1079 *
1080 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1081 *
1082 *******************************************************************************/
1083 cy_en_smif_status_t Cy_SMIF_HyperBus_Read(SMIF_Type *base,
1084 cy_stc_smif_mem_config_t *memConfig,
1085 cy_en_hb_burst_type_t burstType,
1086 uint32_t readAddress,
1087 uint32_t sizeInHalfWord,
1088 uint16_t buf[],
1089 uint32_t dummyCycles,
1090 bool doubleLat,
1091 bool isblockingMode,
1092 cy_stc_smif_context_t *context);
1093
1094 /*******************************************************************************
1095 * Function Cy_SMIF_HyperBus_Write
1096 ****************************************************************************//**
1097 *
1098 * This function writes data into hyper bus memory in MMIO mode.
1099 *
1100 * \param base
1101 * Holds the base address of the SMIF block registers.
1102 *
1103 * \param memConfig
1104 * SMIF memory configuration structure for memory mode of operation.
1105 *
1106 * \param burstType
1107 * Specifies wrapped or continuous burst. \ref en_hb_bust_type_t
1108 *
1109 * \param writeAddress
1110 * Specifies address of external device to be write.
1111 *
1112 * \param sizeInHalfWord
1113 * Specifies memory size to be read.
1114 * Note hyper bus memory have 16bit data per each address.
1115 *
1116 * \param buf
1117 * Pointer to buffer where read data to be stored
1118 *
1119 * \param hbDevType
1120 * Specifies hyper bus type. FLASH or SRAM. \ref cy_en_smif_hb_dev_type_t
1121 *
1122 * \param dummyCycles
1123 * Dummy Cycles based on Frequency of operation.
1124 *
1125 * \param isblockingMode
1126 * Blocking mode or not. if this is true, process waits for the read finished in this
1127 * function. unless, the process does not wait and exit function.
1128 *
1129 * \param context
1130 * Passes a configuration structure that contains the transfer parameters of the
1131 * SMIF block.
1132 *
1133 * \return \ref cy_en_smif_status_t
1134 *
1135 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1136 *
1137 *******************************************************************************/
1138 cy_en_smif_status_t Cy_SMIF_HyperBus_Write(SMIF_Type *base,
1139 cy_stc_smif_mem_config_t *memConfig,
1140 cy_en_hb_burst_type_t burstType,
1141 uint32_t writeAddress,
1142 uint32_t sizeInHalfWord,
1143 uint16_t buf[],
1144 cy_en_smif_hb_dev_type_t hbDevType,
1145 uint32_t dummyCycles,
1146 bool isblockingMode,
1147 cy_stc_smif_context_t *context);
1148
1149 /*******************************************************************************
1150 * Function Cy_SMIF_HyperBus_MMIO_Write
1151 ****************************************************************************//**
1152 *
1153 * This function writes data into hyper bus memory in MMIO mode.
1154 *
1155 * \param base
1156 * Holds the base address of the SMIF block registers.
1157 *
1158 * \param slave
1159 * Specifies slave of external device to be read. \ref cy_en_smif_slave_select_t
1160 *
1161 * \param burstType
1162 * Specifies wrapped or continuous burst. \ref en_hb_bust_type_t
1163 *
1164 * \param writeAddress
1165 * Specifies address of external device to be write.
1166 *
1167 * \param sizeInHalfWord
1168 * Specifies memory size to be read.
1169 * Note hyper bus memory have 16bit data per each address.
1170 *
1171 * \param buf
1172 * Pointer to buffer where read data to be stored
1173 *
1174 * \param hbDevType
1175 * Specifies hyper bus type. FLASH or SRAM. \ref cy_en_smif_hb_dev_type_t
1176 *
1177 * \param dummyCycles
1178 * Dummy Cycles based on Frequency of operation.
1179 *
1180 * \param isblockingMode
1181 * Blocking mode or not. if this is true, process waits for the read finished in this
1182 * function. unless, the process does not wait and exit function.
1183 *
1184 * \param context
1185 * Passes a configuration structure that contains the transfer parameters of the
1186 * SMIF block.
1187 *
1188 * \return \ref cy_en_smif_status_t
1189 *
1190 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1191 *
1192 *******************************************************************************/
1193 cy_en_smif_status_t Cy_SMIF_HyperBus_MMIO_Write(SMIF_Type *base,
1194 cy_en_smif_slave_select_t slave,
1195 cy_en_hb_burst_type_t burstType,
1196 uint32_t writeAddress,
1197 uint32_t sizeInHalfWord,
1198 uint16_t buf[],
1199 cy_en_smif_hb_dev_type_t hbDevType,
1200 uint32_t dummyCycle,
1201 bool isblockingMode,
1202 cy_stc_smif_context_t *context);
1203
1204
1205 /*******************************************************************************
1206 * Function Name: CY_SMIF_HyperBus_ReadStatus
1207 ****************************************************************************//**
1208 *
1209 * This function reads the flash status register bits.
1210 *
1211 * \param base
1212 * Holds the base address of the SMIF block registers.
1213 *
1214 * \param memConfig
1215 * SMIF memory configuration structure for memory mode of operation.
1216 *
1217 * \param regStatus
1218 * output status register value.
1219 *
1220 * \return \ref cy_en_smif_status_t
1221 *
1222
1223 *******************************************************************************/
1224 cy_en_smif_status_t CY_SMIF_HyperBus_ReadStatus(SMIF_Type *base, cy_stc_smif_mem_config_t *memConfig, uint16_t *regStatus, cy_stc_smif_context_t *context);
1225
1226 /*******************************************************************************
1227 * Function Name: CY_SMIF_HyperBus_ClearStatus
1228 ****************************************************************************//**
1229 *
1230 * This function clears the flash status register bits.
1231 *
1232 * \param base
1233 * Holds the base address of the SMIF block registers.
1234 *
1235 * \param memConfig
1236 * SMIF memory configuration structure for memory mode of operation.
1237 *
1238 * \return \ref cy_en_smif_status_t
1239 *
1240 *******************************************************************************/
1241 cy_en_smif_status_t CY_SMIF_HyperBus_ClearStatus(SMIF_Type *base, cy_stc_smif_mem_config_t *memConfig, cy_stc_smif_context_t *context);
1242
1243 /*******************************************************************************
1244 * Function Name: Cy_SMIF_HyperBus_EraseSector
1245 ****************************************************************************//**
1246 *
1247 * This function Erases the data in the given sector.
1248 *
1249 * \param base
1250 * Holds the base address of the SMIF block registers.
1251 *
1252 * \param memConfig
1253 * SMIF memory configuration structure for memory mode of operation.
1254 *
1255 * \param offset
1256 * offset of the sector to be erased.
1257 *
1258 * \return \ref cy_en_smif_status_t
1259 *
1260 * \snippet smif/snippet/main.c snippet_Cy_SMIF_HyperBus
1261 *
1262 *******************************************************************************/
1263 cy_en_smif_status_t Cy_SMIF_HyperBus_EraseSector(SMIF_Type *base, cy_stc_smif_mem_config_t *memConfig, uint32_t offset, cy_stc_smif_context_t *context);
1264
1265 /*******************************************************************************
1266 * Function Name: Cy_SMIF_HyperBus_EraseChip
1267 ****************************************************************************//**
1268 *
1269 * This function Erases the data in the entire flash memory.
1270 *
1271 * \param base
1272 * Holds the base address of the SMIF block registers.
1273 *
1274 * \param memConfig
1275 * SMIF memory configuration structure for memory mode of operation.
1276 *
1277 * \return \ref cy_en_smif_status_t
1278 *
1279 *******************************************************************************/
1280 cy_en_smif_status_t Cy_SMIF_HyperBus_EraseChip(SMIF_Type *base, cy_stc_smif_mem_config_t *memConfig, cy_stc_smif_context_t *context);
1281
1282 #endif /* (CY_IP_MXSMIF_VERSION>=2) */
1283
1284 /** \} group_smif_mem_slot_functions */
1285
1286 __STATIC_INLINE void SfdpGetQuadEnableParameters(cy_stc_smif_mem_device_cfg_t *device,
1287 cy_en_smif_qer_t qerId);
1288 __STATIC_INLINE void XipRegInit(SMIF_DEVICE_Type volatile *dev, cy_stc_smif_mem_config_t const * memCfg);
1289
1290 __STATIC_INLINE cy_en_smif_status_t ReadAnyReg(SMIF_Type *base,
1291 cy_en_smif_slave_select_t slaveSelect,
1292 uint8_t *value,
1293 uint8_t command,
1294 uint8_t dummyCycles,
1295 uint8_t const *address,
1296 uint32_t addressSize,
1297 cy_stc_smif_context_t const *context);
1298 __STATIC_INLINE void ValueToByteArray(uint32_t value, uint8_t *byteArray, uint32_t startPos, uint32_t size);
1299 __STATIC_INLINE uint32_t ByteArrayToValue(uint8_t const *byteArray, uint32_t size);
1300
1301 /*******************************************************************************
1302 * Function Name: SfdpGetQuadEnableParameters
1303 ****************************************************************************//**
1304 *
1305 * Gets the Quad Enable parameters.
1306 *
1307 * \param device
1308 * The device structure instance declared by the user. This is where the detected
1309 * parameters are stored and returned.
1310 *
1311 * \param qerId
1312 * quad enable requirement ID
1313 *
1314 *******************************************************************************/
SfdpGetQuadEnableParameters(cy_stc_smif_mem_device_cfg_t * device,cy_en_smif_qer_t qerId)1315 __STATIC_INLINE void SfdpGetQuadEnableParameters(cy_stc_smif_mem_device_cfg_t *device,
1316 cy_en_smif_qer_t qerId)
1317 {
1318 CY_ASSERT_L1(NULL != device->readStsRegQeCmd);
1319 CY_ASSERT_L1(NULL != device->writeStsRegQeCmd);
1320
1321 /* The command transfer width */
1322 device->writeStsRegQeCmd->cmdWidth = CY_SMIF_WIDTH_SINGLE;
1323
1324 /* The QE mask for the status registers */
1325 switch (qerId)
1326 {
1327 case CY_SMIF_SFDP_QER_0:
1328 device->stsRegQuadEnableMask = CY_SMIF_NO_COMMAND_OR_MODE;
1329 device->writeStsRegQeCmd->command = CY_SMIF_NO_COMMAND_OR_MODE;
1330 device->readStsRegQeCmd->command = CY_SMIF_NO_COMMAND_OR_MODE;
1331 #if (CY_IP_MXSMIF_VERSION>=2)
1332 device->writeStsRegQeCmd->cmdPresence = CY_SMIF_NOT_PRESENT;
1333 device->readStsRegQeCmd->cmdPresence = CY_SMIF_NOT_PRESENT;
1334 #endif /* CY_IP_MXSMIF_VERSION */
1335 break;
1336 case CY_SMIF_SFDP_QER_1:
1337 case CY_SMIF_SFDP_QER_4:
1338 case CY_SMIF_SFDP_QER_5:
1339 device->stsRegQuadEnableMask = CY_SMIF_SFDP_QE_BIT_1_OF_SR_2;
1340
1341 /* The command to write into the QE-containing status register */
1342 /* The 8-bit command. QE WRSR */
1343 device->writeStsRegQeCmd->command = CY_SMIF_WRITE_STATUS_REG1_CMD;
1344 device->readStsRegQeCmd->command = CY_SMIF_READ_STATUS_REG2_T1_CMD;
1345 #if (CY_IP_MXSMIF_VERSION>=2)
1346 device->writeStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1347 device->readStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1348 #endif /* CY_IP_MXSMIF_VERSION */
1349 break;
1350 case CY_SMIF_SFDP_QER_2:
1351 device->stsRegQuadEnableMask = CY_SMIF_SFDP_QE_BIT_6_OF_SR_1;
1352
1353 /* The command to write into the QE-containing status register */
1354 /* The 8-bit command. QE WRSR */
1355 device->writeStsRegQeCmd->command = CY_SMIF_WRITE_STATUS_REG1_CMD;
1356 device->readStsRegQeCmd->command = CY_SMIF_READ_STATUS_REG1_CMD;
1357 #if (CY_IP_MXSMIF_VERSION>=2)
1358 device->writeStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1359 device->readStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1360 #endif /* CY_IP_MXSMIF_VERSION */
1361 break;
1362 case CY_SMIF_SFDP_QER_3:
1363 device->stsRegQuadEnableMask = CY_SMIF_SFDP_QE_BIT_7_OF_SR_2;
1364
1365 /* The command to write into the QE-containing status register */
1366 /* The 8-bit command. QE WRSR */
1367 device->writeStsRegQeCmd->command = CY_SMIF_WRITE_STATUS_REG2_T1_CMD;
1368 device->readStsRegQeCmd->command = CY_SMIF_READ_STATUS_REG2_T2_CMD;
1369 #if (CY_IP_MXSMIF_VERSION>=2)
1370 device->writeStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1371 device->readStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1372 #endif /* CY_IP_MXSMIF_VERSION */
1373 break;
1374 case CY_SMIF_SFDP_QER_6:
1375 device->stsRegQuadEnableMask = CY_SMIF_SFDP_QE_BIT_1_OF_SR_2;
1376
1377 /* The command to write into the QE-containing status register */
1378 /* The 8-bit command. QE WRSR */
1379 device->writeStsRegQeCmd->command = CY_SMIF_WRITE_STATUS_REG2_T2_CMD;
1380 device->readStsRegQeCmd->command = CY_SMIF_READ_STATUS_REG2_T1_CMD;
1381 #if (CY_IP_MXSMIF_VERSION>=2)
1382 device->writeStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1383 device->readStsRegQeCmd->cmdPresence = CY_SMIF_PRESENT_1BYTE;
1384 #endif /* CY_IP_MXSMIF_VERSION */
1385 break;
1386 default:
1387 /* Unsupported quad enable requirement */
1388 break;
1389 }
1390 }
1391
1392 /*******************************************************************************
1393 * Function Name: XipRegInit
1394 ****************************************************************************//**
1395 *
1396 * \internal
1397 * This function initializes the memory device registers used for the XIP mode of
1398 * the specified device.
1399 *
1400 * \param dev
1401 * The SMIF memory device registers structure. \ref SMIF_DEVICE_Type
1402 *
1403 * \param memCfg
1404 * The memory configuration structure that configures the SMIF memory device to
1405 * map into the PSoC memory map. \ref cy_stc_smif_mem_config_t
1406 *
1407 *******************************************************************************/
XipRegInit(SMIF_DEVICE_Type volatile * dev,cy_stc_smif_mem_config_t const * memCfg)1408 __STATIC_INLINE void XipRegInit(SMIF_DEVICE_Type volatile *dev, cy_stc_smif_mem_config_t const * memCfg)
1409 {
1410 cy_stc_smif_mem_device_cfg_t const * devCfg = memCfg->deviceCfg;
1411 cy_stc_smif_mem_cmd_t const * read = devCfg->readCmd;
1412 cy_stc_smif_mem_cmd_t const * prog = devCfg->programCmd;
1413
1414 SMIF_DEVICE_ADDR(dev) = (SMIF_DEVICE_ADDR_ADDR_Msk & memCfg->baseAddress);
1415
1416 /* Convert the size in the mask */
1417 SMIF_DEVICE_MASK(dev)= (SMIF_DEVICE_MASK_MASK_Msk & (~(memCfg->memMappedSize) + 1UL));
1418
1419 #if (CY_IP_MXSMIF_VERSION>=2)
1420 SMIF_DEVICE_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_ADDR_CTL_SIZE3, (devCfg->numOfAddrBytes - 1UL)) |
1421 ((0UL != memCfg->dualQuadSlots)? SMIF_DEVICE_ADDR_CTL_DIV2_Msk: 0UL);
1422
1423 if((memCfg->flags & CY_SMIF_FLAG_SMIF_REV_3) != 0UL)
1424 {
1425 if(NULL != read)
1426 {
1427 SMIF_DEVICE_RD_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->command) ?
1428 (_VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_CODE, (uint32_t)read->command) |
1429 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_CODEH, (uint32_t)read->commandH) |
1430 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_DDR_MODE, (uint32_t)read->cmdRate) |
1431 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_WIDTH, (uint32_t)read->cmdWidth) |
1432 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_PRESENT2, (uint32_t)read->cmdPresence))
1433 : 0U;
1434 SMIF_DEVICE_RD_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_ADDR_CTL_WIDTH, (uint32_t)read->addrWidth) |
1435 _VAL2FLD(SMIF_DEVICE_RD_ADDR_CTL_DDR_MODE, (uint32_t)read->addrRate);
1436
1437 SMIF_DEVICE_RD_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->mode) ?
1438 (_VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_CODE, (uint32_t)read->mode) |
1439 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_CODEH, (uint32_t)read->modeH) |
1440 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_WIDTH, (uint32_t)read->modeWidth) |
1441 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_DDR_MODE, (uint32_t)read->modeRate) |
1442 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_PRESENT2, read->modePresence))
1443 : 0U;
1444
1445 SMIF_DEVICE_RD_DUMMY_CTL(dev) = (0UL != read->dummyCycles)?
1446 (_VAL2FLD(SMIF_DEVICE_RD_DUMMY_CTL_SIZE5, (read->dummyCycles - 1UL)) |
1447 _VAL2FLD(SMIF_DEVICE_RD_DUMMY_CTL_PRESENT2,read->dummyCyclesPresence))
1448 : 0U;
1449
1450 SMIF_DEVICE_RD_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_DATA_CTL_WIDTH, (uint32_t)read->dataWidth) |
1451 _VAL2FLD(SMIF_DEVICE_RD_DATA_CTL_DDR_MODE, (uint32_t)read->dataRate);
1452 }
1453
1454 if(NULL != prog)
1455 {
1456 SMIF_DEVICE_WR_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->command) ?
1457 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_CODE, (uint32_t)prog->command) |
1458 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_CODEH, (uint32_t)prog->commandH) |
1459 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_DDR_MODE, (uint32_t)prog->cmdRate) |
1460 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_WIDTH, (uint32_t)prog->cmdWidth) |
1461 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_PRESENT2, prog->cmdPresence)
1462 : 0U;
1463
1464 SMIF_DEVICE_WR_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_ADDR_CTL_WIDTH, (uint32_t)prog->addrWidth) |
1465 _VAL2FLD(SMIF_DEVICE_WR_ADDR_CTL_DDR_MODE, (uint32_t)prog->addrRate);
1466
1467 SMIF_DEVICE_WR_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->mode) ?
1468 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_CODE, (uint32_t)prog->mode) |
1469 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_CODEH, (uint32_t)prog->modeH) |
1470 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_WIDTH, (uint32_t)prog->modeWidth) |
1471 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_DDR_MODE, (uint32_t)prog->modeRate) |
1472 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_PRESENT2, prog->modePresence)
1473 : 0UL;
1474
1475 SMIF_DEVICE_WR_DUMMY_CTL(dev) = (0UL != prog->dummyCycles) ?
1476 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_SIZE5, (prog->dummyCycles - 1UL)) |
1477 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_PRESENT2, prog->dummyCyclesPresence)) |
1478 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_RWDS_EN, (prog->dummyCyclesPresence == CY_SMIF_NOT_PRESENT) ? 0UL : 1UL)))
1479 : 0U;
1480
1481 SMIF_DEVICE_WR_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_DATA_CTL_WIDTH, (uint32_t)prog->dataWidth) |
1482 _VAL2FLD(SMIF_DEVICE_WR_DATA_CTL_DDR_MODE, (uint32_t)prog->dataRate);
1483 }
1484 }
1485 else
1486 {
1487 if(NULL != read)
1488 {
1489 SMIF_DEVICE_RD_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->command) ?
1490 (_VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_CODE, (uint32_t)read->command) |
1491 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_WIDTH, (uint32_t)read->cmdWidth) |
1492 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_PRESENT2, 1UL))
1493 : 0U;
1494
1495 SMIF_DEVICE_RD_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_ADDR_CTL_WIDTH, (uint32_t)read->addrWidth);
1496
1497 SMIF_DEVICE_RD_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->mode) ?
1498 (_VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_CODE, (uint32_t)read->mode) |
1499 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_WIDTH, (uint32_t)read->modeWidth)|
1500 _VAL2FLD(SMIF_DEVICE_RD_MODE_CTL_PRESENT2, 1UL))
1501 : 0U;
1502
1503 SMIF_DEVICE_RD_DUMMY_CTL(dev) = (0UL != read->dummyCycles)?
1504 (_VAL2FLD(SMIF_DEVICE_RD_DUMMY_CTL_SIZE5, (read->dummyCycles - 1UL)) |
1505 _VAL2FLD(SMIF_DEVICE_RD_DUMMY_CTL_PRESENT2, 1UL))
1506 : 0U;
1507
1508 SMIF_DEVICE_RD_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_DATA_CTL_WIDTH, (uint32_t)read->dataWidth);
1509 }
1510
1511 if(NULL != prog)
1512 {
1513 SMIF_DEVICE_WR_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->command) ?
1514 (_VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_CODE, (uint32_t)prog->command) |
1515 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_WIDTH, (uint32_t)prog->cmdWidth)|
1516 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_PRESENT2, 1UL))
1517 : 0U;
1518
1519 SMIF_DEVICE_WR_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_ADDR_CTL_WIDTH, (uint32_t)prog->addrWidth);
1520
1521 SMIF_DEVICE_WR_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->mode) ?
1522 (_VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_CODE, (uint32_t)prog->mode) |
1523 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_WIDTH, (uint32_t)prog->modeWidth)|
1524 _VAL2FLD(SMIF_DEVICE_WR_MODE_CTL_PRESENT2, 1UL))
1525 : 0UL;
1526
1527 SMIF_DEVICE_WR_DUMMY_CTL(dev) = (0UL != prog->dummyCycles) ?
1528 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_SIZE5, (prog->dummyCycles - 1UL)) |
1529 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_PRESENT2, 1UL)))
1530 : 0U;
1531
1532 SMIF_DEVICE_WR_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_DATA_CTL_WIDTH, (uint32_t)prog->dataWidth);
1533 }
1534 }
1535 #else
1536 SMIF_DEVICE_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_ADDR_CTL_SIZE2, (devCfg->numOfAddrBytes - 1UL)) |
1537 ((0UL != memCfg->dualQuadSlots)? SMIF_DEVICE_ADDR_CTL_DIV2_Msk: 0UL);
1538
1539 if(NULL != read)
1540 {
1541 SMIF_DEVICE_RD_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->command) ?
1542 (_VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_CODE, (uint32_t)read->command) |
1543 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_WIDTH, (uint32_t)read->cmdWidth) |
1544 SMIF_DEVICE_RD_CMD_CTL_PRESENT_Msk)
1545 : 0U;
1546
1547 SMIF_DEVICE_RD_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_ADDR_CTL_WIDTH, (uint32_t)read->addrWidth);
1548
1549 SMIF_DEVICE_RD_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != read->mode) ?
1550 (_VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_CODE, (uint32_t)read->mode) |
1551 _VAL2FLD(SMIF_DEVICE_RD_CMD_CTL_WIDTH, (uint32_t)read->modeWidth)|
1552 SMIF_DEVICE_RD_CMD_CTL_PRESENT_Msk)
1553 : 0U;
1554
1555 SMIF_DEVICE_RD_DUMMY_CTL(dev) = (0UL != read->dummyCycles)?
1556 (_VAL2FLD(SMIF_DEVICE_RD_DUMMY_CTL_SIZE5, (read->dummyCycles - 1UL)) |
1557 SMIF_DEVICE_RD_DUMMY_CTL_PRESENT_Msk)
1558 : 0U;
1559
1560 SMIF_DEVICE_RD_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_RD_DATA_CTL_WIDTH, (uint32_t)read->dataWidth);
1561 }
1562
1563 if(NULL != prog)
1564 {
1565 SMIF_DEVICE_WR_CMD_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->command) ?
1566 (_VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_CODE, (uint32_t)prog->command) |
1567 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_WIDTH, (uint32_t)prog->cmdWidth)|
1568 SMIF_DEVICE_WR_CMD_CTL_PRESENT_Msk)
1569 : 0U;
1570
1571 SMIF_DEVICE_WR_ADDR_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_ADDR_CTL_WIDTH, (uint32_t)prog->addrWidth);
1572
1573 SMIF_DEVICE_WR_MODE_CTL(dev) = (CY_SMIF_NO_COMMAND_OR_MODE != prog->mode) ?
1574 (_VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_CODE, (uint32_t)prog->mode) |
1575 _VAL2FLD(SMIF_DEVICE_WR_CMD_CTL_WIDTH, (uint32_t)prog->modeWidth)|
1576 SMIF_DEVICE_WR_CMD_CTL_PRESENT_Msk)
1577 : 0UL;
1578
1579 SMIF_DEVICE_WR_DUMMY_CTL(dev) = (0UL != prog->dummyCycles) ?
1580 (_VAL2FLD(SMIF_DEVICE_WR_DUMMY_CTL_SIZE5, (prog->dummyCycles - 1UL)) |
1581 SMIF_DEVICE_WR_DUMMY_CTL_PRESENT_Msk)
1582 : 0U;
1583
1584 SMIF_DEVICE_WR_DATA_CTL(dev) = _VAL2FLD(SMIF_DEVICE_WR_DATA_CTL_WIDTH, (uint32_t)prog->dataWidth);
1585 }
1586 #endif /* CY_IP_MXSMIF_VERSION */
1587 }
1588 /*******************************************************************************
1589 * Function Name: ReadAnyReg
1590 ****************************************************************************//**
1591 *
1592 * This function reads any registers by address. This function is a blocking
1593 * function, it will block the execution flow until the status register is read.
1594 *
1595 * \param base
1596 * Holds the base address of the SMIF block registers.
1597 *
1598 * \param slaveSelect
1599 * The slave select line for the device.
1600 *
1601 * \param value
1602 * The value of the register.
1603 *
1604 * \param command
1605 * The command required to read the status/configuration register.
1606 *
1607 * \param dummyCycles
1608 * Number of latency cycles to be issue after sending register address.
1609 *
1610 * \param address
1611 * The register address array.
1612 *
1613 * \param addressSize
1614 * The size of the address array.
1615 *
1616 * \param context
1617 * This is the pointer to the context structure \ref cy_stc_smif_context_t
1618 * allocated by the user. The structure is used during the SMIF
1619 * operation for internal configuration and data retention. The user must not
1620 * modify anything in this structure.
1621 *
1622 * \return A status of the command reception.
1623 * - \ref CY_SMIF_SUCCESS
1624 * - \ref CY_SMIF_CMD_FIFO_FULL
1625 * - \ref CY_SMIF_EXCEED_TIMEOUT
1626 * - \ref CY_SMIF_CMD_NOT_FOUND
1627 *
1628 *******************************************************************************/
ReadAnyReg(SMIF_Type * base,cy_en_smif_slave_select_t slaveSelect,uint8_t * value,uint8_t command,uint8_t dummyCycles,uint8_t const * address,uint32_t addressSize,cy_stc_smif_context_t const * context)1629 __STATIC_INLINE cy_en_smif_status_t ReadAnyReg(SMIF_Type *base,
1630 cy_en_smif_slave_select_t slaveSelect,
1631 uint8_t *value,
1632 uint8_t command,
1633 uint8_t dummyCycles,
1634 uint8_t const *address,
1635 uint32_t addressSize,
1636 cy_stc_smif_context_t const *context)
1637 {
1638 cy_en_smif_status_t result = CY_SMIF_CMD_NOT_FOUND;
1639
1640 /* Read the memory register */
1641 result = Cy_SMIF_TransmitCommand(base, command, CY_SMIF_WIDTH_SINGLE,
1642 address, addressSize,
1643 CY_SMIF_WIDTH_SINGLE, slaveSelect,
1644 CY_SMIF_TX_NOT_LAST_BYTE, context);
1645
1646 if ((CY_SMIF_SUCCESS == result) && (dummyCycles != 0U))
1647 {
1648 result = Cy_SMIF_SendDummyCycles(base, dummyCycles);
1649 }
1650
1651 if (CY_SMIF_SUCCESS == result)
1652 {
1653 result = Cy_SMIF_ReceiveDataBlocking( base, value,
1654 CY_SMIF_READ_ONE_BYTE, CY_SMIF_WIDTH_SINGLE, context);
1655 }
1656
1657 return(result);
1658 }
1659 /*******************************************************************************
1660 * Function Name: ValueToByteArray
1661 ****************************************************************************//**
1662 *
1663 * Unpacks 0-numBytes from a 4-byte value into the byte array byteArray.
1664 *
1665 * \param value
1666 * The 4-byte value to unpack.
1667 *
1668 * \param byteArray
1669 * The byte array to fill.
1670 *
1671 * \param startPos
1672 * The start position of the array to begin filling from.
1673 *
1674 * \param size
1675 * The size of the array.
1676 *
1677 *
1678 *******************************************************************************/
ValueToByteArray(uint32_t value,uint8_t * byteArray,uint32_t startPos,uint32_t size)1679 static void ValueToByteArray(uint32_t value, uint8_t *byteArray, uint32_t startPos, uint32_t size)
1680 {
1681 do
1682 {
1683 size--;
1684 byteArray[size + startPos] = (uint8_t)(value & PARAM_ID_LSB_MASK);
1685 value >>= PARAM_ID_MSB_OFFSET; /* Shift to get the next byte */
1686 } while (size > 0U);
1687 }
1688
1689
1690 /*******************************************************************************
1691 * Function Name: ByteArrayToValue
1692 ****************************************************************************//**
1693 *
1694 * Packs the byte array into a single value.
1695 *
1696 * \param byteArray
1697 * The byte array to unpack.
1698 *
1699 * \param size
1700 * The size of the array.
1701 *
1702 * \return
1703 * The 4-byte value filled from the array.
1704 *
1705 *
1706 *******************************************************************************/
ByteArrayToValue(uint8_t const * byteArray,uint32_t size)1707 static uint32_t ByteArrayToValue(uint8_t const *byteArray, uint32_t size)
1708 {
1709 uint32_t value = 0UL;
1710 uint32_t idx = 0UL;
1711 for (idx = 0UL; idx < size; idx++)
1712 {
1713 value <<= 8;
1714 value |= ((uint32_t) byteArray[idx]);
1715 }
1716 return value;
1717 }
1718
1719 #if defined(__cplusplus)
1720 }
1721 #endif
1722
1723 #endif /* CY_IP_MXSMIF */
1724
1725 #endif /* (CY_SMIF_MEMORYSLOT_H) */
1726
1727
1728 /* [] END OF FILE */
1729