/*
* nvram.h
*
* Created on: 4 Jun 2017
* Author: Mike
*/
#include "libPLX/plx.h"
#pragma once
#if defined __cplusplus
extern "C"
{
#endif
#pragma pack(push, 1)
///\brief State of currently displayed item
/// this is expected to be packed into 32 bits
typedef union
{
struct
{
unsigned tag : 8;
unsigned : 8;
enum PLX_Observations observation : 8;
int instance : 8;
} data;
uint32_t u32;
} nvram_info_t;
#pragma pack(pop)
// Allocation of NVRAM words : there are 4k bytes
#define NVRAM_WORDS (4096 / sizeof(nvram_info_t))
/// @brief Erase every NVRAM entry
extern void erase_nvram();
/// @brief Save data, replacing any with a matching tag field.
/// @param data data item to write
extern void write_nvram_data(nvram_info_t data);
//
/// @brief Find data according to the tag field/
/// @param tag tag code to find
/// @return a pointer to the nvram data with matching tag or NULL if not found
extern nvram_info_t *find_nvram_data(uint8_t tag);
#if defined __cplusplus
}
#endif