Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
retention.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_RETENTION_
13#define ZEPHYR_INCLUDE_RETENTION_
14
15#include <stdint.h>
16#include <stddef.h>
17#include <sys/types.h>
18#include <zephyr/kernel.h>
19#include <zephyr/device.h>
20#include <zephyr/types.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
33typedef ssize_t (*retention_size_api)(const struct device *dev);
34typedef int (*retention_is_valid_api)(const struct device *dev);
35typedef int (*retention_read_api)(const struct device *dev, off_t offset, uint8_t *buffer,
36 size_t size);
37typedef int (*retention_write_api)(const struct device *dev, off_t offset,
38 const uint8_t *buffer, size_t size);
39typedef int (*retention_clear_api)(const struct device *dev);
40
47};
48
57ssize_t retention_size(const struct device *dev);
58
69int retention_is_valid(const struct device *dev);
70
82int retention_read(const struct device *dev, off_t offset, uint8_t *buffer, size_t size);
83
96int retention_write(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size);
97
105int retention_clear(const struct device *dev);
106
111#ifdef __cplusplus
112}
113#endif
114
115#endif /* ZEPHYR_INCLUDE_RETENTION_ */
int(* retention_write_api)(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size)
Definition: retention.h:37
int retention_write(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size)
Writes data to the retention area (underlying data does not need to be cleared prior to writing),...
int(* retention_read_api)(const struct device *dev, off_t offset, uint8_t *buffer, size_t size)
Definition: retention.h:35
ssize_t(* retention_size_api)(const struct device *dev)
Definition: retention.h:33
int retention_read(const struct device *dev, off_t offset, uint8_t *buffer, size_t size)
Reads data from the retention area.
int(* retention_clear_api)(const struct device *dev)
Definition: retention.h:39
int retention_is_valid(const struct device *dev)
Checks if the underlying data in the retention area is valid or not.
int retention_clear(const struct device *dev)
Clears all data in the retention area (sets it to 0)
int(* retention_is_valid_api)(const struct device *dev)
Definition: retention.h:34
ssize_t retention_size(const struct device *dev)
Returns the size of the retention area.
Public kernel APIs.
__SIZE_TYPE__ ssize_t
Definition: types.h:28
__INTPTR_TYPE__ off_t
Definition: types.h:36
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition: device.h:381
Definition: retention.h:41
retention_write_api write
Definition: retention.h:45
retention_is_valid_api is_valid
Definition: retention.h:43
retention_clear_api clear
Definition: retention.h:46
retention_size_api size
Definition: retention.h:42
retention_read_api read
Definition: retention.h:44