MTB CAT1 Peripheral driver library

General Description

Functions

void Cy_Flashc_MainWriteEnable (void)
 Enable writing to main flash. More...
 
void Cy_Flashc_MainWriteDisable (void)
 Disable writing to main flash Disables writing to main flash. More...
 
void Cy_Flashc_WorkWriteEnable (void)
 Enable writing work flash Work Flash embedded operations are enabled. More...
 
void Cy_Flashc_WorkWriteDisable (void)
 Disable writing work flash Work Flash embedded operations are blocked. More...
 
void Cy_Flashc_WorkECCEnable (void)
 Enables ECC for work flash ECC checking/reporting on FLASH work interface is enabled. More...
 
void Cy_Flashc_WorkECCDisable (void)
 Disables ECC for work flash ECC checking/reporting on FLASH work interface is disabled. More...
 
void Cy_Flashc_MainECCEnable (void)
 Enables ECC for main flash ECC checking/reporting on FLASH main interface is enabled. More...
 
void Cy_Flashc_MainECCDisable (void)
 Disables ECC for main flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_Program_WorkFlash (const cy_stc_flash_programrow_config_t *config)
 This function writes an array data to work flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_Program (const cy_stc_flash_programrow_config_t *config, cy_en_flash_driver_blocking_t block)
 This function writes an array of data to flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_Checksum (const cy_stc_flash_checksum_config_t *config, uint32_t *checksumPtr)
 Returns a checksum value of the specified flash row. More...
 
cy_en_flashdrv_status_t Cy_Flash_EraseSuspend (void)
 This function suspends an ongoing erase operation. More...
 
cy_en_flashdrv_status_t Cy_Flash_EraseResume (const cy_stc_flash_eraseresume_config_t *config)
 This function calls to resume a suspended erase operation. More...
 
cy_en_flashdrv_status_t Cy_Flash_BlankCheck (const cy_stc_flash_blankcheck_config_t *config, cy_en_flash_driver_blocking_t block)
 This function performs blank check on the addressed work FLASH. More...
 
cy_en_flashdrv_status_t Cy_Flash_OperationStatus (void)
 Checks the status of the Flash Operation, and returns it. More...
 
cy_en_flashdrv_status_t Cy_Flashc_InjectECC (cy_en_region_t region, uint32_t address, uint8_t parity)
 This function enables ECC injection and sets the address where a parity will be injected and the parity value. More...
 
void Cy_Flashc_InjectECC_Disable (cy_en_region_t region)
 This function disables ECC injection for the region specified. More...
 
cy_en_flashdrv_status_t Cy_Flash_EraseRow (uint32_t rowAddr)
 This function erases a single row of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_StartEraseRow (uint32_t rowAddr)
 Starts erasing a single row of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_EraseSubsector (uint32_t subSectorAddr)
 This function erases an 8-row subsector of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_StartEraseSubsector (uint32_t subSectorAddr)
 Starts erasing an 8-row subsector of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_WriteRow (uint32_t rowAddr, const uint32_t *data)
 This function writes an array of data to a single row of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_StartProgram (uint32_t rowAddr, const uint32_t *data)
 Starts writing an array of data to a single row of flash. More...
 
uint32_t Cy_Flash_GetExternalStatus (void)
 This function handles the case where a module such as security image captures a system call from this driver and reports its own status or error code, for example protection violation. More...
 
void Cy_Flash_InitExt (cy_stc_flash_notify_t *ipcWaitMessageAddr)
 Initiates all needed prerequisites to support flash erase/write. More...
 
void Cy_Flashc_SetWorkBankMode (cy_en_bankmode_t mode)
 Sets bank mode for work flash. More...
 
cy_en_bankmode_t Cy_Flashc_GetWorkBankMode (void)
 Gets current bank mode for work flash. More...
 
void Cy_Flashc_SetMainBankMode (cy_en_bankmode_t mode)
 Sets bank mode for main flash. More...
 
cy_en_bankmode_t Cy_Flashc_GetMainBankMode (void)
 Gets current bank mode for main flash. More...
 
void Cy_Flashc_SetMain_Flash_Mapping (cy_en_maptype_t mapping)
 Sets mapping for main flash region. More...
 
void Cy_Flashc_SetWork_Flash_Mapping (cy_en_maptype_t mapping)
 Sets mapping for work flash region. More...
 
cy_en_flashdrv_status_t Cy_Flash_IsOperationComplete (void)
 Reports a successful operation result, reason of failure or busy status ( CY_FLASH_DRV_OPCODE_BUSY ). More...
 
cy_en_flashdrv_status_t Cy_Flash_StartWrite (uint32_t rowAddr, const uint32_t *data)
 Starts programming the flash row with the input data. More...
 
cy_en_flashdrv_status_t Cy_Flash_StartEraseSector (uint32_t sectorAddr)
 Starts erasing a sector of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_ProgramRow (uint32_t rowAddr, const uint32_t *data)
 This function writes an array of data to a single row of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_EraseSector (uint32_t sectorAddr)
 This function erases a sector of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_CalculateHash (const uint32_t *data, uint32_t numberOfBytes, uint32_t *hashPtr)
 Returns a hash value of the specified region of flash. More...
 
