
/*
 * 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
    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))


    // Save data according to its tag field
    extern void write_nvram_data(nvram_info_t data);

    // find data according to the tag field or return null if no info,
    extern nvram_info_t *find_nvram_data(uint8_t tag);

#if defined __cplusplus
}
#endif
