#ifndef HWINFO_H
#define HWINFO_H
//----------------------------------------------------------------------------
///
/// \brief   campo vagus class
///
///          generic TDT communication
///
/// \date   20230325
/// \author Maximilian Seesslen <mes@seesslen.net>
///
//----------------------------------------------------------------------------


//---Includes-----------------------------------------------------------------


//---Own------------------------------

#if 0
#include "vagus_checker.hpp"
#include <biwak/uid.hpp>
#include <biwak/retain.h>
#include <biwak/heartbeat.hpp>
#include <biwak/can.hpp>
#include <biwak/flash_i2c.hpp>
#include <tdt/message.hpp>
#endif

#if IS_ENABLED( CONFIG_VAGUS_HWINFO_V5 )
   #include <hwinfo/hwinfo_v5.h>
   using namespace V5;
   #if defined( CONFIG_VAGUS_HWINFO_V6 ) || defined( CONFIG_VAGUS_HWINFO_V7 )
      #error Multiple configs defined
   #endif
#elif IS_ENABLED( CONFIG_VAGUS_HWINFO_V6 )
   #include <hwinfo/hwinfo_v6.h>
   #if defined( CONFIG_VAGUS_HWINFO_V5 ) || defined( CONFIG_VAGUS_HWINFO_V7 )
      #error Multiple configs defined
   #endif
#elif IS_ENABLED( CONFIG_VAGUS_HWINFO_V7 )
   #include <hwinfo/hwinfo_v7.h>
   #if defined( CONFIG_VAGUS_HWINFO_V5 ) || defined( CONFIG_VAGUS_HWINFO_V6 )
      #error Multiple configs defined
   #endif
#else
   #error Specify a layout version via CONFIG_VAGUS_HWINFO_Vx in config header.
#endif

#if defined VAGUS_EXTENSION_BOOTLOADER
   #include <platform_generated_bootloader.hpp>
#else
   #include <platform_generated.hpp>
#endif

#if IS_ENABLED( CONFIG_VAGUS_TDT_MMP )
#include <tdt/mmp.hpp>
#endif

#if IS_ENABLED( CONFIG_VAGUS_CAN_PLACEHOLDER )
#define  m_can1      (*m_pCan1)
#endif

#if defined CONFIG_VAGUS_I2C_VARIABLE_NAME
#define m_i2c1       CONFIG_VAGUS_I2C_VARIABLE_NAME
#endif

#if defined( CONFIG_VAGUS_LOG_CODE )
#error VAGUS_LOG_CODE is obsolete
#endif

#if defined( CONFIG_VAGUS_LOG_REPEAT )
#error VAGUS_LOG_REPEAT is obsolete
#endif

#if IS_ENABLED( CONFIG_BIWAK_LOG_CUSTOM_CHANNEL ) || IS_ENABLED( CONFIG_VAGUS_TDT_MMP )
#define CONFIG_VAGUS_INSTANCE       1
#endif

// log code needs getInstance()
#undef CONFIG_VAGUS_INSTANCE
#define CONFIG_VAGUS_INSTANCE       1

// #define VCONF(c)   (((SEepromConfigVagus*)m_pConfig)->c)
// #define CONF(c)   (((SEepromConfigCustom*)m_pConfig)->c)

// #define DECLARE_CUSTOM_CONFIG    SEepromConfigCustom& m_cConfig = *(SEepromConfigCustom*)m_pConfig;
// #define CONF(c)                  m_cConfig.c

#define DECLARE_CUSTOM_CONFIG
#define VAGUS_CONFIG(c)          m_config.c
//#define CONF(c)                ((SEepromConfigCustom*)&m_config)->c
#define CUSTOM_CONFIG(c)         ((SEepromConfigCustom&)m_config).c
#define OBJCONFIG(o, c)          ((SEepromConfigCustom&)(o->m_config)).c
#define CONFIG_ADDR              (&m_config)
#define CUSTOM_CONFIG_INSTANCE   ((SEepromConfigCustom&)m_config)


//---Declaration--------------------------------------------------------------


#undef PHONY_PACKED
// #define PHONY_PACKED __attribute ((packed))
#define PHONY_PACKED

struct SCollectedHwData
{
   uint32_t uidLow;
   uint32_t uidHigh;
};

struct SEepromConfigVagus: SEepromConfigBase
{
   uint8_t bootLoaderMode;    // 0x0
   char reserved_v1;          // 0x1
   char reserved_v2;          // 0x2
   char reserved_v3;          // 0x3
   uint32_t operatingTime;    // 0x04 .. 0x07
} PHONY_PACKED;

struct SEepromConfigVagusExpanded: SEepromConfigVagus
{
   char reservedExpand[ 0x20 - RETAIN_HEADER_SIZE - sizeof( SEepromConfigVagus ) ];
};

#define CONFIG_SIZE        ( 0x20 - RETAIN_HEADER_SIZE )
    
static_assert( sizeof( SCollectedHwData ) == 8 );

static_assert( sizeof( SEepromHwData ) == ( 0x40 - RETAIN_HEADER_SIZE ) );
static_assert( sizeof( SEepromConfigBase ) <= ( 0x20 - RETAIN_HEADER_SIZE ) );
static_assert( sizeof( SEepromConfigVagus ) <= ( 0x20 - RETAIN_HEADER_SIZE ) );

static_assert( ( sizeof( SEepromConfigBase ) & 3 ) == 0 );
static_assert( ( sizeof( SEepromConfigVagus ) & 3 ) == 0 );



//---fin----------------------------------------------------------------------
#endif // ? ! HWINFO_H
