From 0be4b230bd5424a0ca9ac4ee2943fbd90a2022d1 Mon Sep 17 00:00:00 2001
From: Alain Carlucci <alain.carlucci@skywarder.eu>
Date: Sun, 30 Apr 2017 15:14:26 +0200
Subject: [PATCH] [Sensors] Removed padding

---
 src/shared/sensors/FXAS21002.h |  4 ++--
 src/shared/sensors/LPS331AP.h  |  4 ++--
 src/shared/sensors/MAX21105.h  |  4 ++--
 src/shared/sensors/MPU9250.h   |  5 ++---
 src/shared/sensors/iNemo.h     | 10 +++++-----
 5 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/shared/sensors/FXAS21002.h b/src/shared/sensors/FXAS21002.h
index 4a564af7b..cfba4bf28 100644
--- a/src/shared/sensors/FXAS21002.h
+++ b/src/shared/sensors/FXAS21002.h
@@ -125,7 +125,7 @@ public:
     std::vector<SPIRequest> buildDMARequest() override
     {
         std::vector<uint8_t> data = {
-            REG_OUT_X_MSB | 0x80, 0,
+            REG_OUT_X_MSB | 0x80,
             0,0,0,0,0,0
         };
 
@@ -136,7 +136,7 @@ public:
     {
         const auto& r = req.readResponseFromPeripheral();
         int16_t data[3];
-        memcpy(data, &r[2], sizeof(data));
+        memcpy(data, &r[1], sizeof(data));
 
         for(int i=0;i<3;i++)
             data[i] = fromBigEndian16(data[i]);
diff --git a/src/shared/sensors/LPS331AP.h b/src/shared/sensors/LPS331AP.h
index 41ebf69d2..5af67789b 100644
--- a/src/shared/sensors/LPS331AP.h
+++ b/src/shared/sensors/LPS331AP.h
@@ -71,7 +71,7 @@ public:
     {
         return { 
             SPIRequest(0, Bus::getCSPin(), { 
-                REG_STATUS | 0xc0, 0,
+                REG_STATUS | 0xc0,
                 0,0,0,0, // pressure    (int32_t)
                 0,0      // temperature (int16_t)
             })
@@ -81,7 +81,7 @@ public:
     void onDMAUpdate(const SPIRequest& req) override
     {
         const auto& r = req.readResponseFromPeripheral();
-        const data_t *data = (const data_t*) &r[2];
+        const data_t *data = (const data_t*) &r[1];
     
         // Remove status and realign bytes
         int32_t pressure = data->press >> 8;
diff --git a/src/shared/sensors/MAX21105.h b/src/shared/sensors/MAX21105.h
index 66f48879c..e78b09469 100644
--- a/src/shared/sensors/MAX21105.h
+++ b/src/shared/sensors/MAX21105.h
@@ -109,7 +109,7 @@ public:
     {
         return { SPIRequest(0, Bus::getCSPin(),
         {
-            (GYRO_X_H | 0x80), 0,
+            (GYRO_X_H | 0x80),
             0,0,0,0,0,0, // gyro
             0,0,         // accel
             0,0,0,0,0,0, // temp
@@ -120,7 +120,7 @@ public:
     void onDMAUpdate(const SPIRequest& req) override
     {
         const auto& r = req.readResponseFromPeripheral();
-        const int16_t* ptr = (const int16_t*) &r[2];
+        const int16_t* ptr = (const int16_t*) &r[1];
         rawdata_t raw_data;
 
         constexpr size_t dSize = 7; // 3 (gyro) + 3 (accel) + 1 (temp)
diff --git a/src/shared/sensors/MPU9250.h b/src/shared/sensors/MPU9250.h
index 4cba3202a..9c7d2d96f 100644
--- a/src/shared/sensors/MPU9250.h
+++ b/src/shared/sensors/MPU9250.h
@@ -38,7 +38,6 @@ class MPU9250 : public GyroSensor, public AccelSensor,
 typedef union {
     struct { 
         uint8_t status1;
-        uint8_t padding;
         int16_t mag[3];
         uint8_t status2;
     };
@@ -72,7 +71,7 @@ public:
     {
         std::vector<uint8_t> v = 
         { 
-            (REG_ACCEL_XOUT_H | 0x80), 0,
+            (REG_ACCEL_XOUT_H | 0x80),
             0,0,0,0,0,0, // accel
             0,0,         // temp
             0,0,0,0,0,0, // gyro
@@ -86,7 +85,7 @@ public:
         const auto& r = req.readResponseFromPeripheral();
         mpudata_t raw_data;
 
-        memcpy(&raw_data.buf, &(r[2]), sizeof(raw_data));
+        memcpy(&raw_data.buf, &(r[1]), sizeof(raw_data));
         for(int i=0;i<3;i++)
         {
             raw_data.accel[i] = fromBigEndian16(raw_data.accel[i]);
diff --git a/src/shared/sensors/iNemo.h b/src/shared/sensors/iNemo.h
index 952f86a6b..baa9301c1 100644
--- a/src/shared/sensors/iNemo.h
+++ b/src/shared/sensors/iNemo.h
@@ -102,13 +102,13 @@ public:
     {
         return {
             SPIRequest(DMA_GYRO, BusG::getCSPin(),  
-                { OUT_X_L_G | 0xc0, 0,0,0,0,0,0,0}),
+                { OUT_X_L_G | 0xc0, 0,0,0,0,0,0}),
             SPIRequest(DMA_ACC,  BusXM::getCSPin(),  
-                { OUT_X_L_A | 0xc0, 0,0,0,0,0,0,0}),
+                { OUT_X_L_A | 0xc0, 0,0,0,0,0,0}),
             SPIRequest(DMA_COMP, BusXM::getCSPin(), 
-                { OUT_X_L_M | 0xc0,0,0,0,0,0,0,0}),
+                { OUT_X_L_M | 0xc0, 0,0,0,0,0,0}),
             SPIRequest(DMA_TEMP, BusXM::getCSPin(), 
-                { OUT_TEMP_L_XM | 0xc0, 0,0,0}),
+                { OUT_TEMP_L_XM | 0xc0, 0,0}),
         };
     }
 
@@ -117,7 +117,7 @@ public:
         const auto& r = req.readResponseFromPeripheral();
 
         int16_t data[3];
-        memcpy(data, &r[2], r.size()-2);
+        memcpy(data, &r[1], r.size()-1);
         // printf("ID: %d  --> ", req.id()); memDump(r.data(), r.size());
 
         switch(req.id())
-- 
GitLab