cy_en_flashdrv_status_t Cy_Flash_RowChecksum (uint32_t rowAddr, uint32_t *checksumPtr)
 Returns a checksum value of the specified flash row. More...
 
void Cy_Flash_Init (void)
 Initiates all needed prerequisites to support flash erase/write. More...
 
cy_en_flashdrv_status_t Cy_Flash_Init (bool refresh_enable)
 Initiates all needed prerequisites to support flash erase/write. More...
 
cy_en_flashdrv_status_t Cy_Flash_Refresh (uint32_t flashAddr)
 This is a blocking call. More...
 
cy_en_flashdrv_status_t Cy_Flash_Refresh_Start (uint32_t flashAddr)
 This is a non-blocking call. More...
 
bool Cy_Flash_Is_Refresh_Required (void)
 Checks if a flash refresh is needed for the sector. More...
 
void Cy_Flashc_ECCEnable (void)
 Enables ECC for flash ECC checking/reporting on FLASH interface is enabled. More...
 
void Cy_Flashc_ECCDisable (void)
 Disables ECC for flash ECC checking/reporting on FLASH interface is disabled. More...
 
void Cy_Flashc_INJ_ECCEnable (void)
 This function enable ECC error injection for FLASH interface And is applicable while ECC is enabled. More...
 
void Cy_Flashc_INJ_ECCDisable (void)
 This function disables ECC error injection for FLASH interface. More...
 
void Cy_Flashc_InjectECC (uint32_t address, uint8_t parity)
 This function enables ECC injection and sets the address where a parity will be injected and the parity value. More...
 
cy_en_flash_ecc_inject_errors_t Cy_Flashc_Get_ECC_Error (void)
 This function when ECC injection is enabled and error is injected will return no of errors generated. More...
 
void Cy_Flashc_Dual_Bank_Mode_Enable (cy_en_flash_dual_bank_mapping_t mapping)
 Enables Dual bank Mode for flash. More...
 
void Cy_Flashc_Dual_Bank_Mode_Disable (void)
 Disables Dual bank Mode for flash. More...
 

Function Documentation

◆ Cy_Flashc_MainWriteEnable()

void Cy_Flashc_MainWriteEnable ( void  )

Enable writing to main flash.

Enables writing to main flash.

Note
This function is applicable for CAT1C devices.
Returns
none

Enable writing to main flash.

◆ Cy_Flashc_MainWriteDisable()

void Cy_Flashc_MainWriteDisable ( void  )

Disable writing to main flash Disables writing to main flash.

Note
This function is applicable for CAT1C devices.
Returns
none

Disable writing to main flash Disables writing to main flash.

◆ Cy_Flashc_WorkWriteEnable()

void Cy_Flashc_WorkWriteEnable ( void  )

Enable writing work flash Work Flash embedded operations are enabled.

Note
This function is applicable for CAT1C devices.
Returns
none

Enable writing work flash Work Flash embedded operations are enabled.

◆ Cy_Flashc_WorkWriteDisable()

void Cy_Flashc_WorkWriteDisable ( void  )

Disable writing work flash Work Flash embedded operations are blocked.

Note
This function is applicable for CAT1C devices.
Returns
none

Disable writing work flash Work Flash embedded operations are blocked.

◆ Cy_Flashc_WorkECCEnable()

void Cy_Flashc_WorkECCEnable ( void  )

Enables ECC for work flash ECC checking/reporting on FLASH work interface is enabled.

Correctable or non-correctable faults are reported by enabling ECC.

Note
This function is applicable for CAT1C devices.
Returns
none

Enables ECC for work flash ECC checking/reporting on FLASH work interface is enabled.

◆ Cy_Flashc_WorkECCDisable()

void Cy_Flashc_WorkECCDisable ( void  )

Disables ECC for work flash ECC checking/reporting on FLASH work interface is disabled.

No correctable or non-correctable faults are reported by disabling ECC.

Note
This function is applicable for CAT1C devices.
Returns
none

Disables ECC for work flash ECC checking/reporting on FLASH work interface is disabled.

◆ Cy_Flashc_MainECCEnable()

void Cy_Flashc_MainECCEnable ( void  )

Enables ECC for main flash ECC checking/reporting on FLASH main interface is enabled.

Correctable or non-correctable faults are reported by enabling ECC.

Note
This function is applicable for CAT1C devices.
Returns
none

Enables ECC for main flash ECC checking/reporting on FLASH main interface is enabled.

◆ Cy_Flashc_MainECCDisable()

void Cy_Flashc_MainECCDisable ( void  )

Disables ECC for main flash.

ECC checking/reporting on FLASH main interface is disabled. No correctable or non-correctable faults are reported by disabling ECC.

Note
This function is applicable for CAT1C devices.
Returns
none

◆ Cy_Flash_Program_WorkFlash()

cy_en_flashdrv_status_t Cy_Flash_Program_WorkFlash ( const cy_stc_flash_programrow_config_t config)

This function writes an array data to work flash.

