AFBR-S50 API Reference Manual  v1.6.5
AFBR-S50 Time-of-Flight Sensor SDK for Embedded Software
argus_nvm.h
Go to the documentation of this file.
1 /*************************************************************************/
37 #ifndef ARGUS_NVM_H
38 #define ARGUS_NVM_H
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /*!***************************************************************************
44  * @defgroup argus_nvm NVM: Non-Volatile Memory Layer
45  * @ingroup argus_hal
46  *
47  * @brief Non-Volatile Memory Layer
48  *
49  * @details This module provides functionality to access the non-volatile
50  * memory (e.g. flash) on the underlying platform.
51  *
52  * This module is optional and only required if calibration data
53  * needs to be stored within the API.
54  *
55  * @note The implementation of this module is optional for the correct
56  * execution of the API. If not implemented, a weak implementation
57  * within the API will be used that disables the NVM feature.
58  *
59  * @addtogroup argus_nvm
60  * @{
61  *****************************************************************************/
62 
63 #include "api/argus_def.h"
64 
66 #define ARGUS_NVM_BLOCK_SIZE 0x300 // 768 bytes
67 
68 /*!***************************************************************************
69  * @brief Write a block of data to the non-volatile memory.
70  *
71  * @details The function is called whenever the API wants to write data into
72  * non-volatile memory, e.g. flash. Later, the API reads the written
73  * data via the #NVM_ReadBlock function.
74  *
75  * The data shall be written to a specified memory block that is
76  * uniquely dedicated to each individual device. The /p id parameter
77  * is passed to the function that identifies the device. The /p id
78  * is composed of the device ID and module type, i.e. it is unique
79  * among all devices. If only a single device is used anyway, the
80  * /p id parameter can be ignored.
81  *
82  * If no NVM module is available, the function can return with error
83  * #ERROR_NOT_IMPLEMENTED and the API ignores the NVM.
84  *
85  * If write fails, e.g. due to lack of memory, a negative status
86  * must be returned, e.g. #ERROR_NVM_OUT_OF_RANGE.
87  *
88  * The block size is fixed for a single device. The actual block size
89  * is defined with #ARGUS_NVM_BLOCK_SIZE.
90  *
91  * @note The implementation of this function is optional for the correct
92  * execution of the API. If not implemented, a weak implementation
93  * within the API will be used that disables the NVM feature.
94  *
95  * @param id The 32-bit ID number to identify the corresponding memory block.
96  * @param block_size The number of bytes to be written. Note that this value
97  * is fixed, i.e. the API always writes the same data size.
98  * The size is defined here: #ARGUS_NVM_BLOCK_SIZE.
99  * @param buf The pointer to the data buffer of size /p block_size that needs
100  * to be written to the NVM.
101  * @return Returns the \link #status_t status\endlink (#STATUS_OK on success).
102  *****************************************************************************/
103 status_t NVM_WriteBlock(uint32_t id, uint32_t block_size, uint8_t const * buf);
104 
105 /*!***************************************************************************
106  * @brief Reads a block of data from the non-volatile memory.
107  *
108  * @details The function is called whenever the API wants to read data from
109  * non-volatile memory, e.g. flash. The data will be previously
110  * stored using the #NVM_WriteBlock function. Otherwise, the function
111  * must return a corresponding error code, namely #ERROR_NVM_EMPTY.
112  *
113  * The data shall be read from a specified memory block that is
114  * uniquely dedicated to each individual device. The /p id parameter
115  * is passed to the function that identifies the device. The /p id
116  * is composed of the device ID and module type, i.e. it is unique
117  * among all devices. If only a single device is used anyway, the
118  * /p id parameter can be ignored.
119  *
120  * If no NVM module is available, the function can return with error
121  * #ERROR_NOT_IMPLEMENTED and the API ignores the NVM.
122  *
123  * If read fails, e.g. if data has not been written previously,
124  * a negative status must be returned, e.g. #ERROR_NVM_EMPTY if no
125  * data has been written yet or any other negative error else-wise.
126  *
127  * The block size is fixed for a single device. The actual block size
128  * is defined with #ARGUS_NVM_BLOCK_SIZE.
129  *
130  * @note The implementation of this function is optional for the correct
131  * execution of the API. If not implemented, a weak implementation
132  * within the API will be used that disables the NVM feature.
133  *
134  * @param id The 32-bit ID number to identify the corresponding memory block.
135  * @param block_size The number of bytes to be read. Note that this value
136  * is fixed, i.e. the API always reads the same data size.
137  * The size is defined here: #ARGUS_NVM_BLOCK_SIZE.
138  * @param buf The pointer to the data buffer of size /p block_size to copy
139  * the data to.
140  * @return Returns the \link #status_t status\endlink (#STATUS_OK on success).
141  *****************************************************************************/
142 status_t NVM_ReadBlock(uint32_t id, uint32_t block_size, uint8_t * buf);
143 
145 #ifdef __cplusplus
146 } // extern "C"
147 #endif
148 #endif // ARGUS_NVM_H
NVM_WriteBlock
status_t NVM_WriteBlock(uint32_t id, uint32_t block_size, uint8_t const *buf)
Write a block of data to the non-volatile memory.
argus_def.h
This file is part of the AFBR-S50 hardware API.
status_t
int32_t status_t
Type used for all status and error return values.
Definition: argus_status.h:70
NVM_ReadBlock
status_t NVM_ReadBlock(uint32_t id, uint32_t block_size, uint8_t *buf)
Reads a block of data from the non-volatile memory.