PSoC 6 Peripheral Driver Library

General Description

Functions

cy_en_smif_status_t Cy_SMIF_MemInit (SMIF_Type *base, cy_stc_smif_block_config_t const *blockConfig, cy_stc_smif_context_t *context)
 This function initializes the slots of the memory device in the SMIF configuration. More...
 
void Cy_SMIF_MemDeInit (SMIF_Type *base)
 This function de-initializes all slave slots of the memory device to their default values. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdWriteEnable (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_context_t const *context)
 This function sends the Write Enable command to the memory device. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdWriteDisable (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_context_t const *context)
 This function sends a Write Disable command to the memory device. More...
 
bool Cy_SMIF_MemIsBusy (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_context_t const *context)
 This function checks if the status of the memory device is busy. More...
 
cy_en_smif_status_t Cy_SMIF_MemQuadEnable (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_context_t const *context)
 This function enables the memory device for the quad mode of operation. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdReadStatus (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, uint8_t *status, uint8_t command, cy_stc_smif_context_t const *context)
 This function reads the status register. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdWriteStatus (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, void const *status, uint8_t command, cy_stc_smif_context_t const *context)
 This function writes the status register. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdChipErase (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_context_t const *context)
 This function performs a chip erase of the external memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdSectorErase (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, uint8_t const *sectorAddr, cy_stc_smif_context_t const *context)
 This function performs a block Erase of the external memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdProgram (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, uint8_t const *addr, uint8_t const *writeBuff, uint32_t size, cy_smif_event_cb_t cmdCompleteCb, cy_stc_smif_context_t *context)
 This function performs the Program operation. More...
 
cy_en_smif_status_t Cy_SMIF_MemCmdRead (SMIF_Type *base, cy_stc_smif_mem_config_t const *memDevice, uint8_t const *addr, uint8_t *readBuff, uint32_t size, cy_smif_event_cb_t cmdCompleteCb, cy_stc_smif_context_t *context)
 This function performs the Read operation. More...
 
cy_en_smif_status_t Cy_SMIF_MemSfdpDetect (SMIF_Type *base, cy_stc_smif_mem_device_cfg_t *device, cy_en_smif_slave_select_t slaveSelect, cy_en_smif_data_select_t dataSelect, cy_stc_smif_context_t *context)
 This function detects the device signature for SFDP devices. More...
 
cy_en_smif_status_t Cy_SMIF_MemIsReady (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, uint32_t timeoutUs, cy_stc_smif_context_t const *context)
 Polls the memory device to check whether it is ready to accept new commands or not until either it is ready or the retries have exceeded the limit. More...
 
cy_en_smif_status_t Cy_SMIF_MemIsQuadEnabled (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, bool *isQuadEnabled, cy_stc_smif_context_t const *context)
 Checks whether the QE (Quad Enable) bit is set or not in the configuration register of the memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemEnableQuadMode (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, uint32_t timeoutUs, cy_stc_smif_context_t const *context)
 Sets the QE (QUAD Enable) bit in the external memory configuration register to enable quad SPI mode. More...
 
cy_en_smif_status_t Cy_SMIF_MemRead (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, uint32_t address, uint8_t rxBuffer[], uint32_t length, cy_stc_smif_context_t *context)
 Reads data from the external memory and blocks until the read transfer is complete or a timeout occurs. More...
 
cy_en_smif_status_t Cy_SMIF_MemWrite (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, uint32_t address, uint8_t const txBuffer[], uint32_t length, cy_stc_smif_context_t *context)
 This function writes data to the external memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemEraseSector (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, uint32_t address, uint32_t length, cy_stc_smif_context_t const *context)
 Erases a block/sector of the external memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemEraseChip (SMIF_Type *base, cy_stc_smif_mem_config_t const *memConfig, cy_stc_smif_context_t const *context)
 Erases the entire chip of the external memory. More...
 
cy_en_smif_status_t Cy_SMIF_MemLocateHybridRegion (cy_stc_smif_mem_config_t const *memDevice, cy_stc_smif_hybrid_region_info_t **regionInfo, uint32_t address)
 This function locates the region structure by the address which belongs to it. More...
 

Function Documentation

◆ Cy_SMIF_MemInit()

