commit ed9a1bf53c3145e845296a606332dc10ee72ca76
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Tue Jun 23 16:47:35 2020 +0200

    MPU6050 driver reworked.
    Implementation is very rudimentary and incomplete yet.

diff --git a/drivers/MPU6050/v1/alld_MPU6050.h b/drivers/MPU6050/v1/alld_MPU6050.h
index 326c7c2..1259cdf 100644
--- a/drivers/MPU6050/v1/alld_MPU6050.h
+++ b/drivers/MPU6050/v1/alld_MPU6050.h
@@ -34,72 +34,24 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /******************************************************************************/
 
 /**
- * @brief Maximum I2C frequency.
+ * @brief   Maximum I2C frequency.
  */
-#define MPU6050_LLD_I2C_MAXFREQUENCY    400000
-
-/* Default I2C address */
-#define MPU6050_LLD_I2C_ADDR_FIXED      0x68
-#define MPU6050_LLD_I2C_ADDR_AD0        0x01
-
-/* MPU6050 registers */
-#define MPU6050_LLD_AUX_VDDIO   0x01
-#define MPU6050_LLD_SMPLRT_DIV   0x19
-#define MPU6050_LLD_CONFIG    0x1A
-#define MPU6050_LLD_GYRO_CONFIG   0x1B
-#define MPU6050_LLD_ACCEL_CONFIG  0x1C
-#define MPU6050_LLD_MOTION_THRESH  0x1F
-#define MPU6050_LLD_INT_PIN_CFG   0x37
-#define MPU6050_LLD_INT_ENABLE   0x38
-#define MPU6050_LLD_INT_STATUS   0x3A
-#define MPU6050_LLD_ACCEL_XOUT_H  0x3B
-#define MPU6050_LLD_ACCEL_XOUT_L  0x3C
-#define MPU6050_LLD_ACCEL_YOUT_H  0x3D
-#define MPU6050_LLD_ACCEL_YOUT_L  0x3E
-#define MPU6050_LLD_ACCEL_ZOUT_H  0x3F
-#define MPU6050_LLD_ACCEL_ZOUT_L  0x40
-#define MPU6050_LLD_TEMP_OUT_H   0x41
-#define MPU6050_LLD_TEMP_OUT_L   0x42
-#define MPU6050_LLD_GYRO_XOUT_H   0x43
-#define MPU6050_LLD_GYRO_XOUT_L   0x44
-#define MPU6050_LLD_GYRO_YOUT_H   0x45
-#define MPU6050_LLD_GYRO_YOUT_L   0x46
-#define MPU6050_LLD_GYRO_ZOUT_H   0x47
-#define MPU6050_LLD_GYRO_ZOUT_L   0x48
-#define MPU6050_LLD_MOT_DETECT_STATUS 0x61
-#define MPU6050_LLD_SIGNAL_PATH_RESET 0x68
-#define MPU6050_LLD_MOT_DETECT_CTRL  0x69
-#define MPU6050_LLD_USER_CTRL   0x6A
-#define MPU6050_LLD_PWR_MGMT_1   0x6B
-#define MPU6050_LLD_PWR_MGMT_2   0x6C
-#define MPU6050_LLD_FIFO_COUNTH   0x72
-#define MPU6050_LLD_FIFO_COUNTL   0x73
-#define MPU6050_LLD_FIFO_R_W   0x74
-#define MPU6050_LLD_WHO_AM_I   0x75
-
-#define MPU6050_LLD_DataRate_8KHz        0   /**< Sample rate set to 8 kHz */
-#define MPU6050_LLD_DataRate_4KHz        1   /**< Sample rate set to 4 kHz */
-#define MPU6050_LLD_DataRate_2KHz        3   /**< Sample rate set to 2 kHz */
-#define MPU6050_LLD_DataRate_1KHz        7   /**< Sample rate set to 1 kHz */
-#define MPU6050_LLD_DataRate_500Hz       15  /**< Sample rate set to 500 Hz */
-#define MPU6050_LLD_DataRate_250Hz       31  /**< Sample rate set to 250 Hz */
-#define MPU6050_LLD_DataRate_125Hz       63  /**< Sample rate set to 125 Hz */
-#define MPU6050_LLD_DataRate_100Hz       79  /**< Sample rate set to 100 Hz */
-
-/* Who I am register value */
-#define MPU6050_I_AM    MPU6050_LLD_I2C_ADDR_FIXED
-
-/* Gyro sensitivities in degrees/s */
-#define MPU6050_LLD_GYRO_SENS_250  ((float) 131)
-#define MPU6050_LLD_GYRO_SENS_500  ((float) 65.5)
-#define MPU6050_LLD_GYRO_SENS_1000  ((float) 32.8)
-#define MPU6050_LLD_GYRO_SENS_2000  ((float) 16.4)
-
-/* Acce sensitivities in g/s */
-#define MPU6050_LLD_ACCE_SENS_2   ((float) 16384)
-#define MPU6050_LLD_ACCE_SENS_4   ((float) 8192)
-#define MPU6050_LLD_ACCE_SENS_8   ((float) 4096)
-#define MPU6050_LLD_ACCE_SENS_16  ((float) 2048)
+#define MPU6050_LLD_I2C_MAXFREQUENCY            400000
+
+/**
+ * @brief   Default I2C address
+ */
+#define MPU6050_LLD_I2C_ADDR_FIXED              0x68
+
+/**
+ * @brief   Optional I2C address mask, if AD0 is high.
+ */
+#define MPU6050_LLD_I2C_ADDR_AD0                0x01
+
+/**
+ * @brief   Constant value of the WHO_AM_I register.
+ */
+#define MPU6050_LLD_WHO_AM_I                    0x68
 
 /******************************************************************************/
 /* SETTINGS                                                                   */
