Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
flash.h File Reference

Public API for FLASH drivers. More...

#include <zephyr/types.h>
#include <stddef.h>
#include <sys/types.h>
#include <device.h>
#include <syscalls/flash.h>

Go to the source code of this file.

Data Structures

struct  flash_pages_layout
 
struct  flash_parameters
 
struct  flash_driver_api
 
struct  flash_pages_info
 

Typedefs

typedef int(* flash_api_read) (const struct device *dev, off_t offset, void *data, size_t len)
 
typedef int(* flash_api_write) (const struct device *dev, off_t offset, const void *data, size_t len)
 Flash write implementation handler type. More...
 
typedef int(* flash_api_erase) (const struct device *dev, off_t offset, size_t size)
 Flash erase implementation handler type. More...
 
typedef int(* flash_api_write_protection) (const struct device *dev, bool enable)
 
typedef const struct flash_parameters *(* flash_api_get_parameters) (const struct device *dev)
 
typedef void(* flash_api_pages_layout) (const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size)
 Retrieve a flash device's layout. More...
 
typedef int(* flash_api_sfdp_read) (const struct device *dev, off_t offset, void *data, size_t len)
 
typedef int(* flash_api_read_jedec_id) (const struct device *dev, uint8_t *id)
 
typedef bool(* flash_page_cb) (const struct flash_pages_info *info, void *data)
 Callback type for iterating over flash pages present on a device. More...
 

Functions

int flash_read (const struct device *dev, off_t offset, void *data, size_t len)
 Read data from flash. More...
 
int flash_write (const struct device *dev, off_t offset, const void *data, size_t len)
 Write buffer into flash memory. More...
 
int flash_erase (const struct device *dev, off_t offset, size_t size)
 Erase part or all of a flash memory. More...
 
int flash_write_protection_set (const struct device *dev, bool enable)
 Enable or disable write protection for a flash memory. More...
 
int flash_get_page_info_by_offs (const struct device *dev, off_t offset, struct flash_pages_info *info)
 Get the size and start offset of flash page at certain flash offset. More...
 
int flash_get_page_info_by_idx (const struct device *dev, uint32_t page_index, struct flash_pages_info *info)
 Get the size and start offset of flash page of certain index. More...
 
size_t flash_get_page_count (const struct device *dev)
 Get the total number of flash pages. More...
 
void flash_page_foreach (const struct device *dev, flash_page_cb cb, void *data)
 Iterate over all flash pages on a device. More...
 
int flash_sfdp_read (const struct device *dev, off_t offset, void *data, size_t len)
 Read data from Serial Flash Discoverable Parameters. More...
 
int flash_read_jedec_id (const struct device *dev, uint8_t *id)
 Read the JEDEC ID from a compatible flash device. More...
 
size_t flash_get_write_block_size (const struct device *dev)
 Get the minimum write block size supported by the driver. More...
 
const struct flash_parametersflash_get_parameters (const struct device *dev)
 Get pointer to flash_parameters structure. More...
 

Detailed Description

Public API for FLASH drivers.