cy_en_smif_status_t Cy_SMIF_MemInit ( SMIF_Type base,
cy_stc_smif_block_config_t const *  blockConfig,
cy_stc_smif_context_t context 
)

This function initializes the slots of the memory device in the SMIF configuration.

This function must be called when a memory device is required to be used in memory-mapped (XIP) mode. This function can also be called instead of calling Cy_SMIF_MemSfdpDetect when SFDP auto-discovery is enabled. Note that this function performs SFDP on all the external memories whereas Cy_SMIF_MemSfdpDetect peforms it only on one memory that is specified through the arguments. This function configures the SMIF device slot registers with the configuration from cy_stc_smif_mem_config_t structure which is a member of the cy_stc_smif_block_config_t structure. If SFDP discovery is enabled in the configuration strucutre through autoDetectSfdp field, this function calls Cy_SMIF_MemSfdpDetect function for each memory, fills the structures with the discovered parameters, and configures the SMIF device slot registers accordingly. Cy_SMIF_Init must have been called prior to calling this funciton. The cy_stc_smif_context_t context structure returned from Cy_SMIF_Init is passed as a parameter to this function.

Note
4-byte addressing mode is set when the memory device supports 3- or 4-byte addressing mode.
Parameters
baseThe address of the slave-slot device register to initialize.
blockConfigThe configuration structure array that configures the SMIF memory device to be mapped into the PSoC memory map. cy_stc_smif_mem_config_t
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The memory slot initialization status.

◆ Cy_SMIF_MemDeInit()

void Cy_SMIF_MemDeInit ( SMIF_Type base)

This function de-initializes all slave slots of the memory device to their default values.

Parameters
baseHolds the base address of the SMIF block registers.

◆ Cy_SMIF_MemCmdWriteEnable()

cy_en_smif_status_t Cy_SMIF_MemCmdWriteEnable ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_context_t const *  context 
)

This function sends the Write Enable command to the memory device.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. The Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command transmission.

◆ Cy_SMIF_MemCmdWriteDisable()

cy_en_smif_status_t Cy_SMIF_MemCmdWriteDisable ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_context_t const *  context 
)

This function sends a Write Disable command to the memory device.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode this API should be called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command transmission.

◆ Cy_SMIF_MemIsBusy()

bool Cy_SMIF_MemIsBusy ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_context_t const *  context 
)

This function checks if the status of the memory device is busy.

This is done by reading the status register and the corresponding bit (stsRegBusyMask). This function is a blocking function until the status register from the memory is read.

Note
In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the memory device.
  • True - The device is busy or a timeout occurs.
  • False - The device is not busy.
Note
Check Rules for PSoC6 QSPI/SMIF Block Usage for any usage restriction

◆ Cy_SMIF_MemQuadEnable()

cy_en_smif_status_t Cy_SMIF_MemQuadEnable ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_context_t const *  context 
)

This function enables the memory device for the quad mode of operation.

This command must be executed before sending quad SPI commands to the memory device.

Note
In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command.
Note
Check Rules for PSoC6 QSPI/SMIF Block Usage for any usage restriction

◆ Cy_SMIF_MemCmdReadStatus()

cy_en_smif_status_t Cy_SMIF_MemCmdReadStatus ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
uint8_t *  status,
uint8_t  command,
cy_stc_smif_context_t const *  context 
)

This function reads the status register.

This function is a blocking function, it will block the execution flow until the status register is read.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. the Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
statusThe status register value returned by the external memory.
commandThe command required to read the status/configuration register.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command reception.
Note
Check Rules for PSoC6 QSPI/SMIF Block Usage for any usage restriction

◆ Cy_SMIF_MemCmdWriteStatus()

cy_en_smif_status_t Cy_SMIF_MemCmdWriteStatus ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
void const *  status,
uint8_t  command,
cy_stc_smif_context_t const *  context 
)

This function writes the status register.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. The Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
statusThe status to write into the status register.
commandThe command to write into the status/configuration register.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command transmission.

◆ Cy_SMIF_MemCmdChipErase()

cy_en_smif_status_t Cy_SMIF_MemCmdChipErase ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_context_t const *  context 
)

This function performs a chip erase of the external memory.

The Write Enable command is called before this API.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command transmission.

◆ Cy_SMIF_MemCmdSectorErase()

cy_en_smif_status_t Cy_SMIF_MemCmdSectorErase ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
uint8_t const *  sectorAddr,
cy_stc_smif_context_t const *  context 
)

