PebbleOS
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions | Variables
flash.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <system/status_codes.h>

Data Structures

struct  FlashSecurityRegisters
 Security (OTP) registers of the flash part. More...
 

Typedefs

typedef void(* FlashOperationCompleteCb) (void *context, status_t result)
 Flash operation completion callback.
 

Enumerations

enum  FlashModeType { FLASH_MODE_ASYNC = 0 , FLASH_MODE_SYNC_BURST , FLASH_MODE_NUM_MODES }
 Flash read mode. More...
 

Functions

void flash_init (void)
 Initialize the flash driver and the flash part.
 
void flash_stop (void)
 Stop flash activity.
 
void flash_read_bytes (uint8_t *buffer, uint32_t start_addr, uint32_t buffer_size)
 Read from flash.
 
void flash_write_bytes (const uint8_t *buffer, uint32_t start_addr, uint32_t buffer_size)
 Write to flash.
 
void flash_erase_subsector (uint32_t subsector_addr, FlashOperationCompleteCb on_complete, void *context)
 Erase the subsector containing an address, asynchronously.
 
void flash_erase_sector (uint32_t sector_addr, FlashOperationCompleteCb on_complete, void *context)
 Erase the sector containing an address, asynchronously.
 
void flash_erase_subsector_blocking (uint32_t subsector_addr)
 Erase the subsector containing an address.
 
void flash_erase_sector_blocking (uint32_t sector_addr)
 Erase the sector containing an address.
 
bool flash_sector_is_erased (uint32_t sector_addr)
 Check whether the sector containing an address is erased.
 
bool flash_subsector_is_erased (uint32_t sector_addr)
 Check whether the subsector containing an address is erased.
 
void flash_erase_bulk (void)
 Erase the entire flash.
 
void flash_erase_optimal_range (uint32_t min_start, uint32_t max_start, uint32_t min_end, uint32_t max_end, FlashOperationCompleteCb on_complete, void *context)
 Erase a range of flash asynchronously, using as few erase operations as possible.
 
void flash_sleep_when_idle (bool enable)
 Let the flash enter deep sleep between commands.
 
bool flash_get_sleep_when_idle (void)
 Check whether flash_sleep_when_idle() is in effect.
 
bool flash_is_initialized (void)
 Check whether flash_init() has run.
 
void flash_power_down_for_stop_mode (void)
 Put the flash in deep power-down before entering stop mode.
 
void flash_power_up_after_stop_mode (void)
 Wake the flash after stop mode.
 
void flash_switch_mode (FlashModeType mode)
 Switch the read mode.
 
uint32_t flash_get_sector_base_address (uint32_t flash_addr)
 Get the base address of the sector containing an address.
 
uint32_t flash_get_subsector_base_address (uint32_t flash_addr)
 Get the base address of the subsector containing an address.
 
void flash_enable_write_protection (void)
 Enable write protection, if the part requires it to be enabled explicitly.
 
void flash_prf_set_protection (bool do_protect)
 Write-protect the recovery firmware region, or remove all protection.
 
uint32_t flash_crc32 (uint32_t flash_addr, uint32_t length)
 Compute the CRC-32 of a flash region.
 
uint32_t flash_crc32_legacy (uint32_t flash_addr, uint32_t length)
 Compute the legacy checksum of a flash region.
 
void flash_use (void)
 Take a reference keeping the flash peripheral powered.
 
void flash_release_many (uint32_t num_locks)
 Drop several references taken with flash_use().
 
status_t flash_read_security_register (uint32_t addr, uint8_t *val)
 Read a byte from a security register.
 
status_t flash_security_register_is_locked (uint32_t addr, bool *locked)
 Check whether a security register is locked.
 
status_t flash_erase_security_register (uint32_t addr)
 Erase a security register.
 
status_t flash_write_security_register (uint32_t addr, uint8_t val)
 Write a byte to a security register.
 
const FlashSecurityRegisters * flash_security_registers_info (void)
 Get the security register layout.
 

Variables

static const uint32_t EXPECTED_SPI_FLASH_ID_32MBIT = 0x20bb16
 Expected ID of a 32 Mbit part.
 
static const uint32_t EXPECTED_SPI_FLASH_ID_64MBIT = 0x20bb17
 Expected ID of a 64 Mbit part.