@@ -114,86 +66,99 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /******************************************************************************/
 
 /**
- * @brief  MPU6050 can have 2 different slave addresses, depends on it's input AD0 pin
- *         This feature allows you to use 2 different sensors with this library at the same time
- */
-typedef enum  {
-	SD_MPU6050_Device_0 = 0x00, /*!< AD0 pin is set to low */
-	SD_MPU6050_Device_1 = 0x02  /*!< AD0 pin is set to high */
-} SD_MPU6050_Device;
-
-/**
- * @brief  MPU6050 result enumeration
- */
-typedef enum  {
-	SD_MPU6050_Result_Ok = 0x00,          /*!< Everything OK */
-	SD_MPU6050_Result_Error,              /*!< Unknown error */
-	SD_MPU6050_Result_DeviceNotConnected, /*!< There is no device with valid slave address */
-	SD_MPU6050_Result_DeviceInvalid       /*!< Connected device with address is not MPU6050 */
-} SD_MPU6050_Result;
-
-/**
- * @brief  Parameters for accelerometer range
- */
-typedef enum  {
-	SD_MPU6050_Accelerometer_2G = 0x00, /*!< Range is +- 2G */
-	SD_MPU6050_Accelerometer_4G = 0x01, /*!< Range is +- 4G */
-	SD_MPU6050_Accelerometer_8G = 0x02, /*!< Range is +- 8G */
-	SD_MPU6050_Accelerometer_16G = 0x03 /*!< Range is +- 16G */
-} SD_MPU6050_Accelerometer;
-
-/**
- * @brief  Parameters for gyroscope range
+ * @brief   Register map.
  */
 typedef enum {
-	SD_MPU6050_Gyroscope_250s = 0x00,  /*!< Range is +- 250 degrees/s */
-	SD_MPU6050_Gyroscope_500s = 0x01,  /*!< Range is +- 500 degrees/s */
-	SD_MPU6050_Gyroscope_1000s = 0x02, /*!< Range is +- 1000 degrees/s */
-	SD_MPU6050_Gyroscope_2000s = 0x03  /*!< Range is +- 2000 degrees/s */
-} SD_MPU6050_Gyroscope;
-
-
-/**
- * @brief  Interrupts union and structure
- */
-typedef union {
-	struct {
-		uint8_t DataReady:1;       /*!< Data ready interrupt */
-		uint8_t reserved2:2;       /*!< Reserved bits */
-		uint8_t Master:1;          /*!< Master interrupt. Not enabled with library */
-		uint8_t FifoOverflow:1;    /*!< FIFO overflow interrupt. Not enabled with library */
-		uint8_t reserved1:1;       /*!< Reserved bit */
-		uint8_t MotionDetection:1; /*!< Motion detected interrupt */
-		uint8_t reserved0:1;       /*!< Reserved bit */
-	} F;
-	uint8_t Status;
-} SD_MPU6050_Interrupt;
+  MPU6050_LLD_REGISTER_SELF_TEST_X        = 0x0D,
+  MPU6050_LLD_REGISTER_SELF_TEST_Y        = 0x0E,
+  MPU6050_LLD_REGISTER_SELF_TEST_Z        = 0x0F,
+  MPU6050_LLD_REGISTER_SELF_TEST_A        = 0x10,
+  MPU6050_LLD_REGISTER_SMPLRT_DIV         = 0x19,
+  MPU6050_LLD_REGISTER_CONFIG             = 0x1A,
+  MPU6050_LLD_REGISTER_GYRO_CONFIG        = 0x1B,
+  MPU6050_LLD_REGISTER_ACCEL_CONFIG       = 0x1C,
+  MPU6050_LLD_REGISTER_FIFO_EN            = 0x23,
+  MPU6050_LLD_REGISTER_I2C_MST_CTRL       = 0x24,
+  MPU6050_LLD_REGISTER_I2C_SLV0_ADDR      = 0x25,
+  MPU6050_LLD_REGISTER_I2C_SLV0_REG       = 0x26,
+  MPU6050_LLD_REGISTER_I2C_SLV0_CTRL      = 0x27,
+  MPU6050_LLD_REGISTER_I2C_SLV1_ADDR      = 0x28,
+  MPU6050_LLD_REGISTER_I2C_SLV1_REG       = 0x29,
+  MPU6050_LLD_REGISTER_I2C_SLV1_CTRL      = 0x2A,
+  MPU6050_LLD_REGISTER_I2C_SLV2_ADDR      = 0x2B,
+  MPU6050_LLD_REGISTER_I2C_SLV2_REG       = 0x2C,
+  MPU6050_LLD_REGISTER_I2C_SLV2_CTRL      = 0x2D,
+  MPU6050_LLD_REGISTER_I2C_SLV3_ADDR      = 0x2E,
+  MPU6050_LLD_REGISTER_I2C_SLV3_REG       = 0x2F,
+  MPU6050_LLD_REGISTER_I2C_SLV3_CTRL      = 0x30,
+  MPU6050_LLD_REGISTER_I2C_SLV4_ADDR      = 0x31,
+  MPU6050_LLD_REGISTER_I2C_SLV4_REG       = 0x32,
+  MPU6050_LLD_REGISTER_I2C_SLV4_DO        = 0x33,
+  MPU6050_LLD_REGISTER_I2C_SLV4_CTRL      = 0x34,
+  MPU6050_LLD_REGISTER_I2C_SLV4_DI        = 0x35,
+  MPU6050_LLD_REGISTER_I2C_MST_STATUS     = 0x36,
+  MPU6050_LLD_REGISTER_INT_PIN_CFG        = 0x37,
+  MPU6050_LLD_REGISTER_INT_ENABLE         = 0x38,
+  MPU6050_LLD_REGISTER_INT_STATUS         = 0x3A,
+  MPU6050_LLD_REGISTER_ACCEL_XOUT_H       = 0x3B,
+  MPU6050_LLD_REGISTER_ACCEL_XOUT_L       = 0x3C,
+  MPU6050_LLD_REGISTER_ACCEL_YOUT_H       = 0x3D,
+  MPU6050_LLD_REGISTER_ACCEL_YOUT_L       = 0x3E,
+  MPU6050_LLD_REGISTER_ACCEL_ZOUT_H       = 0x3F,
+  MPU6050_LLD_REGISTER_ACCEL_ZOUT_L       = 0x40,
+  MPU6050_LLD_REGISTER_TEMP_OUT_H         = 0x41,
+  MPU6050_LLD_REGISTER_TEMP_OUT_L         = 0x42,
+  MPU6050_LLD_REGISTER_GYRO_XOUT_H        = 0x43,
+  MPU6050_LLD_REGISTER_GYRO_XOUT_L        = 0x44,
+  MPU6050_LLD_REGISTER_GYRO_YOUT_H        = 0x45,
+  MPU6050_LLD_REGISTER_GYRO_YOUT_L        = 0x46,
+  MPU6050_LLD_REGISTER_GYRO_ZOUT_H        = 0x47,
+  MPU6050_LLD_REGISTER_GYRO_ZOUT_L        = 0x48,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_00   = 0x49,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_01   = 0x4A,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_02   = 0x4B,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_03   = 0x4C,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_04   = 0x4D,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_05   = 0x4E,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_06   = 0x4F,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_07   = 0x50,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_08   = 0x51,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_09   = 0x52,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_10   = 0x53,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_11   = 0x54,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_12   = 0x55,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_13   = 0x56,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_14   = 0x57,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_15   = 0x58,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_16   = 0x59,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_17   = 0x5A,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_18   = 0x5B,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_19   = 0x5C,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_20   = 0x5D,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_21   = 0x5E,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_22   = 0x5F,
+  MPU6050_LLD_REGISTER_EXT_SENS_DATA_23   = 0x60,
+  MPU6050_LLD_REGISTER_I2C_SLV0_DO        = 0x63,
+  MPU6050_LLD_REGISTER_I2C_SLV1_DO        = 0x64,
+  MPU6050_LLD_REGISTER_I2C_SLV2_DO        = 0x65,
+  MPU6050_LLD_REGISTER_I2C_SLV3_DO        = 0x66,
+  MPU6050_LLD_REGISTER_I2C_MST_DELAY_CTRL = 0x67,
+  MPU6050_LLD_REGISTER_SIGNAL_PATH_RESET  = 0x68,
+  MPU6050_LLD_REGISTER_USER_CTRL          = 0x6A,
+  MPU6050_LLD_REGISTER_PWR_MGMT_1         = 0x6B,
+  MPU6050_LLD_REGISTER_PWR_MGMT_2         = 0x6C,
+  MPU6050_LLD_REGISTER_FIFO_COUNTH        = 0x72,
+  MPU6050_LLD_REGISTER_FIFO_COUNTL        = 0x73,
+  MPU6050_LLD_REGISTER_FIFO_R_W           = 0x74,
+  MPU6050_LLD_REGISTER_WHO_AM_I           = 0x75,
+} mpu6050_lld_register_t;
 
 /**
- * @brief Config register.
- */
-typedef union {
-  uint16_t data;
-  struct {
-    /**
-    ina219_lld_mode_t mode : 3;
-    ina219_lld_adc_t sadc : 4;
-    ina219_lld_adc_t badc : 4;
-    ina219_lld_gain_t gain : 2;
-    ina219_lld_brng_t brng : 1;
-    */
-    uint8_t zero : 1;
-    uint8_t reset : 1;
-  } options;
-} mpu6050_lld_cfg_t;
-
-
-/**
- * @brief The MPU6050 struct.
+ * @brief The MPU6050Driver struct.
  */
 typedef struct {
-  apalI2CDriver_t* i2cd;
-  apalI2Caddr_t addr;   /**<The address of the module for I2C communication */
+  apalI2CDriver_t* i2cd;  /**< Pointer to the connected I2C driver. */
+  apalI2Caddr_t addr;     /**< The address of the module for I2C communication. */
 } MPU6050Driver;
 
 /******************************************************************************/
@@ -207,8 +172,8 @@ typedef struct {
 #ifdef __cplusplus
 extern "C" {
 #endif
-  apalExitStatus_t mpu6050_lld_read_register(const MPU6050Driver* const mpu6050, const uint8_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
-  apalExitStatus_t mpu6050_lld_write_register(const MPU6050Driver* const mpu6050, const uint8_t addr, const uint8_t* const data, const uint8_t num, const apalTime_t timeout);
+  apalExitStatus_t mpu6050_lld_read_register(const MPU6050Driver* const mpu6050, const mpu6050_lld_register_t addr, uint8_t* const data, const uint8_t num, const apalTime_t timeout);
+  apalExitStatus_t mpu6050_lld_write_register(const MPU6050Driver* const mpu6050, const mpu6050_lld_register_t addr, const uint8_t* const data, const uint8_t num, const apalTime_t timeout);
 #ifdef __cplusplus
 }
 #endif
@@ -219,6 +184,4 @@ extern "C" {
 
 #endif /* AMIROLLD_MPU6050_H */
 
-
 /** @} */
-
