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

Flash simulator specific API. More...

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

Go to the source code of this file.

Data Structures

struct  flash_simulator_params
 Flash simulator parameters structure. More...
struct  flash_simulator_cb
 Flash simulator callbacks structure. More...

Typedefs

typedef int(* flash_simulator_write_byte_cb_t) (const struct device *dev, off_t offset, uint8_t data)
 Flash simulator write byte callback type.
typedef int(* flash_simulator_erase_unit_cb_t) (const struct device *dev, off_t unit_offset)
 Flash simulator erase unit callback type.

Functions

const struct flash_simulator_paramsflash_simulator_get_params (const struct device *dev)
 Get flash simulator parameters.
void flash_simulator_set_callbacks (const struct device *dev, const struct flash_simulator_cb *cb)
 Set flash simulator callbacks.
void * flash_simulator_get_memory (const struct device *dev, size_t *mock_size)
 Obtain a pointer to the RAM buffer used but by the simulator.

Detailed Description

Flash simulator specific API.

Extension for flash simulator.

Typedef Documentation

◆ flash_simulator_erase_unit_cb_t

typedef int(* flash_simulator_erase_unit_cb_t) (const struct device *dev, off_t unit_offset)

Flash simulator erase unit callback type.

Callback used to overwrite unit erase operation. The callback gets the unit offset as the parameter. The offset is the same offset passed to the flash erase. The callback must return 0 in case of success or negative value in case of error.

Note
If this callback is set, the flash simulator driver will not perform any erase operation by itself.
Parameters
devFlash simulator device pointer.
unit_offsetOffset within the flash simulator memory.
Returns
0 in case of success or negative value in case of error.

◆ flash_simulator_write_byte_cb_t

typedef int(* flash_simulator_write_byte_cb_t) (const struct device *dev, off_t offset, uint8_t data)

Flash simulator write byte callback type.

Callback used to overwrite single byte write. The callback gets the requested data and offset as the parameter. The offset is the same offset passed to the flash write. The callback must return a value to be written at the specified offset or negative value in case of error.

Parameters
devFlash simulator device pointer.
offsetOffset within the flash simulator memory.
dataData byte to be written.
Returns
Value to be written at the specified offset or negative value in case of error.

Function Documentation

◆ flash_simulator_get_memory()

void * flash_simulator_get_memory ( const struct device * dev,
size_t * mock_size )

Obtain a pointer to the RAM buffer used but by the simulator.

This function allows the caller to get the address and size of the RAM buffer in which the flash simulator emulates its flash memory content.

Parameters
[in]devflash simulator device pointer.
[out]mock_sizesize of the ram buffer.
Return values
pointerto the ram buffer

◆ flash_simulator_get_params()

const struct flash_simulator_params * flash_simulator_get_params ( const struct device * dev)

Get flash simulator parameters.

This function allows the caller to get the flash simulator parameters used by the driver.

Parameters
[in]devflash simulator device pointer.
Returns
Pointer to the flash simulator parameters structure.

◆ flash_simulator_set_callbacks()

void flash_simulator_set_callbacks ( const struct device * dev,
const struct flash_simulator_cb * cb )

Set flash simulator callbacks.

This function allows the caller to set custom callbacks for byte write and unit erase operations performed by the flash simulator.

Parameters
[in]devflash simulator device pointer.
[in]cbpointer to the structure containing the callbacks.