This function performs a block Erase of the external memory.

The Write Enable command is called before this API.

Note
This function uses the low-level Cy_SMIF_TransmitCommand() API. The Cy_SMIF_TransmitCommand() API works in a blocking mode. In the dual quad mode, this API is called for each memory.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
sectorAddrThe sector address to erase.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the command transmission.

◆ Cy_SMIF_MemCmdProgram()

cy_en_smif_status_t Cy_SMIF_MemCmdProgram ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
uint8_t const *  addr,
uint8_t const *  writeBuff,
uint32_t  size,
cy_smif_event_cb_t  cmdCompleteCb,
cy_stc_smif_context_t context 
)

This function performs the Program operation.

Note
This function uses the Cy_SMIF_TransmitCommand() API. The Cy_SMIF_TransmitCommand() API works in the blocking mode. In the dual quad mode, this API works with both types of memory simultaneously.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
addrThe address to program.
writeBuffThe pointer to the data to program. If this pointer is a NULL, then the function does not enable the interrupt. This use case is typically used when the FIFO is handled outside the interrupt and is managed in either a polling-based code or a DMA. The user would handle the FIFO management in a DMA or a polling-based code. If the user provides a NULL pointer in this function and does not handle the FIFO transaction, this could either stall or timeout the operation Cy_SMIF_TransmitData().
sizeThe size of data to program. The user must ensure that the data size does not exceed the page size.
cmdCompleteCbThe callback function to call after the transfer completion. NULL interpreted as no callback.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of a transmission.

◆ Cy_SMIF_MemCmdRead()

cy_en_smif_status_t Cy_SMIF_MemCmdRead ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memDevice,
uint8_t const *  addr,
uint8_t *  readBuff,
uint32_t  size,
cy_smif_event_cb_t  cmdCompleteCb,
cy_stc_smif_context_t context 
)

This function performs the Read operation.

Note
This function uses the Cy_SMIF_TransmitCommand() API. The Cy_SMIF_TransmitCommand() API works in the blocking mode. In the dual quad mode, this API works with both types of memory simultaneously.
Parameters
baseHolds the base address of the SMIF block registers.
memDeviceThe device to which the command is sent.
addrThe address to read.
readBuffThe pointer to the variable where the read data is stored. If this pointer is a NULL, then the function does not enable the interrupt. This use case is typically used when the FIFO is handled outside the interrupt and is managed in either a polling-based code or a DMA. The user would handle the FIFO management in a DMA or a polling-based code. If the user provides a NULL pointer in this function and does not handle the FIFO transaction, this could either stall or timeout the operation Cy_SMIF_TransmitData().
sizeThe size of data to read.
cmdCompleteCbThe callback function to call after the transfer completion. NULL interpreted as no callback.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the transmission.
Note
Check Rules for PSoC6 QSPI/SMIF Block Usage for any usage restriction

◆ Cy_SMIF_MemSfdpDetect()

cy_en_smif_status_t Cy_SMIF_MemSfdpDetect ( SMIF_Type base,
cy_stc_smif_mem_device_cfg_t device,
cy_en_smif_slave_select_t  slaveSelect,
cy_en_smif_data_select_t  dataSelect,
cy_stc_smif_context_t context 
)

This function detects the device signature for SFDP devices.

Refer to the SFDP spec (JESD216B) for details. The function asks the device using an SPI and then populates the relevant parameters for cy_stc_smif_mem_device_cfg_t.

Note
This function is a blocking function and blocks until the structure data is read and returned. This function uses Cy_SMIF_TransmitCommand() If there is no support for SFDP in the memory device, the API returns an error condition. The function requires:
The SFDP detect takes into account the types of the SPI supported by the memory device and also the dataSelect option selected to choose which SPI mode (SPI, DSPI, QSPI) to load into the structures. The algorithm prefers QSPI>DSPI>SPI, provided there is support for it in the memory device and the dataSelect selected by the user.
4-byte addressing mode is set when the memory device supports 3- or 4-byte addressing mode.
When the Erase command is not found the width of the command transfer (cmdWidth) is set to CY_SMIF_WIDTH_NA. When the Program command is not found for 4 byte addressing mode the Program command instruction is set for 1S-1S-1S Protocol mode and 3-byte addressing mode.
Parameters
baseHolds the base address of the SMIF block registers.
deviceThe device structure instance declared by the user. This is where the detected parameters are stored and returned.
slaveSelectThe slave select line for the device.
dataSelectThe data line selection options for a slave device.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
A status of the transmission.