Reports success or or a reason for failure. User should only pass work flash address else it will return an error. This function executes in blocking mode only.

Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. User firmware should not enter the hibernate mode until flash Write is complete. The Flash operation is allowed in Sleep and Deep-sleep modes. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1C devices.
User needs to make sure that the data pointer passed to this function points to 32 byte aligned data.
Parameters
configconfiguration of this function. This parameter is defined by the cy_stc_flash_programrow_config_t in Structures macro.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t).
Function Usage
uint32_t data = 0x55;
cy_stc_flash_programrow_config_t flash_programrow_config =
{
.destAddr = (const uint32_t *)CY_FLASH_BASE,
.dataAddr = (const uint32_t *)&data,
};
result = Cy_Flash_Program_WorkFlash(&flash_programrow_config);
if(result != CY_FLASH_DRV_SUCCESS)
{
//handle Error
}
This function writes an array data to work flash.

Reports success or or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. User firmware should not enter the hibernate mode until flash Write is complete. The Flash operation is allowed in Sleep and Deep-sleep modes. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

config configuration of this function. This parameter is defined by the cy_stc_flash_programrow_config_t in group_flash_srom_config_structure macro.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

Note: row or page is same and of the size 512 bytes

◆ Cy_Flash_Program()

This function writes an array of data to flash.

Reports success or or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. User firmware should not enter the hibernate mode until flash Write is complete. The Flash operation is allowed in Sleep and Deep-sleep modes. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1C devices.
User needs to make sure that the data pointer passed to this function points to 32 byte aligned data.
Parameters
configconfiguration of this function. This parameter is defined by the cy_stc_flash_programrow_config_t in Structures macro.
blockspecifies if the function to execute in blocking or non blocking mode.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t). returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error in non blocking mode. returns CY_FLASH_DRV_SUCCESS in blocking mode.
Function Usage
uint32_t data = 0x55;
cy_stc_flash_programrow_config_t flash_programrow_config =
{
.destAddr = (const uint32_t *)CY_FLASH_BASE,
.dataAddr = (const uint32_t *)&data,
};
result = Cy_Flash_Program(&flash_programrow_config, CY_FLASH_DRIVER_BLOCKING);
if(result != CY_FLASH_DRV_SUCCESS)
{
//handle Error
}
This function writes an array of data to flash.

Reports success or or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. User firmware should not enter the hibernate mode until flash Write is complete. The Flash operation is allowed in Sleep and Deep-sleep modes. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

config configuration of this function. This parameter is defined by the cy_stc_flash_programrow_config_t in group_flash_srom_config_structure macro.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

Note: row or page is same and of the size 512 bytes

◆ Cy_Flash_Checksum()

cy_en_flashdrv_status_t Cy_Flash_Checksum ( const cy_stc_flash_checksum_config_t config,
uint32_t *  checksumPtr 
)

Returns a checksum value of the specified flash row.

supports only blocking mode for now.

Note
This function is applicable for CAT1C devices.
Parameters
configconfiguration of this function. This parameter is defined by the cy_stc_flash_checksum_config_t in cy_stc_flash_checksum_config_t macro.
checksumPtrThe pointer to the address where checksum is to be stored
Returns
Returns the status of the Flash operation.
Function Usage
uint32_t checksumPtr;
cy_stc_flash_checksum_config_t flash_computechecksum_config =
{
.rowId = 0,
};
result = Cy_Flash_Checksum(&flash_computechecksum_config, &checksumPtr);
if(result != CY_FLASH_DRV_SUCCESS)
{
//handle Error
}
supports only blocking mode for now. rowNum The Checksum is calculated to the flash row.

checksumPtr The pointer to the address where checksum is to be stored

Returns the status of the Flash operation.

Note:row or page is same and of the size 512 bytes

◆ Cy_Flash_EraseSuspend()

cy_en_flashdrv_status_t Cy_Flash_EraseSuspend ( void  )

This function suspends an ongoing erase operation.

User should not read from a sector which is suspended from an erase operation. Cy_Flash_ProgramRow function will return error if invoked on suspended sector. This function cannot be called on SFLASH. Reports success or a reason for failure. Does not return until the Erase operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. This function supports only blocking mode for now.

Note
This function is applicable for CAT1C devices.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

User should not read from a sector which is suspended from an erase operation. Cy_Flash_ProgramRow function will return error if invoked on suspended sector. This function cannot be called on SFLASH. Reports success or a reason for failure. Does not return until the Erase operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash. This function supports only blocking mode for now.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

◆ Cy_Flash_EraseResume()

cy_en_flashdrv_status_t Cy_Flash_EraseResume ( const cy_stc_flash_eraseresume_config_t config)

This function calls to resume a suspended erase operation.

Reports success or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1C devices.
Parameters
configconfiguration of this function. This parameter is defined by the cy_stc_flash_eraseresume_config_t in Structures macro.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

Reports success or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash.

config configuration of this function. This parameter is defined by the cy_stc_flash_eraseresume_config_t in group_flash_srom_config_structure macro.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

◆ Cy_Flash_BlankCheck()

cy_en_flashdrv_status_t Cy_Flash_BlankCheck ( const cy_stc_flash_blankcheck_config_t config,
cy_en_flash_driver_blocking_t  block 
)

