EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #760 background imageLoading...
Page #760 background image
Chapter 2. API Reference
Parameters
chip: Pointer to identify flash chip. Must have been successfully initialised via esp_flash_init()
[out] out_regions: Pointer to receive a pointer to the array of protectable regions of the
chip.
[out] out_num_regions: Pointer to an integer receiving the count of protectable regions in
the array returned in regions.
esp_err_t esp_flash_get_protected_region(esp_flash_t *chip, const esp_flash_region_t
*region, bool *out_protected)
Detect if a region of the SPI flash chip is protected.
Note It is possible for this result to be false and write operations to still fail, if protection is enabled for the
entire chip.
Note Correct behaviour of this function depends on the SPI flash chip model and chip_drv in use (via the
chip->drvfield).
Return ESP_OK on success, or a flash error code if operation failed.
Parameters
chip: Pointer to identify flash chip. Must have been successfully initialised via esp_flash_init()
region: Pointer to a struct describing a protected region. This must match one of the regions
returned from esp_flash_get_protectable_regions().
[out] out_protected: Pointer to a flag which is set based on the protected status for this
region.
esp_err_t esp_flash_set_protected_region(esp_flash_t *chip, const esp_flash_region_t
*region, bool protect)
Update the protected status for a region of the SPI flash chip.
Note It is possible for the region protection flag to be cleared and write operations to still fail, if protection is
enabled for the entire chip.
Note Correct behaviour of this function depends on the SPI flash chip model and chip_drv in use (via the
chip->drvfield).
Return ESP_OK on success, or a flash error code if operation failed.
Parameters
chip: Pointer to identify flash chip. Must have been successfully initialised via esp_flash_init()
region: Pointer to a struct describing a protected region. This must match one of the regions
returned from esp_flash_get_protectable_regions().
protect: Write protection flag to set.
esp_err_t esp_flash_read(esp_flash_t *chip, void *buffer, uint32_t address, uint32_t length)
Read data from the SPI flash chip.
There are no alignment constraints on buffer, address or length.
Parameters
chip: Pointer to identify flash chip. Must have been successfully initialised via esp_flash_init()
buffer: Pointer to a buffer where the data will be read. To get better performance, this should be
in the DRAM and word aligned.
address: Address on flash to read from. Must be less than chip->size field.
length: Length (in bytes) of data to read.
Note If on-chip flash encryption is used, this function returns raw (ie encrypted) data. Use the flash cache to
transparently decrypt data.
Return
ESP_OK: success
ESP_ERR_NO_MEM: Buffer is in external PSRAM which cannot be concurrently accessed, and a
temporary internal buffer could not be allocated.
or a flash error code if operation failed.
esp_err_t esp_flash_write(esp_flash_t *chip, const void *buer, uint32_t address, uint32_t length)
Write data to the SPI flash chip.
There are no alignment constraints on buffer, address or length.
Parameters
Espressif Systems 749
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish