commit 6ef38c23e5c946c41de7b8739f79c83bea93b0fb
Author: Julia Niermann <jniermann@techfak.uni-bielefeld.de>
Date:   Fri Jun 14 12:27:46 2019 +0200

    Add untested driver for p9221r wireless charging kit

diff --git a/include/P9221R/v1/alld_P9221R_v1.h b/include/P9221R/v1/alld_P9221R_v1.h
new file mode 100644
index 0000000..382e69c
--- /dev/null
+++ b/include/P9221R/v1/alld_P9221R_v1.h
@@ -0,0 +1,100 @@
+/*
+AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
+Copyright (C) 2016..2019  Thomas Schöpping et al.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file    alld_P9221R_v1.h
+ * @brief   Power Monitor macros and structures.
+ *
+ * @addtogroup lld_power
+ * @{
+ */
+
+#ifndef AMIROLLD_P9221R_V1_H
+#define AMIROLLD_P9221R_V1_H
+
+#include <amiro-lld.h>
+
+/******************************************************************************/
+/* CONSTANTS                                                                  */
+/******************************************************************************/
+
+/******************************************************************************/
+/* SETTINGS                                                                   */
+/******************************************************************************/
+
+/******************************************************************************/
+/* CHECKS                                                                     */
+/******************************************************************************/
+
+/******************************************************************************/
+/* DATA STRUCTURES AND TYPES                                                  */
+/******************************************************************************/
+/**
+ * @brief Registers.
+ */
+typedef enum {
+  // Writeable Registers
+  P9221R_LLD_REGISTER_BATTERY_STATUS_SENT       = 0x3A,
+  P9221R_LLD_REGISTER_END_POWER_TRANSFER        = 0x3B,
+  // Read-Only Registers
+  P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_LSB        = 0x3C,
+  P9221R_LLD_REGISTER_OUTPUT_VOLTAGE_MSB        = 0x3D,
+  P9221R_LLD_REGISTER_IOUT_CURRENT_LSB          = 0x44,
+  P9221R_LLD_REGISTER_IOUT_CURRENT_MSB          = 0x45,
+  P9221R_LLD_REGISTER_OPERATING_FREQUENCY_MSB   = 0x48,
+  P9221R_LLD_REGISTER_OPERATING_FREQUENCY_LSB   = 0x49,
+  P9221R_LLD_REGISTER_ALIGNMENT_X               = 0x4B,
+  P9221R_LLD_REGISTER_ALIGNMENT_Y               = 0x4C,
+} p9221r_lld_register_t;
+
+/**
+ * @brief I2C address masks.
+ */
+enum {
+  P9221R_LLD_I2C_ADDR_FIXED   = 0x0061u,
+};
+
+typedef struct {
+  apalI2CDriver_t* i2cd;
+  apalI2Caddr_t addr;
+  uint16_t current_lsb_uA;
+  P9221R_lld_cfg_t *config;
+} P9221RDriver;
+
+
+/******************************************************************************/
+/* MACROS                                                                     */
+/******************************************************************************/
+
+/******************************************************************************/
+/* EXTERN DECLARATIONS                                                        */
+/******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint16_t* const data, const uint8_t num, const apalTime_t timeout);
+  apalExitStatus_t p9221r_lld_write_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, const uint16_t* const data, const uint8_t num, const apalTime_t timeout);
+#ifdef __cplusplus
+}
+#endif
+
+/******************************************************************************/
+/* INLINE FUNCTIONS                                                           */
+/******************************************************************************/
+
diff --git a/source/P9221R/v1/alld_P9221R_v1.c b/source/P9221R/v1/alld_P9221R_v1.c
new file mode 100644
index 0000000..76fc139
--- /dev/null
+++ b/source/P9221R/v1/alld_P9221R_v1.c
@@ -0,0 +1,135 @@
+/*
+AMiRo-LLD is a compilation of low-level hardware drivers for the Autonomous Mini Robot (AMiRo) platform.
+Copyright (C) 2016..2019  Thomas Schöpping et al.
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file    alld_P9221R_v1.c
+ *
+ * @brief   Power Monitor function implementations
+ *
+ * @addtogroup lld_power
+ * @{
+ */
+
+#include <alld_P9221R_v1.h>
+
+
+/******************************************************************************/
+/* LOCAL DEFINITIONS                                                          */
+/******************************************************************************/
+
+/******************************************************************************/
+/* EXPORTED VARIABLES                                                         */
+/******************************************************************************/
+
+/******************************************************************************/
+/* LOCAL TYPES                                                                */
+/******************************************************************************/
+
+/******************************************************************************/
+/* LOCAL VARIABLES                                                            */
+/******************************************************************************/
+
+/******************************************************************************/
+/* LOCAL FUNCTIONS                                                            */
+/******************************************************************************/
+
+/******************************************************************************/
+/* EXPORTED FUNCTIONS                                                         */
+/******************************************************************************/
+
+
+/**
+ * @brief Read the value of one or more of the registers.
+ * @param[in]   i2cd        i2c driver
+ * @param[in]   PRd         p9221r driver
+ * @param[in]   addr        register address
+ * @param[out]  data        register content
+ * @param[in]   num         number of subsequent registers to read
+ * @param[in]   timeout     timeout
+ * @return                  An indicator whether the call was successfull
+ */
+apalExitStatus_t p9221r_lld_read_register(const P9221RDriver* const p9221r, const p9221r_lld_register_t addr, uint16_t* const data, const uint8_t num, const apalTime_t timeout)
+{
+  apalDbgAssert(p9221r != NULL);
+  apalDbgAssert(p9221r->i2cd != NULL);
+  apalDbgAssert(data != NULL);
+
+  uint8_t buffer[num*2];
+  apalExitStatus_t status = apalI2CMasterTransmit(p9221r->i2cd, (P9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), (uint8_t*)&addr, 1, buffer, 2*num, timeout);
+  for (uint8_t dataIdx = 0; dataIdx < num; dataIdx++) {
+    data[dataIdx] = (buffer[2*dataIdx] << 8) | buffer[2*dataIdx+1];
+  }
+  return status;
+}
+
+/**
+ * @brief Write the value of one or more of the registers.
+ * @param[in]   i2cd        i2c driver
+ * @param[in]   PRd         p9221r driver
+ * @param[in]   addr        register address
+ * @param[in]   data        data to write
+ * @param[in]   num         number of subsequent registers to read
+ * @param[in]   timeout     timeout
+ * @return                  An indicator whether the call was successfull
+ */
+
+apalExitStatus_t p9221r_lld_write_register(const R9221RDriver* const p9221r, const p9221r_lld_register_t addr, const uint16_t* const data, const uint8_t num, const apalTime_t timeout)
+{
+  apalDbgAssert(p9221r != NULL);
+  apalDbgAssert(p9221r->i2cd != NULL);
+  apalDbgAssert(data != NULL);
+
+  uint8_t buffer[1+2*num];
+  buffer[0] = addr;
+  for (uint8_t dataIdx = 0; dataIdx < num; dataIdx++) {
+    buffer[dataIdx*2+1] = data[dataIdx] >> 8;
+    buffer[dataIdx*2+2] = data[dataIdx] & (0x00FFu);
+  }
+  return apalI2CMasterTransmit(p9221r->i2cd, (R9221R_LLD_I2C_ADDR_FIXED | p9221r->addr), buffer, 1+2*num, NULL, 0, timeout);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