This function performs blank check on the addressed work FLASH.

Reports success or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash.

Note
This function is applicable for CAT1C devices.
Parameters
configconfiguration of this function. This parameter is defined by the cy_stc_flash_blankcheck_config_t in Structures macro.
blockspecifies if the function to execute in blocking or non blocking mode.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t). returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error in non blocking mode. returns CY_FLASH_DRV_SUCCESS in blocking mode.
Function Usage
/* Writing to a memory location with data is not allowed. Erasing the memory first. */
Cy_Flash_StartEraseSector((uint32_t)CY_FLASH_BASE);
// Wait for completion with counting
{
Cy_SysLib_Delay(1); /* delay one millisecond each iteration */
}
blankcheck_config.addrToBeChecked = (uint32_t*)CY_FLASH_BASE;
blankcheck_config.numOfWordsToBeChecked = CY_WORK_LES_SIZE_IN_WORD;
cy_en_flashdrv_status_t blank_check_status = Cy_Flash_BlankCheck(&blankcheck_config, CY_FLASH_DRIVER_BLOCKING);
if(blank_check_status != CY_FLASH_DRV_SUCCESS)
{
//handle error
}
flashWriteStatus = Cy_Flash_StartWrite((uint32_t)flashData, (const uint32_t *)ramData);
if(flashWriteStatus == CY_FLASH_DRV_OPERATION_STARTED)
{
{
}
/* Verify the data written into flash by comparing it with the RAM data */
if( memcmp(ramData,flashData,CY_FLASH_SIZEOF_ROW) != 0u)
{
//handle error
}
}
else /* flash write operation did not start */
{
//handle error
}
Reports success or a reason for failure. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is operating flash.

config configuration of this function. This parameter is defined by the cy_stc_flash_blankcheck_config_t in group_flash_srom_config_structure macro.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

◆ Cy_Flash_OperationStatus()

cy_en_flashdrv_status_t Cy_Flash_OperationStatus ( void  )

Checks the status of the Flash Operation, and returns it.

Returns
Driver status. returns CY_FLASH_DRV_OPERATION_STARTED if operation in non blocking mode is not complete. returns CY_FLASH_DRV_SUCCESS if the operation is complete.
Function Usage
/* Writing to a memory location with data is not allowed. Erasing the memory first. */
Cy_Flash_StartEraseSector((uint32_t)CY_FLASH_BASE);
// Wait for completion with counting
{
Cy_SysLib_Delay(1); /* delay one millisecond each iteration */
}
blankcheck_config.addrToBeChecked = (uint32_t*)CY_FLASH_BASE;
blankcheck_config.numOfWordsToBeChecked = CY_WORK_LES_SIZE_IN_WORD;
cy_en_flashdrv_status_t blank_check_status = Cy_Flash_BlankCheck(&blankcheck_config, CY_FLASH_DRIVER_BLOCKING);
if(blank_check_status != CY_FLASH_DRV_SUCCESS)
{
//handle error
}
flashWriteStatus = Cy_Flash_StartWrite((uint32_t)flashData, (const uint32_t *)ramData);
if(flashWriteStatus == CY_FLASH_DRV_OPERATION_STARTED)
{
{
}
/* Verify the data written into flash by comparing it with the RAM data */
if( memcmp(ramData,flashData,CY_FLASH_SIZEOF_ROW) != 0u)
{
//handle error
}
}
else /* flash write operation did not start */
{
//handle error
}

◆ Cy_Flashc_InjectECC() [1/2]

cy_en_flashdrv_status_t Cy_Flashc_InjectECC ( cy_en_region_t  region,
uint32_t  address,
uint8_t  parity 
)

This function enables ECC injection and sets the address where a parity will be injected and the parity value.

Reports success or a reason for failure.

Note
This function is applicable for CAT1C devices.
Parameters
regionAn indicator which region (Code/Work/Cache) ECC parity will be injected to. This parameter is defined by the cy_en_region_t in Macros macro.
addressThe address where ECC parity will be injected.
parityThe parity value which will be injected.
Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

Reports success or a reason for failure.

region An indicator which region (Code/Work/Cache) ECC parity will be injected to. This parameter is defined by the cy_en_region_t in group_flash_macro macro.

address The address where ECC parity will be injected.

parity The parity value which will be injected.

Returns the status of the Flash operation (see cy_en_flashdrv_status_t).

◆ Cy_Flashc_InjectECC_Disable()

void Cy_Flashc_InjectECC_Disable ( cy_en_region_t  region)

This function disables ECC injection for the region specified.

Parameters
region: ECC injection is disabled for this region (Code/Work/Cache). This parameter is defined by the cy_en_region_t in Macros macro.
Note
This function is applicable for CAT1C devices.
This function is applicable for CAT1C devices.

◆ Cy_Flash_EraseRow()

cy_en_flashdrv_status_t Cy_Flash_EraseRow ( uint32_t  rowAddr)

This function erases a single row of flash.

Reports success or a reason for failure. Does not return until the Write operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash or erasing the row. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, ors Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1A and CAT1B devices.
CAT1B devices doesn't use IPC for any flash operations.
Parameters
rowAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

