Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
flash.h File Reference

Public API for FLASH drivers. More...

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

Go to the source code of this file.

Data Structures

struct  flash_pages_layout
 
struct  flash_parameters
 Flash memory parameters. More...
 
struct  flash_driver_api
 
struct  flash_pages_info
 

Macros

#define FLASH_ERASE_C_EXPLICIT   0x01
 Set for ordinary Flash where erase is needed before write of random data.
 
#define FLASH_ERASE_CAPS_UNSET   (int)-1
 Reserved for users as initializer for variables that will later store capabilities.
 
#define FLASH_ERASE_C_SUPPORTED   0x02
 
#define FLASH_ERASE_C_VAL_BIT   0x04
 
#define FLASH_ERASE_UNIFORM_PAGE   0x08
 
#define FLASH_EX_OP_VENDOR_BASE   0x8000
 
#define FLASH_EX_OP_IS_VENDOR(c)
 

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.
 
typedef int(* flash_api_erase) (const struct device *dev, off_t offset, size_t size)
 Flash erase implementation handler type.
 
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.
 
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 int(* flash_api_ex_op) (const struct device *dev, uint16_t code, const uintptr_t in, void *out)
 
typedef bool(* flash_page_cb) (const struct flash_pages_info *info, void *data)
 Callback type for iterating over flash pages present on a device.
 

Enumerations

enum  flash_ex_op_types { FLASH_EX_OP_RESET = 0 }
 Enumeration for extra flash operations. More...
 

Functions

static int flash_params_get_erase_cap (const struct flash_parameters *p)
 
int flash_read (const struct device *dev, off_t offset, void *data, size_t len)
 Read data from flash.
 
int flash_write (const struct device *dev, off_t offset, const void *data, size_t len)
 Write buffer into flash memory.
 
int flash_erase (const struct device *dev, off_t offset, size_t size)
 Erase part or all of a flash memory.
 
int flash_fill (const struct device *dev, uint8_t val, off_t offset, size_t size)
 Fill selected range of device with specified value.
 
int flash_flatten (const struct device *dev, off_t offset, size_t size)
 Erase part or all of a flash memory or level it.
 
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.
 
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.
 
size_t flash_get_page_count (const struct device *dev)
 Get the total number of flash pages.
 
void flash_page_foreach (const struct device *dev, flash_page_cb cb, void *data)
 Iterate over all flash pages on a device.
 
int flash_sfdp_read (const struct device *dev, off_t offset, void *data, size_t len)
 Read data from Serial Flash Discoverable Parameters.
 
int flash_read_jedec_id (const struct device *dev, uint8_t *id)
 Read the JEDEC ID from a compatible flash device.
 
size_t flash_get_write_block_size (const struct device *dev)
 Get the minimum write block size supported by the driver.
 
const struct flash_parametersflash_get_parameters (const struct device *dev)
 Get pointer to flash_parameters structure.
 
int flash_ex_op (const struct device *dev, uint16_t code, const uintptr_t in, void *out)
 Execute flash extended operation on given device.
 
int flash_copy (const struct device *src_dev, off_t src_offset, const struct device *dst_dev, off_t dst_offset, off_t size, uint8_t *buf, size_t buf_size)
 Copy flash memory from one device to another.
 

Detailed Description

Public API for FLASH drivers.