#ifndef _VN_HELPER_H_
#define _VN_HELPER_H_

#include <map>
#include <stdint.h>
#include <vector>

#define VN_SPI_READ 0x01
#define VN_SPI_WRITE 0x02

namespace vn {

const uint8_t ImuMeasurementsRegisterID = 54;

/** \brief TODO */
union header_t {
  struct request_t {
    uint8_t Cmd = 0;    /* Defined in VN_SPI_READ */
    uint8_t ID = 0;     /* Register ID */
    uint16_t Empty = 0; /* Spacer */
    request_t(uint8_t ID, uint8_t Cmd) {
      this->ID = ID;
      this->Cmd = Cmd;
    };
  };
  struct response_t {
    uint8_t Empty1 = 0; /* Spacer */
    uint8_t Cmd = 0;    /* Defined in VN_SPI_READ */
    uint8_t ID = 0;     /* Register ID */
    uint8_t Empty2 = 0; /* Spacer */
    response_t(){};
  };
};

/** \brief Requests the specified register to write the payload into it */
template <typename payload_t> struct pkg_request_write_t {
  struct header_t::request_t header;
  payload_t payload;
  pkg_request_write_t(uint8_t ID) : header(ID, VN_SPI_WRITE){};
};

/** \brief Requests the specified register to read from */
struct pkg_request_read_t {
  struct header_t::request_t header;
  pkg_request_read_t(uint8_t ID) : header(ID, VN_SPI_READ){};
};

/** \brief Response structure for the specified register */
template <typename payload_t> struct pkg_response_t {
  struct header_t::response_t header;
  payload_t payload;
  pkg_response_t() : header(){};
};

} // namespace vn

#endif
