PSoC 6 Hardware Abstraction Layer (HAL)

General Description

High level interface for interacting with Cypress internal flash memory.

This driver allows data to be read from and written to flash. It also provides the ability to obtain information about the address and characteristics of the flash block(s) contained on the device.

Data Structures

struct  cyhal_flash_block_info_t
 Information about a single block of flash memory. More...
 
struct  cyhal_flash_info_t
 Information about all of the blocks of flash memory. More...
 

Macros

#define CYHAL_FLASH_RSLT_ERR_ADDRESS   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_FLASH, 0))
 

Functions

cy_rslt_t cyhal_flash_init (cyhal_flash_t *obj)
 
void cyhal_flash_free (cyhal_flash_t *obj)
 
void cyhal_flash_get_info (const cyhal_flash_t *obj, cyhal_flash_info_t *info)
 
cy_rslt_t cyhal_flash_read (cyhal_flash_t *obj, uint32_t address, uint8_t *data, size_t size)
 
cy_rslt_t cyhal_flash_erase (cyhal_flash_t *obj, uint32_t address)
 
cy_rslt_t cyhal_flash_write (cyhal_flash_t *obj, uint32_t address, const uint32_t *data)
 
cy_rslt_t cyhal_flash_program (cyhal_flash_t *obj, uint32_t address, const uint32_t *data)
 
cy_rslt_t cyhal_flash_start_erase (cyhal_flash_t *obj, uint32_t address)
 
cy_rslt_t cyhal_flash_start_write (cyhal_flash_t *obj, uint32_t address, const uint32_t *data)
 
cy_rslt_t cyhal_flash_start_program (cyhal_flash_t *obj, uint32_t address, const uint32_t *data)
 
bool cyhal_flash_is_operation_complete (cyhal_flash_t *obj)
 

Data Structure Documentation

◆ cyhal_flash_block_info_t

struct cyhal_flash_block_info_t
Data Fields
uint32_t start_address Start address of the memory.
uint32_t size Size of the flash memory.
uint32_t sector_size Sector size of the memory.
uint32_t page_size Sector size of the memory.
uint8_t erase_value The flash erase value.

◆ cyhal_flash_info_t

struct cyhal_flash_info_t
Data Fields
uint8_t block_count The number of distinct flash blocks.
const cyhal_flash_block_info_t * blocks Array of the distinct flash blocks.

Macro Definition Documentation

◆ CYHAL_FLASH_RSLT_ERR_ADDRESS

#define CYHAL_FLASH_RSLT_ERR_ADDRESS   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_FLASH, 0))

Invalid argument

Function Documentation

◆ cyhal_flash_init()

cy_rslt_t cyhal_flash_init ( cyhal_flash_t *  obj)

Initialize the flash_t object for access to flash through the HAL

Parameters
[out]objThe flash object
Returns
The status of the init request

◆ cyhal_flash_free()

void cyhal_flash_free ( cyhal_flash_t *  obj)

Free resources associated with access to flash through the HAL

Parameters
[out]objThe flash object.

◆ cyhal_flash_get_info()

void cyhal_flash_get_info ( const cyhal_flash_t *  obj,
cyhal_flash_info_t *  info 
)

Gets key flash characteristics including the start address size, and erase values

Parameters
[in]objThe flash object.
[out]infoThe flash configuration info.

◆ cyhal_flash_read()

cy_rslt_t cyhal_flash_read ( cyhal_flash_t *  obj,
uint32_t  address,
uint8_t *  data,
size_t  size 
)

Read data starting at defined address

Parameters
[in]objThe flash object.
[in]addressAddress to begin reading from.
[out]dataThe buffer to read data into.
[in]sizeThe number of bytes to read.
Returns
The status of the read request.

◆ cyhal_flash_erase()

cy_rslt_t cyhal_flash_erase ( cyhal_flash_t *  obj,
uint32_t  address 
)

Erase one page starting at defined address. The address must be at page boundary. This will block until the erase operation is complete.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total erase size.
Parameters
[in]objThe flash object
[in]addressThe page starting address
Returns
The status of the erase request

◆ cyhal_flash_write()

cy_rslt_t cyhal_flash_write ( cyhal_flash_t *  obj,
uint32_t  address,
const uint32_t *  data 
)

Write one page starting at defined address. The address must be at page boundary. This will block until the write operation is complete. This function erases the page prior to writing the new data.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total write size. The provided data buffer must be at least as large as the flash page_size.
Parameters
[in]objThe flash object
[in]addressThe page starting address
[in]dataThe data to write to the flash
Returns
The status of the write request

◆ cyhal_flash_program()

cy_rslt_t cyhal_flash_program ( cyhal_flash_t *  obj,
uint32_t  address,
const uint32_t *  data 
)

Program one page starting at defined address. The address must be at page boundary. This will block until the write operation is complete. Note: This function does not erase the page prior to writing. The page must be erased first via a separate call to erase.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total program size. The provided data buffer must be at least as large as the flash page_size.
Parameters
[in]objThe flash object
[in]addressThe sector starting address
[in]dataThe data buffer to be programmed
Returns
The status of the program request

◆ cyhal_flash_start_erase()

cy_rslt_t cyhal_flash_start_erase ( cyhal_flash_t *  obj,
uint32_t  address 
)

Starts an asynchronous erase of a single page of flash. Returns immediately and reports a successful start or reason for failure.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total erase size.
Parameters
[in]objThe Flash object being operated on
[in]addressThe address to start erasing from
Returns
The status of the start_erase request

◆ cyhal_flash_start_write()

cy_rslt_t cyhal_flash_start_write ( cyhal_flash_t *  obj,
uint32_t  address,
const uint32_t *  data 
)

Starts an asynchronous write to a single page of flash. Returns immediately and reports a successful start or reason for failure.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total write size. The provided data buffer must be at least as large as the flash page_size.
Parameters
[in]objThe Flash object being operated on
[in]addressThe address to start writing to
[in]dataThe data to write to flash
Returns
The status of the start_write request

◆ cyhal_flash_start_program()

cy_rslt_t cyhal_flash_start_program ( cyhal_flash_t *  obj,
uint32_t  address,
const uint32_t *  data 
)

Starts asynchronous programming of a single page of flash. Returns immediately and reports a successful start or reason for failure.

See also
cyhal_flash_get_info() to get the flash charactoristics for legal address values and the total program size. The provided data buffer must be at least as large as the flash page_size.
Parameters
[in]objThe Flash object being operated on
[in]addressThe address to start programming
[in]dataThe data to write to flash
Returns
The status of the start_program request

◆ cyhal_flash_is_operation_complete()

bool cyhal_flash_is_operation_complete ( cyhal_flash_t *  obj)

Reports a successful operation result, reason of failure or busy status

Parameters
[in]objThe Flash object being operated on
Returns
Whether the flash operation is complete