◆ Cy_Flash_StartEraseRow()

cy_en_flashdrv_status_t Cy_Flash_StartEraseRow ( uint32_t  rowAddr)

Starts erasing a single row of flash.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when IPC structure is locked by another process. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
To avoid situation of reading data from cache memory - before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1A and CAT1B devices.
CAT1B devices doesn't use IPC for any flash operations.
Parameters
rowAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash erase operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t. returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error.

◆ Cy_Flash_EraseSubsector()

cy_en_flashdrv_status_t Cy_Flash_EraseSubsector ( uint32_t  subSectorAddr)

This function erases an 8-row subsector of flash.

Reports success or a reason for failure. Does not return until the Write operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash or erasing the row. User firmware should not enter the Hibernate or Deep-Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1A and CAT1B devices.
CAT1B devices doesn't use IPC for any flash operations.
Parameters
subSectorAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

◆ Cy_Flash_StartEraseSubsector()

cy_en_flashdrv_status_t Cy_Flash_StartEraseSubsector ( uint32_t  subSectorAddr)

Starts erasing an 8-row subsector of flash.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when IPC structure is locked by another process. User firmware should not enter the Hibernate or Deep-Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This function is applicable for CAT1A devices.
Parameters
subSectorAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash erase operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t. returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error.

◆ Cy_Flash_WriteRow()

cy_en_flashdrv_status_t Cy_Flash_WriteRow ( uint32_t  rowAddr,
const uint32_t *  data 
)

This function writes an array of data to a single row of flash.

This is done in three steps - pre-program, erase and then program flash row with the input data. Reports success or a reason for failure. Does not return until the Write operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash. User firmware should not enter the Hibernate or Deep-sleep mode until flash Write is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a blocking function and will not return until the Write operation is complete.
This function is applicable for CAT1A and CAT1B devices.
CAT1B devices doesn't use IPC for any flash operations.
Parameters
rowAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
dataThe pointer to the data which has to be written to flash. The size of the data array must be equal to the flash row size. The flash row size for the selected device is defined by the CY_FLASH_SIZEOF_ROW macro. Refer to the device datasheet for the details.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

◆ Cy_Flash_StartProgram()

cy_en_flashdrv_status_t Cy_Flash_StartProgram ( uint32_t  rowAddr,
const uint32_t *  data 
)

Starts writing an array of data to a single row of flash.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error if another process is writing to flash. The user firmware should not enter Hibernate or Deep-Sleep mode until flash Program is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.
Before calling this function, the target flash region must be erased by the StartEraseRow/EraseRow function.
Data to be programmed must be located in the SRAM memory region.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a non blocking function and will not wait until the Write operation is complete.
This function is applicable for CAT1A and CAT1B devices.
CAT1B devices doesn't use IPC for any flash operations.
Parameters
rowAddrThe address of the flash row number. The Read-while-Write violation occurs when the Flash Write operation is performing. Refer to the device datasheet for the details. The address must match the row start address.
dataThe pointer to the data to be written to flash. The size of the data array must be equal to the flash row size. The flash row size for the selected device is defined by the CY_FLASH_SIZEOF_ROW macro. Refer to the device datasheet for the details.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t. returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error.

◆ Cy_Flash_GetExternalStatus()

uint32_t Cy_Flash_GetExternalStatus ( void  )

This function handles the case where a module such as security image captures a system call from this driver and reports its own status or error code, for example protection violation.

In that case, a function from this driver returns an unknown error (see cy_en_flashdrv_status_t). After receipt of an unknown error, the user may call this function to get the status of the capturing module.

The user is responsible for parsing the content of the returned value and casting it to the appropriate enumeration.

Note
This function is applicable for CAT1A devices.
Returns
Returns the status of the Flash operation code.

◆ Cy_Flash_InitExt()

void Cy_Flash_InitExt ( cy_stc_flash_notify_t ipcWaitMessageAddr)

Initiates all needed prerequisites to support flash erase/write.

Should be called from each core. Defines the address of the message structure.

Requires a call to Cy_IPC_Sema_Init(), Cy_IPC_Pipe_Config() and Cy_IPC_Pipe_Init() functions before use.

Note
This function is applicable for CAT1A devices.

This function is called in the Cy_Flash_Init() function - see the Cy_Flash_Init usage considerations.

◆ Cy_Flashc_SetWorkBankMode()

void Cy_Flashc_SetWorkBankMode ( cy_en_bankmode_t  mode)

Sets bank mode for work flash.

Note
This function is applicable for CAT1C devices.
Parameters
modebank mode to be set
Returns
none
Function Usage
Cy_Flashc_SetWorkBankMode(set_bank_mode);
if(set_bank_mode != get_bank_mode)
{
//handle Error
}
mode bank mode to be set

◆ Cy_Flashc_GetWorkBankMode()

cy_en_bankmode_t Cy_Flashc_GetWorkBankMode ( void  )

Gets current bank mode for work flash.

Note
This function is applicable for CAT1C devices.
Returns
Current bank mode
Function Usage
Cy_Flashc_SetWorkBankMode(set_bank_mode);
if(set_bank_mode != get_bank_mode)
{
//handle Error
}