◆ Cy_SMIF_MemIsReady()

cy_en_smif_status_t Cy_SMIF_MemIsReady ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
uint32_t  timeoutUs,
cy_stc_smif_context_t const *  context 
)

Polls the memory device to check whether it is ready to accept new commands or not until either it is ready or the retries have exceeded the limit.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
timeoutUsThe timeout value in microseconds to apply while polling the memory.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. CY_SMIF_SUCCESS - Memory is ready to accept new commands. CY_SMIF_EXCEED_TIMEOUT - Memory is busy.
Function Usage
/* Scenario: Wait until the erase operation is completed.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
#define TIMEOUT (10000UL) /* 10 msec timeout */
/* Wait until the erase operation is completed or a timeout occurs */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemIsReady(SMIF, smifBlockConfig.memConfig[0], TIMEOUT, &SMIF_context))
{
/* Insert error handling */
}

◆ Cy_SMIF_MemIsQuadEnabled()

cy_en_smif_status_t Cy_SMIF_MemIsQuadEnabled ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
bool *  isQuadEnabled,
cy_stc_smif_context_t const *  context 
)

Checks whether the QE (Quad Enable) bit is set or not in the configuration register of the memory.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
isQuadEnabledThis parameter is updated to indicate whether quad mode is enabled (true) or not (false). The value is valid only when the function returns CY_SMIF_SUCCESS.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Function Usage
/* Scenario: Check whether Quad mode (1-1-4 or 1-4-4 modes) is enabled. If Quad mode is disabled,
* then enable it to use all the four I/Os during communication.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
/* Timeout in microseconds to apply while polling the memory for its ready status after quad
* enable command has been sent out. Quad enable is a non-volatile write.
*/
#define QUAD_ENABLE_TIMEOUT (5000UL) /* 5 miliseconds */
bool isQuadEnabled = false;
/* Check whether Quad mode is enabled */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemIsQuadEnabled(SMIF, smifBlockConfig.memConfig[0], &isQuadEnabled, &SMIF_context))
{
/* Insert error handling */
}
if (!isQuadEnabled)
{
/* Enable Quad Mode */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemEnableQuadMode(SMIF, smifBlockConfig.memConfig[0], QUAD_ENABLE_TIMEOUT, &SMIF_context))
{
/* Insert error handling */
}
}

◆ Cy_SMIF_MemEnableQuadMode()

cy_en_smif_status_t Cy_SMIF_MemEnableQuadMode ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
uint32_t  timeoutUs,
cy_stc_smif_context_t const *  context 
)

Sets the QE (QUAD Enable) bit in the external memory configuration register to enable quad SPI mode.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
timeoutUsThe timeout value in microseconds to apply while polling the memory.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Function Usage
See Cy_SMIF_MemIsQuadEnabled usage.

◆ Cy_SMIF_MemRead()

cy_en_smif_status_t Cy_SMIF_MemRead ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
uint32_t  address,
uint8_t  rxBuffer[],
uint32_t  length,
cy_stc_smif_context_t context 
)

Reads data from the external memory and blocks until the read transfer is complete or a timeout occurs.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
addressThe address to read data from.
rxBufferThe buffer for storing the read data.
lengthThe size of data to read.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Function Usage
/* Scenario: Read 64 bytes of data from the external memory into the rxBuffer array.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
#define READ_PACKET_SIZE (64U) /* Data Buffer size */
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
uint32_t extMemAddress = 0x00UL; /* Address = 0x00000000 (4 bytes) */
uint8_t rxBuffer[READ_PACKET_SIZE];
/* Read data from the external memory */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemRead(SMIF, smifBlockConfig.memConfig[0], extMemAddress, rxBuffer, READ_PACKET_SIZE, &SMIF_context))
{
/* Insert error handling */
}

◆ Cy_SMIF_MemWrite()

cy_en_smif_status_t Cy_SMIF_MemWrite ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
uint32_t  address,
uint8_t const  txBuffer[],
uint32_t  length,
cy_stc_smif_context_t context 
)

