Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
stream_flash.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, 2020 Nordic Semiconductor ASA
3 * Copyright (c) 2017 Linaro Limited
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13#ifndef ZEPHYR_INCLUDE_STORAGE_STREAM_FLASH_H_
14#define ZEPHYR_INCLUDE_STORAGE_STREAM_FLASH_H_
15
23#include <stdbool.h>
24#include <drivers/flash.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
45typedef int (*stream_flash_callback_t)(uint8_t *buf, size_t len, size_t offset);
46
54 uint8_t *buf; /* Write buffer */
55 size_t buf_len; /* Length of write buffer */
56 size_t buf_bytes; /* Number of bytes currently stored in write buf */
57 const struct device *fdev; /* Flash device */
58 size_t bytes_written; /* Number of bytes written to flash */
59 size_t offset; /* Offset from base of flash device to write area */
60 size_t available; /* Available bytes in write area */
61 stream_flash_callback_t callback; /* Callback invoked after write op */
62#ifdef CONFIG_STREAM_FLASH_ERASE
63 off_t last_erased_page_start_offset; /* Last erased offset */
64#endif
65};
66
83int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev,
84 uint8_t *buf, size_t buf_len, size_t offset, size_t size,
96
115 size_t len, bool flush);
116
130
146 const char *settings_key);
147
158 const char *settings_key);
159
170 const char *settings_key);
171
172#ifdef __cplusplus
173}
174#endif
175
180#endif /* ZEPHYR_INCLUDE_STORAGE_STREAM_FLASH_H_ */
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition: asm-macro-32-bit-gnu.h:17
Public API for FLASH drivers.
int stream_flash_progress_load(struct stream_flash_ctx *ctx, const char *settings_key)
Load persistent stream write progress stored with key settings_key .
int(* stream_flash_callback_t)(uint8_t *buf, size_t len, size_t offset)
Signature for callback invoked after flash write completes.
Definition: stream_flash.h:45
int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev, uint8_t *buf, size_t buf_len, size_t offset, size_t size, stream_flash_callback_t cb)
Initialize context needed for stream writes to flash.
int stream_flash_progress_save(struct stream_flash_ctx *ctx, const char *settings_key)
Save persistent stream write progress using key settings_key .
int stream_flash_erase_page(struct stream_flash_ctx *ctx, off_t off)
Erase the flash page to which a given offset belongs.
int stream_flash_buffered_write(struct stream_flash_ctx *ctx, const uint8_t *data, size_t len, bool flush)
Process input buffers to be written to flash device in single blocks. Will store remainder between ca...
size_t stream_flash_bytes_written(struct stream_flash_ctx *ctx)
Read number of bytes written to the flash.
int stream_flash_progress_clear(struct stream_flash_ctx *ctx, const char *settings_key)
Clear persistent stream write progress stored with key settings_key .
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
Structure for stream flash context.
Definition: stream_flash.h:53
stream_flash_callback_t callback
Definition: stream_flash.h:61
uint8_t * buf
Definition: stream_flash.h:54
size_t offset
Definition: stream_flash.h:59
size_t bytes_written
Definition: stream_flash.h:58
size_t buf_bytes
Definition: stream_flash.h:56
const struct device * fdev
Definition: stream_flash.h:57
size_t available
Definition: stream_flash.h:60
size_t buf_len
Definition: stream_flash.h:55
static fdata_t data[2]
Definition: test_fifo_contexts.c:15