◆ Cy_Flashc_SetMainBankMode()

void Cy_Flashc_SetMainBankMode ( cy_en_bankmode_t  mode)

Sets bank mode for main flash.

Parameters
modebank mode to be set
Returns
Function Usage
Cy_Flashc_SetMainBankMode(set_bank_mode);
if(set_bank_mode != get_bank_mode)
{
//handle Error
}
mode bank mode to be set

◆ Cy_Flashc_GetMainBankMode()

cy_en_bankmode_t Cy_Flashc_GetMainBankMode ( void  )

Gets current bank mode for main flash.

Note
This function is applicable for CAT1C devices.
Returns
Current bank mode
Function Usage
Cy_Flashc_SetMainBankMode(set_bank_mode);
if(set_bank_mode != get_bank_mode)
{
//handle Error
}

◆ Cy_Flashc_SetMain_Flash_Mapping()

void Cy_Flashc_SetMain_Flash_Mapping ( cy_en_maptype_t  mapping)

Sets mapping for main flash region.

Applicable only in Dual Bank mode of Main flash region

Parameters
mappingmapping to be set
Returns
none

◆ Cy_Flashc_SetWork_Flash_Mapping()

void Cy_Flashc_SetWork_Flash_Mapping ( cy_en_maptype_t  mapping)

Sets mapping for work flash region.

Applicable only in Dual Bank mode of Work flash region

Parameters
mappingmapping to be set
Returns
none

◆ Cy_Flash_IsOperationComplete()

cy_en_flashdrv_status_t Cy_Flash_IsOperationComplete ( void  )

Reports a successful operation result, reason of failure or busy status ( CY_FLASH_DRV_OPCODE_BUSY ).

Returns
Returns the status of the Flash operation (see cy_en_flashdrv_status_t). returns CY_FLASH_DRV_OPERATION_STARTED if operation in non blocking mode is not complete. returns CY_FLASH_DRV_SUCCESS if the operation is complete.

Reports a successful operation result, reason of failure or busy status ( CY_FLASH_DRV_OPCODE_BUSY ).

◆ Cy_Flash_StartWrite()

cy_en_flashdrv_status_t Cy_Flash_StartWrite ( uint32_t  rowAddr,
const uint32_t *  data 
)

Starts programming the flash row with the input data.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash. User firmware should not enter the Hibernate or Deep-Sleep mode until flash Write is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
This is added as backword compatibility function in CAT1C devices. This function will not erase the row before writing to the row. Erase ROW is not supported in CAT1C devices. User can use Cy_Flash_EraseSector or Cy_Flash_EraseAll functions.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a non blocking function and will not wait until the Write operation is complete.
User needs to make sure that the data pointer passed to this function points to 32 byte aligned data for CAT1C devices.
Parameters
rowAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
dataThe pointer to the data to be written to flash. The size of the data array must be equal to the flash row size. The flash row size for the selected device is defined by the CY_FLASH_SIZEOF_ROW macro. Refer to the device datasheet for the details. For CAT1C devices this data pointer needs to point to 32 byte aligned data.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error. see cy_en_flashdrv_status_t.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash. User firmware should not enter the Hibernate or Deep-Sleep mode until flash Write is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.

rowAddr Address of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.

data The pointer to the data to be written to flash. The size of the data array must be equal to the flash row size. The flash row size for the selected device is defined by the CY_FLASH_SIZEOF_ROW macro. Refer to the device datasheet for the details.

Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

◆ Cy_Flash_StartEraseSector()

cy_en_flashdrv_status_t Cy_Flash_StartEraseSector ( uint32_t  sectorAddr)

Starts erasing a sector of flash.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when IPC structure is locked by another process. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a non blocking function and will not wait until the operation is complete.
Parameters
sectorAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash erase operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Returns
Returns the status of the Flash operation, returns CY_FLASH_DRV_OPERATION_STARTED if operation starts with out error. see cy_en_flashdrv_status_t.

Returns immediately and reports a successful start or reason for failure. Reports a CY_FLASH_DRV_IPC_BUSY error in the case when IPC structure is locked by another process. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, the low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes. Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.

◆ Cy_Flash_ProgramRow()

cy_en_flashdrv_status_t Cy_Flash_ProgramRow ( uint32_t  rowAddr,
const uint32_t *  data 
)

This function writes an array of data to a single row of flash.

Reports success or a reason for failure. Does not return until the Program operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash. User firmware should not enter the Hibernate or Deep-sleep mode until flash Write is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.
Before calling this function, the target flash region must be erased by the StartErase/EraseRow function.
Data to be programmed must be located in the SRAM memory region.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a blocking function and will not return until the Write operation is complete.
User needs to make sure that the data pointer passed to this function points to 32 byte aligned data for CAT1C devices.
Parameters
rowAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
dataThe pointer to the data which has to be written to flash. The size of the data array must be equal to the flash row size. The flash row size for the selected device is defined by the CY_FLASH_SIZEOF_ROW macro. Refer to the device datasheet for the details. For CAT1C devices this data pointer needs to point to 32 byte aligned data.
Note
In CAT1B devices with flash IP CY_IP_MXS40FLASHC When refresh is enabled, for each row an extra 16 bytes is used for storing refresh related data. User need to make sure that this data is not corrupted while writing and erasing the row data. When refresh is enabled row size has to be considered as CY_FLASH_SIZEOF_ROW + 16Bytes
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

