grblHAL core  20241107
nvs.h File Reference

Go to the source code of this file.

Data Structures

struct  nvs_driver_area_t
 Structure for keeping track of NVS area used by driver and/or plugin code. More...
 
struct  nvs_io_t
 Handler functions and variables for NVS storage of settings and data. More...
 

Macros

#define NVS_SIZE   2048
 Total size in bytes of the NVS. Minimum 1024 bytes required, more if space for driver and/or plugin data and settings is required. More...
 
#define GRBL_NVS_END   1023
 Number of bytes at the start of the NVS area reserved for core settings and parameters. Minimum 1024 bytes required. More...
 
#define NVS_CRC_BYTES   1
 Number of bytes used for storing CRC values. Do not change this! More...
 
Define persistent storage memory address location values for core settings and parameters.

The upper half is reserved for parameters and the startup script. The lower half contains the global settings and space for future developments.

NOTE: 1024 bytes of persistent storage is the minimum required.

#define NVS_ADDR_GLOBAL   1U
 
#define NVS_ADDR_PARAMETERS   512U
 
#define NVS_ADDR_BUILD_INFO   (GRBL_NVS_END - 81U)
 
#define NVS_ADDR_STARTUP_BLOCK   (NVS_ADDR_BUILD_INFO - 1 - N_STARTUP_LINE * (sizeof(stored_line_t) + NVS_CRC_BYTES))
 
#define GRBL_NVS_SIZE   (GRBL_NVS_END + 1)
 

Typedefs

typedef uint8_t(* get_byte_ptr) (uint32_t addr)
 Pointer to function for getting a byte from NVS storage. More...
 
typedef void(* put_byte_ptr) (uint32_t addr, uint8_t new_value)
 Pointer to function for putting a byte into NVS storage. More...
 
typedef nvs_transfer_result_t(* memcpy_from_nvs_ptr) (uint8_t *dest, uint32_t source, uint32_t size, bool with_checksum)
 Pointer to function for reading a block of data from NVS storage. More...
 
typedef nvs_transfer_result_t(* memcpy_to_nvs_ptr) (uint32_t dest, uint8_t *source, uint32_t size, bool with_checksum)
 Pointer to function for writing a block of data to NVS storage. More...
 
typedef bool(* memcpy_from_flash_ptr) (uint8_t *dest)
 Pointer to function for reading a block of data from flash based NVS storage. More...
 
typedef bool(* memcpy_to_flash_ptr) (uint8_t *source)
 Pointer to function for reading a block of data from flash based NVS storage. More...
 

Enumerations

enum  nvs_type {
  NVS_None = 0 , NVS_EEPROM , NVS_FRAM , NVS_Flash ,
  NVS_Emulated
}
 
enum  nvs_transfer_result_t { NVS_TransferResult_Failed = 0 , NVS_TransferResult_Busy , NVS_TransferResult_OK }
 

Macro Definition Documentation

◆ GRBL_NVS_END

#define GRBL_NVS_END   1023

Number of bytes at the start of the NVS area reserved for core settings and parameters. Minimum 1024 bytes required.

◆ GRBL_NVS_SIZE

#define GRBL_NVS_SIZE   (GRBL_NVS_END + 1)

◆ NVS_ADDR_BUILD_INFO

#define NVS_ADDR_BUILD_INFO   (GRBL_NVS_END - 81U)

◆ NVS_ADDR_GLOBAL

#define NVS_ADDR_GLOBAL   1U

◆ NVS_ADDR_PARAMETERS

#define NVS_ADDR_PARAMETERS   512U

◆ NVS_ADDR_STARTUP_BLOCK

#define NVS_ADDR_STARTUP_BLOCK   (NVS_ADDR_BUILD_INFO - 1 - N_STARTUP_LINE * (sizeof(stored_line_t) + NVS_CRC_BYTES))

◆ NVS_CRC_BYTES

#define NVS_CRC_BYTES   1

Number of bytes used for storing CRC values. Do not change this!

◆ NVS_SIZE

#define NVS_SIZE   2048

Total size in bytes of the NVS. Minimum 1024 bytes required, more if space for driver and/or plugin data and settings is required.

Typedef Documentation

◆ get_byte_ptr

typedef uint8_t(* get_byte_ptr) (uint32_t addr)

Pointer to function for getting a byte from NVS storage.

Parameters
addrindex base address into the area.
Returns
byte read.

◆ memcpy_from_flash_ptr

typedef bool(* memcpy_from_flash_ptr) (uint8_t *dest)

Pointer to function for reading a block of data from flash based NVS storage.

Parameters
destpointer to destination of data.
Returns
true if successful, false otherwise.

◆ memcpy_from_nvs_ptr

typedef nvs_transfer_result_t(* memcpy_from_nvs_ptr) (uint8_t *dest, uint32_t source, uint32_t size, bool with_checksum)

Pointer to function for reading a block of data from NVS storage.

Parameters
destpointer to destination of data.
sourceindex based address into the storage area.
sizenumber of bytes to write.
with_checksumtrue calculate and verify checksum at the end of the data block, false do not calculate and verify checksum.
Returns
nvs_transfer_result_t enum.

◆ memcpy_to_flash_ptr

typedef bool(* memcpy_to_flash_ptr) (uint8_t *source)

Pointer to function for reading a block of data from flash based NVS storage.

Parameters
sourcepointer to source data.
Returns
true if successful, false otherwise.

◆ memcpy_to_nvs_ptr

typedef nvs_transfer_result_t(* memcpy_to_nvs_ptr) (uint32_t dest, uint8_t *source, uint32_t size, bool with_checksum)

Pointer to function for writing a block of data to NVS storage.

Parameters
destindex based address into the storage area.
sourcepointer to source data
sizenumber of bytes to write
with_checksumtrue calculate and add a checksum at the end of the data block, false do not add checksum.
Returns
nvs_transfer_result_t enum.

◆ put_byte_ptr

typedef void(* put_byte_ptr) (uint32_t addr, uint8_t new_value)

Pointer to function for putting a byte into NVS storage.

Parameters
addrindex based address into the storage area.
new_valuebyte to write.

Enumeration Type Documentation

◆ nvs_transfer_result_t

Enumerator
NVS_TransferResult_Failed 

0

NVS_TransferResult_Busy 

1

NVS_TransferResult_OK 

2

◆ nvs_type

enum nvs_type
Enumerator
NVS_None 

0

NVS_EEPROM 

1

NVS_FRAM 

2

NVS_Flash 

3

NVS_Emulated 

4 - used by the core for buffered read and write