This function writes data to the external memory.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
addressThe address to write data at.
txBufferThe buffer holding the data to write in the external memory.
lengthThe size of data to write.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Function Usage
/* Scenario: Write 64 bytes of data from the txBuffer array into the external memory.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
#define WRITE_PACKET_SIZE (64U) /* Data Buffer size */
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
uint32_t extMemAddress = 0x00UL; /* Address = 0x00000000 */
uint8_t txBuffer[WRITE_PACKET_SIZE];
/* Write data into the external memory */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemWrite(SMIF, smifBlockConfig.memConfig[0], extMemAddress, txBuffer, WRITE_PACKET_SIZE, &SMIF_context))
{
/* Insert error handling */
}

◆ Cy_SMIF_MemEraseSector()

cy_en_smif_status_t Cy_SMIF_MemEraseSector ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
uint32_t  address,
uint32_t  length,
cy_stc_smif_context_t const *  context 
)

Erases a block/sector of the external memory.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
addressThe address of the block to be erased. The address should be aligned with the start address of the sector.
lengthThe size of data to erase. The length should be equal to the sum of all sectors length to be erased.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Note
Memories like hybrid have sectors of different sizes.
Check the adress and length parameters before calling this function.
Function Usage
/* Scenario: Erase one sector of the external memory.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
uint32_t extMemAddress = 0x00UL; /* Address = 0x00000000 */
uint32_t length = smifBlockConfig.memConfig[0]->deviceCfg->eraseSize; /* The sector size */
/* Erase a sector of the external memory */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemEraseSector(SMIF, smifBlockConfig.memConfig[0], extMemAddress, length, &SMIF_context))
{
/* Insert error handling */
}

◆ Cy_SMIF_MemEraseChip()

cy_en_smif_status_t Cy_SMIF_MemEraseChip ( SMIF_Type base,
cy_stc_smif_mem_config_t const *  memConfig,
cy_stc_smif_context_t const *  context 
)

Erases the entire chip of the external memory.

This is a blocking function, it will block the execution flow until the command transmission is completed.

Parameters
baseHolds the base address of the SMIF block registers.
memConfigThe memory device configuration.
contextThis is the pointer to the context structure cy_stc_smif_context_t allocated by the user. The structure is used during the SMIF operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
The status of the operation. See cy_en_smif_status_t.
Function Usage
/* Scenario: Erase the entire chip.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
/* Erase the entire chip */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemEraseChip(SMIF, smifBlockConfig.memConfig[0], &SMIF_context))
{
/* Insert error handling */
}

◆ Cy_SMIF_MemLocateHybridRegion()

cy_en_smif_status_t Cy_SMIF_MemLocateHybridRegion ( cy_stc_smif_mem_config_t const *  memDevice,
cy_stc_smif_hybrid_region_info_t **  regionInfo,
uint32_t  address 
)

This function locates the region structure by the address which belongs to it.

Note
This function is valid for the memories with hybrid sectors.
Parameters
memDeviceThe memory device configuration.
regionInfoPlaces a hybrid region configuration structure that contains the region specific parameters. See cy_stc_smif_hybrid_region_info_t for reference.
addressThe address for which a region is searched.
Returns
A status of the region location.
Function Usage
/* Scenario: Get the erase size for a specific region.
* Erase one sector of the external memory.
* The SMIF/QSPI configuration tool generates the smifBlockConfig structure
* needed for the memslot level API usage.
*/
cy_stc_smif_hybrid_region_info_t *currentRegionInfo = NULL; /* The pointer to the structure
* which defines the region
* we are searching for.*/
cy_stc_smif_context_t SMIF_context; /* This is a shared context structure.
* It must be global
*/
uint32_t regionAddress = 0x00UL; /* The address for which a region is searched */
/* Update the currentRegion with a pointer to the region the address belongs to */
Cy_SMIF_MemLocateHybridRegion(smifBlockConfig.memConfig[0], &currentRegionInfo, regionAddress);
/* Populate the erase size and erase time from the region structure */
uint32_t regionEraseSize = currentRegionInfo->eraseSize;
/* Erase a sector of the external memory */
if (CY_SMIF_SUCCESS != Cy_SMIF_MemEraseSector(SMIF, smifBlockConfig.memConfig[0], regionAddress, regionEraseSize, &SMIF_context))
{
/* Insert error handling */
}