Reports success or a reason for failure. Does not return until the Program operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash. User firmware should not enter the Hibernate or Deep-sleep mode until flash Write is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.
Before calling this function, the target flash region must be erased by the StartErase/EraseRow function.
Data to be programmed must be located in the SRAM memory region.

Note
Before reading data from previously programmed/erased flash rows, the user must clear the flash cache with the Cy_SysLib_ClearFlashCacheAndBuffer() function.

◆ Cy_Flash_EraseSector()

cy_en_flashdrv_status_t Cy_Flash_EraseSector ( uint32_t  sectorAddr)

This function erases a sector of flash.

Reports success or a reason for failure. Does not return until the Erase operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash or erasing the row. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Note
A Read while Write violation occurs when a flash Read operation is initiated in the same or neighboring flash sector where the flash Write, Erase, or Program operation is working. This violation may cause a HardFault exception. To avoid the Read while Write violation, use Cy_Flash_IsOperationComplete() to ensure flash operation is complete.
This is a blocking function and will not return until the erase operation is complete.
Parameters
sectorAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

Reports success or a reason for failure. Does not return until the Erase operation is complete. Returns immediately and reports a CY_FLASH_DRV_IPC_BUSY error in the case when another process is writing to flash or erasing the row. User firmware should not enter the Hibernate or Deep Sleep mode until flash Erase is complete. The Flash operation is allowed in Sleep mode. During the Flash operation, the device should not be reset, including the XRES pin, a software reset, and watchdog reset sources. Also, low-voltage detect circuits should be configured to generate an interrupt instead of a reset. Otherwise, portions of flash may undergo unexpected changes.

Parameters
sectorAddrAddress of the flash row number. The Read-while-Write violation occurs when the flash read operation is initiated in the same flash sector where the flash write operation is performing. Refer to the device datasheet for the details. Address must match row start address.
Returns
Returns the status of the Flash operation, see cy_en_flashdrv_status_t.

◆ Cy_Flash_CalculateHash()

cy_en_flashdrv_status_t Cy_Flash_CalculateHash ( const uint32_t *  data,
uint32_t  numberOfBytes,
uint32_t *  hashPtr 
)

Returns a hash value of the specified region of flash.

Parameters
dataStart the data address.
numberOfBytesThe hash value is calculated for the number of bytes after the start data address (0 - 1 byte, 1- 2 bytes etc).
hashPtrThe pointer to the address where hash is to be stored
Returns
Returns the status of the Flash operation.

◆ Cy_Flash_RowChecksum()

cy_en_flashdrv_status_t Cy_Flash_RowChecksum ( uint32_t  rowAddr,
uint32_t *  checksumPtr 
)

Returns a checksum value of the specified flash row.

Note
Now Cy_Flash_RowChecksum() requires the row address (rowAddr) as a parameter. In previous versions of the driver, this function used the row number (rowNum) for this parameter.
Parameters
rowAddrThe address of the flash row.
checksumPtrThe pointer to the address where checksum is to be stored
Returns
Returns the status of the Flash operation.
Note
Now Cy_Flash_RowChecksum() requires the row address (rowAddr) as a parameter. In previous versions of the driver, this function used the row number (rowNum) for this parameter.

rowAddr The address of the flash row.

checksumPtr The pointer to the address where checksum is to be stored

Returns the status of the Flash operation.

◆ Cy_Flash_Init() [1/2]

void Cy_Flash_Init ( void  )

Initiates all needed prerequisites to support flash erase/write.

Should be called from each core.

Requires a call to Cy_IPC_Sema_Init(), Cy_IPC_Pipe_Config() and Cy_IPC_Pipe_Init() functions before use for CAT1A devices.

This function is called in the SystemInit() function, for proper flash write and erase operations. If the default startup file is not used, or the function SystemInit() is not called in your project, ensure to perform the following steps before any flash or EmEEPROM write/erase operations:

/* 1. Allocate and initialize IPC semaphores for the system operations */
static uint32_t ipcSemaArray[CY_IPC_SEMA_COUNT / CY_IPC_SEMA_PER_WORD];
(void) Cy_IPC_Sema_Init(CY_IPC_CHAN_SEMA, CY_IPC_SEMA_COUNT, ipcSemaArray);
/* 2. Create an array of endpoint structures and configure an IPC pipe infrastructure */
Cy_IPC_Pipe_Config(ipcPipeEpArray);
/* 3. Create an array of client callbacks and initialize a system pipe by a configuration structure */
static cy_ipc_pipe_callback_ptr_t sysIpcPipeCbArray[CY_SYS_CYPIPE_CLIENT_CNT];
static const cy_stc_ipc_pipe_config_t systemIpcPipeConfig =
{
/* .ep0ConfigData */
{
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP0,
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP0,
/* .ipcNotifierMuxNumber */ CY_SYS_INTR_CYPIPE_MUX_EP0,
/* .epAddress */ CY_IPC_EP_CYPIPE_CM0_ADDR,
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP0
},
/* .ep1ConfigData */
{
/* .ipcNotifierNumber */ CY_IPC_INTR_CYPIPE_EP1,
/* .ipcNotifierPriority */ CY_SYS_INTR_CYPIPE_PRIOR_EP1,
/* .ipcNotifierMuxNumber */ 0u,
/* .epAddress */ CY_IPC_EP_CYPIPE_CM4_ADDR,
/* .epConfig */ CY_SYS_CYPIPE_CONFIG_EP1
},
/* .endpointClientsCount */ CY_SYS_CYPIPE_CLIENT_CNT,
/* .endpointsCallbacksArray */ sysIpcPipeCbArray,
/* .systemPipeIsrHandler */ &SysIpcPipeIsr
};
Cy_IPC_Pipe_Init(&systemIpcPipeConfig);
/* 4. And finally initialize the flash */
/* Ensure to run these steps on all the MCU cores */

