Functions | |
void | Cy_Flash_Init (void) |
Initiates all needed prerequisites to support flash erase/write. 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_EraseSector (uint32_t sectorAddr) |
This function erases a sector of flash. 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_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_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_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_StartWrite (uint32_t rowAddr, const uint32_t *data) |
Performs pre-program, erase and then starts programming the flash row with the input data. 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... | |
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_RowChecksum (uint32_t rowAddr, uint32_t *checksumPtr) |
Returns a checksum value of the specified flash row. 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... | |
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_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.
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_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.
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. |
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.
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 erase operation is performing. Refer to the device datasheet for the details. Address must match row start address. |
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.
sectorAddr | 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. |
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.
sectorAddr | 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 erase operation is performing. Refer to the device datasheet for the details. Address must match row start address. |
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.
subSectorAddr | 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. |
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.
subSectorAddr | 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 erase operation is performing. Refer to the device datasheet for the details. Address must match row start address. |
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.
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 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. |
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.
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 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. |
cy_en_flashdrv_status_t Cy_Flash_StartWrite | ( | uint32_t | rowAddr, |
const uint32_t * | data | ||
) |
Performs pre-program, erase and then 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.
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. |
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.
rowAddr | The 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. |
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. |
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 ).
cy_en_flashdrv_status_t Cy_Flash_RowChecksum | ( | uint32_t | rowAddr, |
uint32_t * | checksumPtr | ||
) |
Returns a checksum value of the specified flash row.
rowAddr | The address of the flash row. |
checksumPtr | The pointer to the address where checksum is to be stored |
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.
data | Start the data address. |
numberOfBytes | The hash value is calculated for the number of bytes after the start data address (0 - 1 byte, 1- 2 bytes etc). |
hashPtr | The pointer to the address where hash is to be stored |
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.
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.
This function is called in the Cy_Flash_Init() function - see the Cy_Flash_Init usage considerations.