56 void writeByte(
unsigned char regAddr,
unsigned char regByte,
57 unsigned int verbose) {
58 unsigned char txData[3];
61 txData[0] = regAddr | 0x80;
68 printf(
"\r\nREG[0x%02X] < 0x%02X\t", regAddr, regByte);
81 unsigned char regByte,
unsigned int verbose) {
85 printf(
"\r\nREG[0x%02X(W%01d)] < 0x%02X\t", regAddr, winNumber, regByte);
95 unsigned short read16(
unsigned char regAddr,
unsigned int verbose) {
98 unsigned char txData[3];
101 txData[0] = regAddr & 0x7E;
113 if ((size < 4) || (
response[0] != txData[0]) ||
115 printf(
"Returned less data or unexpected data from previous command.\n");
116 printf(
"Return data: 0x%02X, 0x%02X, 0x%02X, 0x%02X\n",
response[0],
133 unsigned int verbose) {
134 unsigned short rxData;
137 rxData =
read16(regAddr, 0);
139 printf(
"REG[0x%02X(W%01d)] > 0x%04X\t", regAddr, winNumber, rxData);
226 int gyro_y = (
rxByteBuf[idx + 4] << 8 * 3) +
229 int gyro_z = (
rxByteBuf[idx + 8] << 8 * 3) +
253 int accel_y = (
rxByteBuf[idx + 4] << 8 * 3) +
256 int accel_z = (
rxByteBuf[idx + 8] << 8 * 3) +
280 int gyro_delta_x = (
rxByteBuf[idx] << 8 * 3) +
283 int gyro_delta_y = (
rxByteBuf[idx + 4] << 8 * 3) +
286 int gyro_delta_z = (
rxByteBuf[idx + 8] << 8 * 3) +
310 int accel_delta_x = (
rxByteBuf[idx] << 8 * 3) +
313 int accel_delta_y = (
rxByteBuf[idx + 4] << 8 * 3) +
316 int accel_delta_z = (
rxByteBuf[idx + 8] << 8 * 3) +
344 int qtn3 = (
rxByteBuf[idx + 12] << 8 * 3) +
347 data->
qtn0 = (double)qtn0 * esensor->
qtn_sf / 65536;
348 data->
qtn1 = (
double)qtn1 * esensor->
qtn_sf / 65536;
349 data->
qtn2 = (double)qtn2 * esensor->
qtn_sf / 65536;
350 data->
qtn3 = (
double)qtn3 * esensor->
qtn_sf / 65536;
424 printf(
"Expecting: %d bytes\n", byte_length);
427 int data_length = byte_length - 2;
432 printf(
"state: %d, byte: 0x%02X\n",
state,
byte);
450 for (
int i = 0; i < data_length; i++) printf(
"0x%02X ",
rxByteBuf[i]);
457 unsigned short calc_checksum = 0;
458 for (
int i = 0; i < data_length - 2; i += 2) {
461 unsigned short epson_checksum =
464 if (calc_checksum != epson_checksum) {
465 printf(
"checksum failed\n");
475 printf(
"Invalid State in Read Burst Processing\n");