Should be called from each core.

This function is called in the SystemInit() function, for proper flash write and erase operations. If the default startup file is not used, or the function SystemInit() is not called in your project, ensure to perform the following steps before any flash or EmEEPROM write/erase operations:

◆ Cy_Flash_Init() [2/2]

cy_en_flashdrv_status_t Cy_Flash_Init ( bool  refresh_enable)

Initiates all needed prerequisites to support flash erase/write.

Should be once before starting any flash operations.

Parameters
refresh_enableenable disable refresh feature
Returns
success if Init is complete else will return err

◆ Cy_Flash_Refresh()

cy_en_flashdrv_status_t Cy_Flash_Refresh ( uint32_t  flashAddr)

This is a blocking call.

Writes to the flash will cause slight degradation of the other cells in the flash. If the flash is written more than 100,000 times, errors may appear on flash reads. To prevent this, the refresh functions should be called before or after flash writes. The refresh functions are not available on CPUSS_FLASHC_SFLASH_SECNUM because it includes the SFLASH.

Parameters
flashAddrof the row that needs to be refreshed.
Returns
success if refresh is complete. Else will return error

◆ Cy_Flash_Refresh_Start()

cy_en_flashdrv_status_t Cy_Flash_Refresh_Start ( uint32_t  flashAddr)

This is a non-blocking call.

Writes to the flash will cause slight degradation of the other cells in the flash. If the flash is written more than 100,000 times, errors may appear on flash reads. To prevent this, the refresh functions should be called before or after flash writes. The refresh functions are not available on CPUSS_FLASHC_SFLASH_SECNUM because it includes the SFLASH.

Parameters
flashAddrof the row that needs to be refreshed.
Returns
success if refresh is started. Else will return error

◆ Cy_Flash_Is_Refresh_Required()

bool Cy_Flash_Is_Refresh_Required ( void  )

Checks if a flash refresh is needed for the sector.

This is not allowed on sector which has SFLASH

Returns
TRUE, if a refresh is needed and FALSE, if a refresh is not needed.

◆ Cy_Flashc_ECCEnable()

void Cy_Flashc_ECCEnable ( void  )

Enables ECC for flash ECC checking/reporting on FLASH interface is enabled.

Correctable or non-correctable faults are reported by enabling ECC.

Returns
none

◆ Cy_Flashc_ECCDisable()

void Cy_Flashc_ECCDisable ( void  )

Disables ECC for flash ECC checking/reporting on FLASH interface is disabled.

Correctable or non-correctable faults are not reported by disabling ECC.

Returns
none

◆ Cy_Flashc_INJ_ECCEnable()

void Cy_Flashc_INJ_ECCEnable ( void  )

This function enable ECC error injection for FLASH interface And is applicable while ECC is enabled.

Returns
none

◆ Cy_Flashc_INJ_ECCDisable()

void Cy_Flashc_INJ_ECCDisable ( void  )

This function disables ECC error injection for FLASH interface.

Returns
none

◆ Cy_Flashc_InjectECC() [2/2]

void Cy_Flashc_InjectECC ( uint32_t  address,
uint8_t  parity 
)

This function enables ECC injection and sets the address where a parity will be injected and the parity value.

Reports success or a reason for failure.

Parameters
addressThe address where ECC parity will be injected.
parityThe parity value which will be injected.
Returns
none.

◆ Cy_Flashc_Get_ECC_Error()

cy_en_flash_ecc_inject_errors_t Cy_Flashc_Get_ECC_Error ( void  )

This function when ECC injection is enabled and error is injected will return no of errors generated.

Returns
no of errors generated with ECC error injection cy_en_flash_ecc_inject_errors_t.

◆ Cy_Flashc_Dual_Bank_Mode_Enable()

void Cy_Flashc_Dual_Bank_Mode_Enable ( cy_en_flash_dual_bank_mapping_t  mapping)

Enables Dual bank Mode for flash.

Parameters
mapping: Mapping for the main and work regions.
Returns
none

◆ Cy_Flashc_Dual_Bank_Mode_Disable()

void Cy_Flashc_Dual_Bank_Mode_Disable ( void  )

Disables Dual bank Mode for flash.

Returns
none