#ifndef _NV_Storage_H__
#define _NV_Storage_H__
#include "os/os_types.h"
#include "bsp/bsp_driver.h"

typedef struct {
	u8 sn[32];
	u16 len;
	u16 crc;
}mc_sn_t;

typedef struct {
	u8 index;
	u16 crc;
	u16 len;
	u32 err_mask;
	u8 data[0]; //just a tag, no memeory alloc
}mc_err_red_t;

void nv_storage_init(void);
int nv_write_sn(u8 *data, int len);
int nv_read_sn(u8 *data, int len);

void nv_write_crit_errblock(u8 *data, int len);
void nv_read_crit_errblock(u8 *data, int len);
void nv_write_runtime_block(u8 *data, int len);
void nv_read_runtime_block(u8 *data, int len);
void nv_write_config_block(u8 idx, u8 *data, int len);
void nv_read_config_block(u8 idx, u8 *data, int len);

#endif /* _NV_Storage_H__ */

