cleaned helper file

This commit is contained in:
Richard Koeppe 2024-05-16 01:59:34 +02:00
parent 8fb9cbab60
commit 89f74e15cc

View File

@ -1,5 +1,5 @@
#ifndef _VN200_ #ifndef _VN_HELPER_H_
#define _VN200_ #define _VN_HELPER_H_
#include <map> #include <map>
#include <stdint.h> #include <stdint.h>
@ -12,10 +12,10 @@ namespace vn {
const uint8_t ImuMeasurementsRegisterID = 54; const uint8_t ImuMeasurementsRegisterID = 54;
/* TODO */ /** \brief TODO */
union header_t { union header_t {
struct request_t { struct request_t {
uint8_t Cmd = 0; /* Defined in VN200_SPI_READ - set in standard constructor */ uint8_t Cmd = 0; /* Defined in VN_SPI_READ */
uint8_t ID = 0; /* Register ID */ uint8_t ID = 0; /* Register ID */
uint16_t Empty = 0; /* Spacer */ uint16_t Empty = 0; /* Spacer */
request_t(uint8_t ID, uint8_t Cmd) { request_t(uint8_t ID, uint8_t Cmd) {
@ -25,37 +25,30 @@ union header_t {
}; };
struct response_t { struct response_t {
uint8_t Empty1 = 0; /* Spacer */ uint8_t Empty1 = 0; /* Spacer */
uint8_t Cmd = 0; /* Defined in VN200_SPI_READ - set in standard constructor */ uint8_t Cmd = 0; /* Defined in VN_SPI_READ */
uint8_t ID = 0; /* Register ID */ uint8_t ID = 0; /* Register ID */
uint8_t Empty2 = 0; /* Spacer */ uint8_t Empty2 = 0; /* Spacer */
response_t(){}; response_t(){};
response_t(uint8_t ID, uint8_t Cmd) {
this->ID = ID;
this->Cmd = Cmd;
};
}; };
}; };
/* Writes the desired payload into the specified register */ /** \brief Requests the specified register to write the payload into it */
template <typename payload_t> struct pkg_request_write_t { template <typename payload_t> struct pkg_request_write_t {
struct header_t::request_t header; struct header_t::request_t header;
payload_t payload; payload_t payload;
/* TODO */
pkg_request_write_t(uint8_t ID) : header(ID, VN_SPI_WRITE){}; pkg_request_write_t(uint8_t ID) : header(ID, VN_SPI_WRITE){};
}; };
/* Writes the desired payload into the specified register */ /** \brief Requests the specified register to read from */
struct pkg_request_read_t { struct pkg_request_read_t {
struct header_t::request_t header; struct header_t::request_t header;
/* TODO */
pkg_request_read_t(uint8_t ID) : header(ID, VN_SPI_READ){}; pkg_request_read_t(uint8_t ID) : header(ID, VN_SPI_READ){};
}; };
/* Writes the desired payload into the specified register */ /** \brief Response structure for the specified register */
template <typename payload_t> struct pkg_response_t { template <typename payload_t> struct pkg_response_t {
struct header_t::response_t header; struct header_t::response_t header;
payload_t payload; payload_t payload;
/* TODO */
pkg_response_t() : header(){}; pkg_response_t() : header(){};
}; };