36 #ifndef UM7_REGISTERS_H_ 37 #define UM7_REGISTERS_H_ 40 #include <machine/endian.h> 54 #define TO_RADIANS (M_PI / 180.0) 55 #define TO_DEGREES (180.0 / M_PI) 59 #define NUM_REGISTERS (DATA_REG_START_ADDRESS + DATA_ARRAY_SIZE) 67 #if __BYTE_ORDER == __LITTLE_ENDIAN 68 uint8_t*
d =
reinterpret_cast<uint8_t*
>(dest);
69 uint8_t*
s =
reinterpret_cast<uint8_t*
>(src);
70 for (uint8_t i = 0; i < count; i++)
72 d[i] = s[count - (i+1)];
76 #warning Big-endian implementation is untested. 77 memcpy(dest, src, count);
97 uint8_t register_width, uint8_t array_length)
98 :
index(register_index),
width(register_width),
122 template<
typename RegT>
126 Accessor(
Registers* registers, uint8_t register_index, uint8_t array_length = 0,
double scale_factor = 1.0)
127 :
Accessor_(registers, register_index, sizeof(RegT), array_length), scale_(scale_factor)
130 RegT
get(uint8_t field)
const 132 RegT* raw_ptr =
reinterpret_cast<RegT*
>(
raw());
140 return get(field) * scale_;
143 void set(uint8_t field, RegT value)
const 145 RegT* raw_ptr =
reinterpret_cast<RegT*
>(
raw());
151 set(field, value / scale_);
183 memset(raw_, 0,
sizeof(raw_));
193 comrate4, comrate5, comrate6;
200 void write_raw(uint8_t register_index, std::string data)
202 if ((register_index - 1) + (data.length()/4 - 1) >=
NUM_REGISTERS)
204 throw std::range_error(
"Index and length write beyond boundaries of register array.");
206 memcpy(&raw_[register_index], data.c_str(), data.length());
216 #endif // UM7_REGISTERS_H_
#define DREG_ACCEL_RAW_XY
Accessor_(Registers *registers, uint8_t register_index, uint8_t register_width, uint8_t array_length)
const Accessor< int16_t > quat
#define CHR_SET_MAG_REFERENCE
#define DREG_ACCEL_PROC_X
Copied directly from the UM7 version of the UM6_config.h file, available online here: http://sourcefo...
#define CREG_MISC_SETTINGS
Accessor(Registers *registers, uint8_t register_index, uint8_t array_length=0, double scale_factor=1.0)
const Accessor< uint32_t > status
void set_scaled(uint16_t field, double value) const
#define CREG_COM_SETTINGS
const Accessor< uint32_t > cmd_zero_gyros
void write_raw(uint8_t register_index, std::string data)
void memcpy_network(void *dest, void *src, size_t count)
const Accessor< float > mag_bias
double get_scaled(uint16_t field) const
#define DREG_EULER_PHI_THETA
const Accessor< float > temperature