diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-11 15:15:16 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-11-11 15:15:16 -0500 |
commit | 5a059c8d6ecfe2f98a77570b8b6cf13c500398f7 (patch) | |
tree | db8d337eb96c44feff77d5564eb9da697e8b961b /ChibiOS_16.1.5/community/os/various/devices_lib/mems | |
parent | 7772ea4579a45bcf63ebd5e68be66ba1a9c72dfa (diff) |
tar'd chibi
Diffstat (limited to 'ChibiOS_16.1.5/community/os/various/devices_lib/mems')
8 files changed, 0 insertions, 1998 deletions
diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.c b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.c deleted file mode 100644 index 1cc52c9..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file l3gd20.c - * @brief L3GD20 MEMS interface module code. - * - * @addtogroup l3gd20 - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#include "l3gd20.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Reads a generic register value. - * @pre The SPI interface must be initialized and the driver started. - * - * @param[in] spip pointer to the SPI interface - * @param[in] reg register number - * @return register value. - */ -uint8_t l3gd20ReadRegister(SPIDriver *spip, uint8_t reg) { - uint8_t txbuf[2] = {L3GD20_RW | reg, 0xFF}; - uint8_t rxbuf[2] = {0x00, 0x00}; - spiSelect(spip); - spiExchange(spip, 2, txbuf, rxbuf); - spiUnselect(spip); - return rxbuf[1]; -} - - -void l3gd20WriteRegister(SPIDriver *spip, uint8_t reg, uint8_t value) { - - switch (reg) { - - default: - /* Reserved register must not be written, according to the datasheet - * this could permanently damage the device. - */ - chDbgAssert(FALSE, "lg3d20WriteRegister(), reserved register"); - case L3GD20_AD_WHO_AM_I: - case L3GD20_AD_OUT_TEMP : - case L3GD20_AD_STATUS_REG: - case L3GD20_AD_OUT_X_L: - case L3GD20_AD_OUT_X_H: - case L3GD20_AD_OUT_Y_L: - case L3GD20_AD_OUT_Y_H: - case L3GD20_AD_OUT_Z_L: - case L3GD20_AD_OUT_Z_H: - case L3GD20_AD_FIFO_SRC_REG: - case L3GD20_AD_INT1_SRC: - /* Read only registers cannot be written, the command is ignored.*/ - return; - case L3GD20_AD_CTRL_REG1: - case L3GD20_AD_CTRL_REG2: - case L3GD20_AD_CTRL_REG3: - case L3GD20_AD_CTRL_REG4: - case L3GD20_AD_CTRL_REG5: - case L3GD20_AD_REFERENCE: - case L3GD20_AD_FIFO_CTRL_REG: - case L3GD20_AD_INT1_CFG: - case L3GD20_AD_INT1_TSH_XH: - case L3GD20_AD_INT1_TSH_XL: - case L3GD20_AD_INT1_TSH_YH: - case L3GD20_AD_INT1_TSH_YL: - case L3GD20_AD_INT1_TSH_ZH: - case L3GD20_AD_INT1_TSH_ZL: - case L3GD20_AD_INT1_DURATION: - spiSelect(spip); - uint8_t txbuf[2] = {reg, value}; - spiSend(spip, 2, txbuf); - spiUnselect(spip); - } -} -/** @} */ diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.h b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.h deleted file mode 100644 index 08d9092..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/l3gd20.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file l3gd20.h - * @brief L3GD20 MEMS interface module header. - * - * @{ - */ - -#ifndef _L3GD20_H_ -#define _L3GD20_H_ - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -#define L3GD20_SENS_250DPS ((float)131.072f) /*!< gyroscope sensitivity with 250 dps full scale [LSB/dps] */ -#define L3GD20_SENS_500DPS ((float)65.536f) /*!< gyroscope sensitivity with 500 dps full scale [LSB/dps] */ -#define L3GD20_SENS_2000DPS ((float)16.384f) /*!< gyroscope sensitivity with 2000 dps full scale [LSB/dps] */ -/** - * @name L3GD20 register names - * @{ - */ -/******************************************************************************/ -/* */ -/* L3GD20 on board MEMS */ -/* */ -/******************************************************************************/ -/******************* Bit definition for SPI communication *******************/ -#define L3GD20_DI ((uint8_t)0xFF) /*!< DI[7:0] Data input */ -#define L3GD20_DI_0 ((uint8_t)0x01) /*!< bit 0 */ -#define L3GD20_DI_1 ((uint8_t)0x02) /*!< bit 1 */ -#define L3GD20_DI_2 ((uint8_t)0x04) /*!< bit 2 */ -#define L3GD20_DI_3 ((uint8_t)0x08) /*!< bit 3 */ -#define L3GD20_DI_4 ((uint8_t)0x10) /*!< bit 4 */ -#define L3GD20_DI_5 ((uint8_t)0x20) /*!< bit 5 */ -#define L3GD20_DI_6 ((uint8_t)0x40) /*!< bit 6 */ -#define L3GD20_DI_7 ((uint8_t)0x80) /*!< bit 7 */ - -#define L3GD20_AD ((uint8_t)0x3F) /*!< AD[5:0] Address Data */ -#define L3GD20_AD_0 ((uint8_t)0x01) /*!< bit 0 */ -#define L3GD20_AD_1 ((uint8_t)0x02) /*!< bit 1 */ -#define L3GD20_AD_2 ((uint8_t)0x04) /*!< bit 2 */ -#define L3GD20_AD_3 ((uint8_t)0x08) /*!< bit 3 */ -#define L3GD20_AD_4 ((uint8_t)0x10) /*!< bit 4 */ -#define L3GD20_AD_5 ((uint8_t)0x20) /*!< bit 5 */ - -#define L3GD20_MS ((uint8_t)0x40) /*!< Multiple read write */ -#define L3GD20_RW ((uint8_t)0x80) /*!< Read Write, 1 0 */ - -/****************** Bit definition for Registers Addresses *******************/ -#define L3GD20_AD_WHO_AM_I ((uint8_t)0x0F) /*!< WHO I AM */ -#define L3GD20_AD_CTRL_REG1 ((uint8_t)0x20) /*!< CONTROL REGISTER 1 */ -#define L3GD20_AD_CTRL_REG2 ((uint8_t)0x21) /*!< CONTROL REGISTER 2 */ -#define L3GD20_AD_CTRL_REG3 ((uint8_t)0x22) /*!< CONTROL REGISTER 3 */ -#define L3GD20_AD_CTRL_REG4 ((uint8_t)0x23) /*!< CONTROL REGISTER 4 */ -#define L3GD20_AD_CTRL_REG5 ((uint8_t)0x24) /*!< CONTROL REGISTER 5 */ -#define L3GD20_AD_REFERENCE ((uint8_t)0x25) /*!< REFERENCE/DATACAPTURE */ -#define L3GD20_AD_OUT_TEMP ((uint8_t)0x26) /*!< MEMS ONBOARD TEMP SENSOR */ -#define L3GD20_AD_STATUS_REG ((uint8_t)0x27) /*!< STATUS REGISTER */ -#define L3GD20_AD_OUT_X_L ((uint8_t)0x28) /*!< OUTPUT X-AXIS LOW */ -#define L3GD20_AD_OUT_X_H ((uint8_t)0x29) /*!< OUTPUT X-AXIS HIGH */ -#define L3GD20_AD_OUT_Y_L ((uint8_t)0x2A) /*!< OUTPUT Y-AXIS LOW */ -#define L3GD20_AD_OUT_Y_H ((uint8_t)0x2B) /*!< OUTPUT Y-AXIS HIGH */ -#define L3GD20_AD_OUT_Z_L ((uint8_t)0x2C) /*!< OUTPUT Z-AXIS LOW */ -#define L3GD20_AD_OUT_Z_H ((uint8_t)0x2D) /*!< OUTPUT Z-AXIS HIGH */ -#define L3GD20_AD_FIFO_CTRL_REG ((uint8_t)0x2E) /*!< FIFO CONTROL REGISTER */ -#define L3GD20_AD_FIFO_SRC_REG ((uint8_t)0x2F) /*!< FIFO SOURCE REGISTER */ -#define L3GD20_AD_INT1_CFG ((uint8_t)0x30) /*!< INTERRUPT1 CONFIG REGISTER */ -#define L3GD20_AD_INT1_SRC ((uint8_t)0x31) /*!< INTERRUPT1 SOURCE REGISTER */ -#define L3GD20_AD_INT1_TSH_XH ((uint8_t)0x32) /*!< INTERRUPT1 THRESHOLD X-AXIS HIGH */ -#define L3GD20_AD_INT1_TSH_XL ((uint8_t)0x33) /*!< INTERRUPT1 THRESHOLD X-AXIS LOW */ -#define L3GD20_AD_INT1_TSH_YH ((uint8_t)0x34) /*!< INTERRUPT1 THRESHOLD Y-AXIS HIGH */ -#define L3GD20_AD_INT1_TSH_YL ((uint8_t)0x35) /*!< INTERRUPT1 THRESHOLD Y-AXIS LOW */ -#define L3GD20_AD_INT1_TSH_ZH ((uint8_t)0x36) /*!< INTERRUPT1 THRESHOLD Z-AXIS HIGH */ -#define L3GD20_AD_INT1_TSH_ZL ((uint8_t)0x37) /*!< INTERRUPT1 THRESHOLD Z-AXIS LOW */ -#define L3GD20_AD_INT1_DURATION ((uint8_t)0x38) /*!< INTERRUPT1 DURATION */ - -/** @} */ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @name Gyroscope data structures and types - * @{ - */ - -/** - * @brief Gyroscope Output Data Rate - */ -typedef enum { - L3GD20_ODR_95Hz_Fc_12_5 = 0x00, /*!< Output Data Rate = 95 Hz - LPF Cut-Off = 12.5 Hz */ - L3GD20_ODR_95Hz_Fc_25 = 0x10, /*!< Output Data Rate = 95 Hz - LPF Cut-Off = 25 Hz */ - L3GD20_ODR_190Hz_Fc_12_5 = 0x40, /*!< Output Data Rate = 190 Hz - LPF Cut-Off = 12.5 Hz */ - L3GD20_ODR_190Hz_Fc_25 = 0x50, /*!< Output Data Rate = 190 Hz - LPF Cut-Off = 25 Hz */ - L3GD20_ODR_190Hz_Fc_50 = 0x60, /*!< Output Data Rate = 190 Hz - LPF Cut-Off = 50 Hz */ - L3GD20_ODR_190Hz_Fc_70 = 0x70, /*!< Output Data Rate = 190 Hz - LPF Cut-Off = 70 Hz */ - L3GD20_ODR_380Hz_Fc_20 = 0x80, /*!< Output Data Rate = 380 Hz - LPF Cut-Off = 20 Hz */ - L3GD20_ODR_380Hz_Fc_25 = 0x90, /*!< Output Data Rate = 380 Hz - LPF Cut-Off = 25 Hz */ - L3GD20_ODR_380Hz_Fc_50 = 0xA0, /*!< Output Data Rate = 380 Hz - LPF Cut-Off = 50 Hz */ - L3GD20_ODR_380Hz_Fc_100 = 0xB0, /*!< Output Data Rate = 380 Hz - LPF Cut-Off = 100 Hz */ - L3GD20_ODR_760Hz_Fc_30 = 0xC0, /*!< Output Data Rate = 760 Hz - LPF Cut-Off = 30 Hz */ - L3GD20_ODR_760Hz_Fc_35 = 0xD0, /*!< Output Data Rate = 760 Hz - LPF Cut-Off = 35 Hz */ - L3GD20_ODR_760Hz_Fc_50 = 0xE0, /*!< Output Data Rate = 760 Hz - LPF Cut-Off = 50 Hz */ - L3GD20_ODR_760Hz_Fc_100 = 0xF0 /*!< Output Data Rate = 760 Hz - LPF Cut-Off = 100 Hz */ -}L3GD20_ODR_t; - -/** - * @brief Gyroscope Power Mode - */ -typedef enum { - L3GD20_PM_POWER_DOWN = 0x00, /*!< Normal mode enabled */ - L3GD20_PM_SLEEP_NORMAL = 0x08 /*!< Low Power mode enabled */ -}L3GD20_PM_t; - -/** - * @brief Gyroscope Full Scale - */ -typedef enum { - L3GD20_FS_250DPS = 0x00, /*!< ±250 dps */ - L3GD20_FS_500DPS = 0x10, /*!< ±500 dps */ - L3GD20_FS_2000DPS = 0x20 /*!< ±200 dps */ -}L3GD20_FS_t; - -/** - * @brief Gyroscope Axes Enabling - */ -typedef enum { - L3GD20_AE_DISABLED = 0x00, /*!< All disabled */ - L3GD20_AE_X = 0x01, /*!< Only X */ - L3GD20_AE_Y = 0x02, /*!< Only Y */ - L3GD20_AE_XY = 0x03, /*!< X & Y */ - L3GD20_AE_Z = 0x04, /*!< Only Z */ - L3GD20_AE_XZ = 0x05, /*!< X & Z */ - L3GD20_AE_YZ = 0x06, /*!< Y & Z */ - L3GD20_AE_XYZ = 0x07 /*!< All enabled */ -}L3GD20_AE_t; - -/** - * @brief Gyroscope Block Data Update - */ -typedef enum { - L3GD20_BDU_CONTINOUS = 0x00, /*!< Continuos Update */ - L3GD20_BDU_BLOCKED = 0x80 /*!< Single Update: output registers not updated until MSB and LSB reading */ -}L3GD20_BDU_t; - -/** - * @brief Gyroscope Endianness - */ -typedef enum { - L3GD20_End_LITTLE = 0x00, /*!< Little Endian: data LSB @ lower address */ - L3GD20_End_BIG = 0x40 /*!< Big Endian: data MSB @ lower address */ -}L3GD20_End_t; - - -/** - * @brief Gyroscope configuration structure. - */ -typedef struct { - /** - * @brief Gyroscope fullscale value. - */ - L3GD20_FS_t fullscale; - /** - * @brief Gyroscope power mode selection. - */ - L3GD20_PM_t powermode; - /** - * @brief Gyroscope output data rate selection. - */ - L3GD20_ODR_t outputdatarate; - /** - * @brief Gyroscope axes enabling. - */ - L3GD20_AE_t axesenabling; - /** - * @brief Gyroscope endianess. - */ - L3GD20_End_t endianess; - /** - * @brief Gyroscope block data update. - */ - L3GD20_BDU_t blockdataupdate; -} L3GD20_Config; -/** @} */ -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - - uint8_t l3gd20ReadRegister(SPIDriver *spip, uint8_t reg); - void l3gd20WriteRegister(SPIDriver *spip, uint8_t reg, uint8_t value); -#ifdef __cplusplus -} -#endif - -#endif /* _L3GD20_H_ */ - -/** @} */ - diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.c b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.c deleted file mode 100644 index 99b71e4..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lis3mdl.c - * @brief LIS3MDL MEMS interface module through I2C code. - * - * @addtogroup lis3mdl - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#include "lis3mdl.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Reads a generic sub-register value. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] message pointer to message - * @return register value. - */ -uint8_t lis3mdlReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message) { - - uint8_t txbuf, rxbuf[2]; -#if defined(STM32F103_MCUCONF) - txbuf = LSM303DLHC_SUB_MSB | sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, TIME_INFINITE); - } - return rxbuf[0]; -#else - txbuf = sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, TIME_INFINITE); - } - return rxbuf[0]; -#endif -} - -/** - * @brief Writes a value into a register. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] value the value to be written - * @param[out] message pointer to message - */ -void lis3mdlWriteRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message) { - - uint8_t txbuf[2]; - uint8_t rxbuf; - switch (sub) { - default: - /* Reserved register must not be written, according to the datasheet - * this could permanently damage the device. - */ - chDbgAssert(FALSE, "lis3mdlWriteRegister(), reserved register"); - case LIS3MDL_SUB_WHO_AM_I: - case LIS3MDL_SUB_STATUS_REG: - case LIS3MDL_SUB_OUT_X_L: - case LIS3MDL_SUB_OUT_X_H: - case LIS3MDL_SUB_OUT_Y_L: - case LIS3MDL_SUB_OUT_Y_H: - case LIS3MDL_SUB_OUT_Z_L: - case LIS3MDL_SUB_OUT_Z_H: - case LIS3MDL_SUB_INT_SOURCE: - case LIS3MDL_SUB_INT_THS_L: - case LIS3MDL_SUB_INT_THS_H: - /* Read only registers cannot be written, the command is ignored.*/ - return; - case LIS3MDL_SUB_CTRL_REG1: - case LIS3MDL_SUB_CTRL_REG2: - case LIS3MDL_SUB_CTRL_REG3: - case LIS3MDL_SUB_CTRL_REG4: - case LIS3MDL_SUB_CTRL_REG5: - case LIS3MDL_SUB_INT_CFG: - txbuf[0] = sub; - txbuf[1] = value; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, TIME_INFINITE); - } - break; - } -} -/** @} */ diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.h b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.h deleted file mode 100644 index e55978e..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lis3mdl.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lis3mdl.h - * @brief LIS3MDL MEMS interface module header. - * - * @{ - */ - -#ifndef _LIS3MDL_H_ -#define _LIS3MDL_H_ - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -#define LIS3MDL_COMP_SENS_4GA ((float)6842.0f) /*!< compass sensitivity with 4 GA full scale [LSB / Ga] */ -#define LIS3MDL_COMP_SENS_8GA ((float)3421.0f) /*!< compass sensitivity with 8 GA full scale [LSB / Ga] */ -#define LIS3MDL_COMP_SENS_12GA ((float)2281.0f) /*!< compass sensitivity with 12 GA full scale [LSB / Ga] */ -#define LIS3MDL_COMP_SENS_16GA ((float)1711.0f) /*!< compass sensitivity with 16 GA full scale [LSB / Ga] */ -/** - * @name LIS3MDL register names - * @{ - */ -/******************************************************************************/ -/* */ -/* LIS3MDL on board MEMS */ -/* */ -/******************************************************************************/ -/***************** Bit definition for I2C/SPI communication *****************/ -#define LIS3MDL_SUB ((uint8_t)0x7F) /*!< SUB[6:0] Sub-registers address Mask */ -#define LIS3MDL_SUB_0 ((uint8_t)0x01) /*!< bit 0 */ -#define LIS3MDL_SUB_1 ((uint8_t)0x02) /*!< bit 1 */ -#define LIS3MDL_SUB_2 ((uint8_t)0x08) /*!< bit 3 */ -#define LIS3MDL_SUB_4 ((uint8_t)0x10) /*!< bit 4 */ -#define LIS3MDL_SUB_5 ((uint8_t)0x20) /*!< bit 5 */ -#define LIS3MDL_SUB_6 ((uint8_t)0x40) /*!< bit 6 */ - -#define LIS3MDL_SUB_MSB ((uint8_t)0x80) /*!< Multiple data read\write bit */ - -/**************** Bit definition SUB-Registers Addresses ********************/ -#define LIS3MDL_SUB_WHO_AM_I ((uint8_t)0x0F) /*!< CONTROL REGISTER 1 */ -#define LIS3MDL_SUB_CTRL_REG1 ((uint8_t)0x20) /*!< CONTROL REGISTER 1 */ -#define LIS3MDL_SUB_CTRL_REG2 ((uint8_t)0x21) /*!< CONTROL REGISTER 2 */ -#define LIS3MDL_SUB_CTRL_REG3 ((uint8_t)0x22) /*!< CONTROL REGISTER 3 */ -#define LIS3MDL_SUB_CTRL_REG4 ((uint8_t)0x23) /*!< CONTROL REGISTER 4 */ -#define LIS3MDL_SUB_CTRL_REG5 ((uint8_t)0x24) /*!< CONTROL REGISTER 5 */ -#define LIS3MDL_SUB_STATUS_REG ((uint8_t)0x27) /*!< STATUS REGISTER */ -#define LIS3MDL_SUB_OUT_X_L ((uint8_t)0x28) /*!< OUTPUT X-AXIS LOW */ -#define LIS3MDL_SUB_OUT_X_H ((uint8_t)0x29) /*!< OUTPUT X-AXIS HIGH */ -#define LIS3MDL_SUB_OUT_Y_L ((uint8_t)0x2A) /*!< OUTPUT Y-AXIS LOW */ -#define LIS3MDL_SUB_OUT_Y_H ((uint8_t)0x2B) /*!< OUTPUT Y-AXIS HIGH */ -#define LIS3MDL_SUB_OUT_Z_L ((uint8_t)0x2C) /*!< OUTPUT Z-AXIS LOW */ -#define LIS3MDL_SUB_OUT_Z_H ((uint8_t)0x2D) /*!< OUTPUT Z-AXIS HIGH */ -#define LIS3MDL_SUB_INT_CFG ((uint8_t)0x30) /*!< INTERRUPT1 CONFIG */ -#define LIS3MDL_SUB_INT_SOURCE ((uint8_t)0x31) /*!< INTERRUPT1 SOURCE */ -#define LIS3MDL_SUB_INT_THS_L ((uint8_t)0x32) /*!< INTERRUPT1 THRESHOLD */ -#define LIS3MDL_SUB_INT_THS_H ((uint8_t)0x33) /*!< INTERRUPT1 DURATION */ - -/** @} */ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @name Compass data structures and types - * @{ - */ - -/** - * @brief Compass Slave Address - */ -typedef enum { - LIS3MDL_SAD_GND = 0x1C, /*!< COMPASS Slave Address when SA1 is to GND */ - LIS3MDL_SAD_VCC = 0x1E /*!< COMPASS Slave Address when SA1 is to VCC */ -}LIS3MDL_SAD_t; - -/** - * @brief Compass Operation Mode for X and Y axes - */ -typedef enum { - LIS3MDL_OMXY_LOW_POWER = 0x00, /*!< Operation Mode XY low power */ - LIS3MDL_OMXY_MEDIUM_PERFORMANCE = 0x20, /*!< Operation Mode XY medium performance */ - LIS3MDL_OMXY_HIGH_PERFORMANCE = 0x40, /*!< Operation Mode XY high performance */ - LIS3MDL_OMXY_ULTRA_PERFORMANCE = 0x60 /*!< Operation Mode XY ultra performance */ -}LIS3MDL_OMXY_t; - -/** - * @brief Compass Output Data Rate - */ -typedef enum { - LIS3MDL_ODR_0_625Hz = 0x00, /*!< Output Data Rate = 0.625 Hz */ - LIS3MDL_ODR_1_25Hz = 0x04, /*!< Output Data Rate = 1.25 Hz */ - LIS3MDL_ODR_2_5Hz = 0x08, /*!< Output Data Rate = 2.5 Hz */ - LIS3MDL_ODR_5Hz = 0x0C, /*!< Output Data Rate = 5 Hz */ - LIS3MDL_ODR_10Hz = 0x10, /*!< Output Data Rate = 10 Hz */ - LIS3MDL_ODR_20Hz = 0x14, /*!< Output Data Rate = 20 Hz */ - LIS3MDL_ODR_40Hz = 0x18, /*!< Output Data Rate = 40 Hz */ - LIS3MDL_ODR_80Hz = 0x1C /*!< Output Data Rate = 80 Hz */ -}LIS3MDL_ODR_t; - -/** - * @brief Compass Full Scale - */ -typedef enum { - LIS3MDL_FS_4GA = 0x00, /*!< ±4 Gauss */ - LIS3MDL_FS_8GA = 0x02, /*!< ±8 Gauss */ - LIS3MDL_FS_12GA = 0x04, /*!< ±12 Gauss */ - LIS3MDL_FS_16GA = 0x0C /*!< ±16 Gauss */ -}LIS3MDL_FS_t; - -/** - * @brief Compass Low Mode configuration - */ -typedef enum { - LIS3MDL_LOW_POWER_DISABLED = 0x00, /*!< Low Power mode disabled */ - LIS3MDL_LOW_POWER_ENABLED = 0x20 /*!< Low Power mode enabled */ -}LIS3MDL_PM_t; - -/** - * @brief Compass Mode - */ -typedef enum { - LIS3MDL_MD_CONTINOUS_CONVERSION = 0x00, /*!< Continous conversion mode */ - LIS3MDL_MD_SINGLE_CONVERSION = 0x01, /*!< Single conversion mode */ - LIS3MDL_MD_POWER_DOWN = 0x02 /*!< Power down mode */ -}LIS3MDL_MD_t; - - -/** - * @brief Compass Operation Mode for Z axis - */ -typedef enum { - LIS3MDL_OMZ_LOW_POWER = 0x00, /*!< Operation Mode Z low power */ - LIS3MDL_OMZ_MEDIUM_PERFORMANCE = 0x04, /*!< Operation Mode Z medium performance */ - LIS3MDL_OMZ_HIGH_PERFORMANCE = 0x08, /*!< Operation Mode Z high performance */ - LIS3MDL_OMZ_ULTRA_PERFORMANCE = 0x0C /*!< Operation Mode Z ultra performance */ -}LIS3MDL_OMZ_t; - -/** - * @brief Compass Endianness - */ -typedef enum { - LIS3MDL_End_LITTLE = 0x00, /*!< Little Endian: data LSB @ lower address */ - LIS3MDL_End_BIG = 0x02 /*!< Big Endian: data MSB @ lower address */ -}LIS3MDL_End_t; - -/** - * @brief Compass Block Data Update - */ -typedef enum { - LIS3MDL_BDU_CONTINOUS = 0x00, /*!< Continuos Update */ - LIS3MDL_BDU_BLOCKED = 0x40 /*!< Single Update: output registers not updated until MSB and LSB reading */ -}LIS3MDL_BDU_t; - - - - -/** - * @brief Gyroscope configuration structure. - */ -typedef struct { - /** - * @brief Compass Slave Address - */ - LIS3MDL_SAD_t slaveaddress; - /** - * @brief Compass Operation Mode for X and Y axes - */ - LIS3MDL_OMXY_t opmodexy; - /** - * @brief Compass Output Data Rate - */ - LIS3MDL_ODR_t outputdatarate; - /** - * @brief Compass Full Scale - */ - LIS3MDL_FS_t fullscale; - /** - * @brief Compass Low Mode configuration - */ - LIS3MDL_PM_t lowpowermode; - /** - * @brief Compass Mode - */ - LIS3MDL_MD_t mode; - /** - * @brief Compass Operation Mode for Z axis - */ - LIS3MDL_OMZ_t opmodez; - /** - * @brief Compass Endianness - */ - LIS3MDL_End_t endianess; - /** - * @brief Compass Block Data Update - */ - LIS3MDL_BDU_t blockdataupdate; -} LIS3MDL_Config; -/** @} */ -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - - uint8_t lis3mdlReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message); - void lis3mdlWriteRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message); -#ifdef __cplusplus -} -#endif - -#endif /* _LIS3MDL_H_ */ - -/** @} */ diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.c b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.c deleted file mode 100644 index 070c49c..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lsm303dlhc.c - * @brief LSM303DLHC MEMS interface module through I2C code. - * - * @addtogroup lsm303dlhc - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#include "lsm303dlhc.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Reads a generic sub-register value. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] message pointer to message - * @return register value. - */ -uint8_t lsm303dlhcReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message) { - - uint8_t txbuf, rxbuf[2]; -#if defined(STM32F103_MCUCONF) - txbuf = LSM303DLHC_SUB_MSB | sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, TIME_INFINITE); - } - return rxbuf[0]; -#else - txbuf = sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, TIME_INFINITE); - } - return rxbuf[0]; -#endif - - -} - -/** - * @brief Writes a value into a register. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] value the value to be written - * @param[out] message pointer to message - */ -void lsm303dlhcWriteRegister(I2CDriver *i2cp,uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message) { - - uint8_t txbuf[2]; - uint8_t rxbuf; - if(sad == LSM303DLHC_SAD_ACCEL){ - switch (sub) { - default: - /* Reserved register must not be written, according to the datasheet - * this could permanently damage the device. - */ - chDbgAssert(FALSE, "lsm303dlhcWriteRegister(), reserved register"); - case LSM303DLHC_SUB_ACC_STATUS_REG: - case LSM303DLHC_SUB_ACC_OUT_X_L: - case LSM303DLHC_SUB_ACC_OUT_X_H: - case LSM303DLHC_SUB_ACC_OUT_Y_L: - case LSM303DLHC_SUB_ACC_OUT_Y_H: - case LSM303DLHC_SUB_ACC_OUT_Z_L: - case LSM303DLHC_SUB_ACC_OUT_Z_H: - case LSM303DLHC_SUB_ACC_FIFO_SRC_REG: - case LSM303DLHC_SUB_ACC_INT1_SOURCE: - case LSM303DLHC_SUB_ACC_INT2_SOURCE: - case LSM303DLHC_SUB_ACC_CLICK_SRC: - /* Read only registers cannot be written, the command is ignored.*/ - return; - case LSM303DLHC_SUB_ACC_CTRL_REG1: - case LSM303DLHC_SUB_ACC_CTRL_REG2: - case LSM303DLHC_SUB_ACC_CTRL_REG3: - case LSM303DLHC_SUB_ACC_CTRL_REG4: - case LSM303DLHC_SUB_ACC_CTRL_REG5: - case LSM303DLHC_SUB_ACC_CTRL_REG6: - case LSM303DLHC_SUB_ACC_REFERENCE: - case LSM303DLHC_SUB_ACC_FIFO_CTRL_REG: - case LSM303DLHC_SUB_ACC_INT1_CFG: - case LSM303DLHC_SUB_ACC_INT1_THS: - case LSM303DLHC_SUB_ACC_INT1_DURATION: - case LSM303DLHC_SUB_ACC_INT2_CFG: - case LSM303DLHC_SUB_ACC_INT2_THS: - case LSM303DLHC_SUB_ACC_INT2_DURATION: - case LSM303DLHC_SUB_ACC_CLICK_CFG: - case LSM303DLHC_SUB_ACC_CLICK_THS: - case LSM303DLHC_SUB_ACC_TIME_LIMIT: - case LSM303DLHC_SUB_ACC_TIME_LATENCY: - case LSM303DLHC_SUB_ACC_TIME_WINDOW: - txbuf[0] = sub; - txbuf[1] = value; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, TIME_INFINITE); - } - break; - } - } - else if(sad == LSM303DLHC_SAD_COMPASS){ - switch (sub) { - default: - /* Reserved register must not be written, according to the datasheet - * this could permanently damage the device. - */ - chDbgAssert(FALSE, "lsm303dlhcWriteRegister(), reserved register"); - case LSM303DLHC_SUB_COMP_OUT_X_H: - case LSM303DLHC_SUB_COMP_OUT_X_L: - case LSM303DLHC_SUB_COMP_OUT_Z_H: - case LSM303DLHC_SUB_COMP_OUT_Z_L: - case LSM303DLHC_SUB_COMP_OUT_Y_H: - case LSM303DLHC_SUB_COMP_OUT_Y_L: - case LSM303DLHC_SUB_COMP_SR_REG: - case LSM303DLHC_SUB_COMP_IRA_REG: - case LSM303DLHC_SUB_COMP_IRB_REG: - case LSM303DLHC_SUB_COMP_IRC_REG: - case LSM303DLHC_SUB_COMP_TEMP_OUT_H: - case LSM303DLHC_SUB_COMP_TEMP_OUT_L: - /* Read only registers cannot be written, the command is ignored.*/ - return; - case LSM303DLHC_SUB_COMP_CRA_REG: - case LSM303DLHC_SUB_COMP_CRB_REG: - case LSM303DLHC_SUB_COMP_MR_REG: - txbuf[0] = sub; - txbuf[1] = value; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, TIME_INFINITE); - } - break; - } - } -} -/** @} */ diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.h b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.h deleted file mode 100644 index 46b51bc..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm303dlhc.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lsm303dlhc.h - * @brief LSM303DLHC MEMS interface module through I2C header. - * - * @addtogroup lsm303dlhc - * @{ - */ - -#ifndef _LSM303DLHC_H_ -#define _LSM303DLHC_H_ - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -#define LSM303DLHC_ACC_SENS_2G ((float)1671.836f) /*!< Accelerometer sensitivity with 2 G full scale [LSB * s^2 / m] */ -#define LSM303DLHC_ACC_SENS_4G ((float)835.918f) /*!< Accelerometer sensitivity with 4 G full scale [LSB * s^2 / m] */ -#define LSM303DLHC_ACC_SENS_8G ((float)417.959f) /*!< Accelerometer sensitivity with 8 G full scale [LSB * s^2 / m] */ -#define LSM303DLHC_ACC_SENS_16G ((float)208.979f) /*!< Accelerometer sensitivity with 16 G full scale [LSB * s^2 / m] */ - -#define LSM303DLHC_COMP_SENS_XY_1_3GA ((float)1100.0f) /*!< Compass sensitivity with 1.3 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_1_9GA ((float)855.0f) /*!< Compass sensitivity with 1.9 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_2_5GA ((float)670.0f) /*!< Compass sensitivity with 2.5 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_4_0GA ((float)450.0f) /*!< Compass sensitivity with 4.0 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_4_7GA ((float)400.0f) /*!< Compass sensitivity with 4.7 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_5_6GA ((float)330.0f) /*!< Compass sensitivity with 5.6 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_XY_8_1GA ((float)230.0f) /*!< Compass sensitivity with 8.1 GA full scale [LSB / Ga] */ - -#define LSM303DLHC_COMP_SENS_Z_1_3GA ((float)980.0f) /*!< Compass sensitivity with 1.3 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_1_9GA ((float)765.0f) /*!< Compass sensitivity with 1.9 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_2_5GA ((float)600.0f) /*!< Compass sensitivity with 2.5 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_4_0GA ((float)400.0f) /*!< Compass sensitivity with 4.0 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_4_7GA ((float)355.0f) /*!< Compass sensitivity with 4.7 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_5_6GA ((float)295.0f) /*!< Compass sensitivity with 5.6 GA full scale [LSB / Ga] */ -#define LSM303DLHC_COMP_SENS_Z_8_1GA ((float)205.0f) /*!< Compass sensitivity with 8.1 GA full scale [LSB / Ga] */ -/** - * @name LSM303DLHC register names - * @{ - */ -/******************************************************************************/ -/* */ -/* LSM303DLHC on board MEMS */ -/* */ -/******************************************************************************/ -/******************* Bit definition for I2C communication *******************/ -#define LSM303DLHC_SAD ((uint8_t)0x7F) /*!< SAD[6:0] Slave Address Mask */ -#define LSM303DLHC_SAD_ACCEL ((uint8_t)0x19) /*!< ACCELEROMETER Slave Address */ -#define LSM303DLHC_SAD_COMPASS ((uint8_t)0x1E) /*!< MAGNETOMETER Slave Address */ - -#define LSM303DLHC_SUB ((uint8_t)0x7F) /*!< SUB[6:0] Sub-registers address Mask */ -#define LSM303DLHC_SUB_0 ((uint8_t)0x01) /*!< bit 0 */ -#define LSM303DLHC_SUB_1 ((uint8_t)0x02) /*!< bit 1 */ -#define LSM303DLHC_SUB_2 ((uint8_t)0x08) /*!< bit 3 */ -#define LSM303DLHC_SUB_4 ((uint8_t)0x10) /*!< bit 4 */ -#define LSM303DLHC_SUB_5 ((uint8_t)0x20) /*!< bit 5 */ -#define LSM303DLHC_SUB_6 ((uint8_t)0x40) /*!< bit 6 */ - -#define LSM303DLHC_SUB_MSB ((uint8_t)0x80) /*!< Multiple data read\write bit */ - -/******** Bit definition for Accelerometer SUB-Registers Addresses **********/ -#define LSM303DLHC_SUB_ACC_CTRL_REG1 ((uint8_t)0x20) /*!< CONTROL REGISTER 1 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CTRL_REG2 ((uint8_t)0x21) /*!< CONTROL REGISTER 2 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CTRL_REG3 ((uint8_t)0x22) /*!< CONTROL REGISTER 3 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CTRL_REG4 ((uint8_t)0x23) /*!< CONTROL REGISTER 4 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CTRL_REG5 ((uint8_t)0x24) /*!< CONTROL REGISTER 5 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CTRL_REG6 ((uint8_t)0x25) /*!< CONTROL REGISTER 6 FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_REFERENCE ((uint8_t)0x26) /*!< REFERENCE/DATACAPTURE FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_STATUS_REG ((uint8_t)0x27) /*!< STATUS REGISTER FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_X_L ((uint8_t)0x28) /*!< OUTPUT X-AXIS LOW FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_X_H ((uint8_t)0x29) /*!< OUTPUT X-AXIS HIGH FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_Y_L ((uint8_t)0x2A) /*!< OUTPUT Y-AXIS LOW FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_Y_H ((uint8_t)0x2B) /*!< OUTPUT Y-AXIS HIGH FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_Z_L ((uint8_t)0x2C) /*!< OUTPUT Z-AXIS LOW FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_OUT_Z_H ((uint8_t)0x2D) /*!< OUTPUT Z-AXIS HIGH FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_FIFO_CTRL_REG ((uint8_t)0x2E) /*!< FIFO CONTROL REGISTER FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_FIFO_SRC_REG ((uint8_t)0x2F) /*!< FIFO SOURCE REGISTER FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT1_CFG ((uint8_t)0x30) /*!< INTERRUPT1 CONFIG FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT1_SOURCE ((uint8_t)0x31) /*!< INTERRUPT1 SOURCE FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT1_THS ((uint8_t)0x32) /*!< INTERRUPT1 THRESHOLD FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT1_DURATION ((uint8_t)0x33) /*!< INTERRUPT1 DURATION FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT2_CFG ((uint8_t)0x34) /*!< INTERRUPT2 CONFIG FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT2_SOURCE ((uint8_t)0x35) /*!< INTERRUPT2 SOURCE FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT2_THS ((uint8_t)0x36) /*!< INTERRUPT2 THRESHOLD FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_INT2_DURATION ((uint8_t)0x37) /*!< INTERRUPT2 DURATION FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CLICK_CFG ((uint8_t)0x38) /*!< CLICK CONFIG FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CLICK_SRC ((uint8_t)0x39) /*!< CLICK SOURCE FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_CLICK_THS ((uint8_t)0x3A) /*!< CLICK THRESHOLD FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_TIME_LIMIT ((uint8_t)0x3B) /*!< TIME LIMIT FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_TIME_LATENCY ((uint8_t)0x3C) /*!< TIME LATENCY FOR ACCELEROMETER */ -#define LSM303DLHC_SUB_ACC_TIME_WINDOW ((uint8_t)0x3D) /*!< TIME WINDOW FOR ACCELEROMETER */ - -/********* Bit definition for Compass SUB-Registers Addresses **********/ -#define LSM303DLHC_SUB_COMP_CRA_REG ((uint8_t)0x00) /*!< CONTROL REGISTER A FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_CRB_REG ((uint8_t)0x01) /*!< CONTROL REGISTER B FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_MR_REG ((uint8_t)0x02) /*!< STATUS REGISTER FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_X_H ((uint8_t)0x03) /*!< OUTPUT X-AXIS HIGH FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_X_L ((uint8_t)0x04) /*!< OUTPUT X-AXIS LOW FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_Z_H ((uint8_t)0x05) /*!< OUTPUT Z-AXIS HIGH FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_Z_L ((uint8_t)0x06) /*!< OUTPUT Z-AXIS LOW FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_Y_H ((uint8_t)0x07) /*!< OUTPUT Y-AXIS HIGH FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_OUT_Y_L ((uint8_t)0x08) /*!< OUTPUT Y-AXIS LOW FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_SR_REG ((uint8_t)0x09) /*!< SR REGISTER FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_IRA_REG ((uint8_t)0x0A) /*!< IR A REGISTER FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_IRB_REG ((uint8_t)0x0B) /*!< IR B REGISTER FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_IRC_REG ((uint8_t)0x0C) /*!< IR C REGISTER FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_TEMP_OUT_H ((uint8_t)0x31) /*!< OUTPUT TEMP HIGH FOR MAGNETOMETER */ -#define LSM303DLHC_SUB_COMP_TEMP_OUT_L ((uint8_t)0x32) /*!< OUTPUT TEMP LOW FOR MAGNETOMETER */ - -/** @} */ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @name Accelerometer data structures and types - * @{ - */ - -/** - * @brief Accelerometer Output Data Rate - */ -typedef enum -{ - LSM303DLHC_ACC_ODR_PD = 0x00, /*!< Power down */ - LSM303DLHC_ACC_ODR_1Hz = 0x10, /*!< Output Data Rate = 1 Hz */ - LSM303DLHC_ACC_ODR_10Hz = 0x20, /*!< Output Data Rate = 10 Hz */ - LSM303DLHC_ACC_ODR_25Hz = 0x30, /*!< Output Data Rate = 25 Hz */ - LSM303DLHC_ACC_ODR_50Hz = 0x40, /*!< Output Data Rate = 50 Hz */ - LSM303DLHC_ACC_ODR_100Hz = 0x50, /*!< Output Data Rate = 100 Hz */ - LSM303DLHC_ACC_ODR_200Hz = 0x60, /*!< Output Data Rate = 200 Hz */ - LSM303DLHC_ACC_ODR_400Hz = 0x70, /*!< Output Data Rate = 400 Hz */ - LSM303DLHC_ACC_ODR_1620Hz = 0x80, /*!< Output Data Rate = 1620 Hz Low Power mode only */ - LSM303DLHC_ACC_ODR_1344Hz = 0x90 /*!< Output Data Rate = 1344 Hz in Normal mode and 5376 Hz in Low Power Mode */ -}LSM303DLHC_ACC_ODR_t; - -/** - * @brief Accelerometer Power Mode - */ -typedef enum -{ - LSM303DLHC_ACC_PM_NORMAL = 0x00, /*!< Normal mode enabled */ - LSM303DLHC_ACC_PM_LOW_POWER = 0x08 /*!< Low Power mode enabled */ -}LSM303DLHC_ACC_PM_t; - -/** - * @brief Accelerometer Full Scale - */ -typedef enum -{ - LSM303DLHC_ACC_FS_2G = 0x00, /*!< ±2 g m/s^2 */ - LSM303DLHC_ACC_FS_4G = 0x10, /*!< ±4 g m/s^2 */ - LSM303DLHC_ACC_FS_8G = 0x20, /*!< ±8 g m/s^2 */ - LSM303DLHC_ACC_FS_16G = 0x30 /*!< ±16 g m/s^2 */ -}LSM303DLHC_ACC_FS_t; - -/** - * @brief Accelerometer Axes Enabling - */ -typedef enum{ - LSM303DLHC_ACC_AE_DISABLED = 0x00, /*!< Axes all disabled */ - LSM303DLHC_ACC_AE_X = 0x01, /*!< Only X-axis enabled */ - LSM303DLHC_ACC_AE_Y = 0x02, /*!< Only Y-axis enabled */ - LSM303DLHC_ACC_AE_XY = 0x03, /*!< X & Y axes enabled */ - LSM303DLHC_ACC_AE_Z = 0x04, /*!< Only Z-axis enabled */ - LSM303DLHC_ACC_AE_XZ = 0x05, /*!< X & Z axes enabled */ - LSM303DLHC_ACC_AE_YZ = 0x06, /*!< Y & Z axes enabled */ - LSM303DLHC_ACC_AE_XYZ = 0x07 /*!< All axes enabled */ -}LSM303DLHC_ACC_AE_t; - -/** - * @brief Accelerometer Block Data Update - */ -typedef enum -{ - LSM303DLHC_ACC_BDU_CONTINOUS = 0x00, /*!< Continuos Update */ - LSM303DLHC_ACC_BDU_BLOCKED = 0x80 /*!< Single Update: output registers not updated until MSB and LSB reading */ -}LSM303DLHC_ACC_BDU_t; - -/** - * @brief Accelerometer Endianness - */ -typedef enum -{ - LSM303DLHC_ACC_End_LITTLE = 0x00, /*!< Little Endian: data LSB @ lower address */ - LSM303DLHC_ACC_End_BIG = 0x40 /*!< Big Endian: data MSB @ lower address */ -}LSM303DLHC_ACC_End_t; - -/** - * @brief Accelerometer High Resolution mode - */ -typedef enum -{ - LSM303DLHC_ACC_HR_Enabled = 0x08, /*!< High resolution output mode enabled */ - LSM303DLHC_ACC_HR_Disabled = 0x00 /*!< High resolution output mode disabled */ -}LSM303DLHC_ACC_HR_t; - -/** - * @brief Accelerometer configuration structure. - */ -typedef struct { - /** - * @brief Accelerometer fullscale value. - */ - LSM303DLHC_ACC_FS_t fullscale; - /** - * @brief Accelerometer power mode selection. - */ - LSM303DLHC_ACC_PM_t powermode; - /** - * @brief Accelerometer output data rate selection. - */ - LSM303DLHC_ACC_ODR_t outputdatarate; - /** - * @brief Accelerometer axes enabling. - */ - LSM303DLHC_ACC_AE_t axesenabling; - /** - * @brief Accelerometer block data update. - */ - LSM303DLHC_ACC_BDU_t blockdataupdate; - /** - * @brief Accelerometer block data update. - */ - LSM303DLHC_ACC_HR_t highresmode; -} LSM303DLHC_ACC_Config; -/** @} */ - - -/** - * @name Compass data types - * @{ - */ - -/** - * @brief Compass Output Data Rate - */ -typedef enum -{ - LSM303DLHC_COMP_ODR_0_75_Hz = 0x00, /*!< Output Data Rate = 0.75 Hz */ - LSM303DLHC_COMP_ODR_1_5_Hz = 0x04, /*!< Output Data Rate = 1.5 Hz */ - LSM303DLHC_COMP_ODR_3_0_Hz = 0x08, /*!< Output Data Rate = 3 Hz */ - LSM303DLHC_COMP_ODR_7_5_Hz = 0x0C, /*!< Output Data Rate = 7.5 Hz */ - LSM303DLHC_COMP_ODR_15_Hz = 0x10, /*!< Output Data Rate = 15 Hz */ - LSM303DLHC_COMP_ODR_30_Hz = 0x14, /*!< Output Data Rate = 30 Hz */ - LSM303DLHC_COMP_ODR_75_Hz = 0x18, /*!< Output Data Rate = 75 Hz */ - LSM303DLHC_COMP_ODR_220_Hz = 0x1C /*!< Output Data Rate = 220 Hz */ -}LSM303DLHC_COMP_ODR_t; - - -/** - * @brief Compass Full Scale - */ -typedef enum -{ - LSM303DLHC_COMP_FS_1_3_GA = 0x20, /*!< Full scale = ±1.3 Gauss */ - LSM303DLHC_COMP_FS_1_9_GA = 0x40, /*!< Full scale = ±1.9 Gauss */ - LSM303DLHC_COMP_FS_2_5_GA = 0x60, /*!< Full scale = ±2.5 Gauss */ - LSM303DLHC_COMP_FS_4_0_GA = 0x80, /*!< Full scale = ±4.0 Gauss */ - LSM303DLHC_COMP_FS_4_7_GA = 0xA0, /*!< Full scale = ±4.7 Gauss */ - LSM303DLHC_COMP_FS_5_6_GA = 0xC0, /*!< Full scale = ±5.6 Gauss */ - LSM303DLHC_COMP_FS_8_1_GA = 0xE0 /*!< Full scale = ±8.1 Gauss */ -}LSM303DLHC_COMP_FS_t; - - -/** - * @brief Compass Working Mode - */ -typedef enum -{ - LSM303DLHC_COMP_WM_CONTINUOS = 0x00, /*!< Continuous-Conversion Mode */ - LSM303DLHC_COMP_WM_BLOCKED = 0x01, /*!< Single-Conversion Mode */ - LSM303DLHC_COMP_WM_SLEEP = 0x02 /*!< Sleep Mode */ -}LSM303DLHC_COMP_WM_t; - -/** - * @brief Compass configuration structure. - */ -typedef struct { - /** - * @brief Compass fullscale value. - */ - LSM303DLHC_COMP_FS_t fullscale; - /** - * @brief Compass output data rate selection. - */ - LSM303DLHC_COMP_ODR_t outputdatarate; - /** - * @brief Compass working mode. - */ - LSM303DLHC_COMP_WM_t workingmode; -} LSM303DLHC_COMP_Config; -/** @} */ -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - - uint8_t lsm303dlhcReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message); - void lsm303dlhcWriteRegister(I2CDriver *i2cp,uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message); - -#ifdef __cplusplus -} -#endif -#endif /* _LSM303DLHC_H_ */ -/** @} */ - diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.c b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.c deleted file mode 100644 index da67f12..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lsm6ds0.c - * @brief LSM6DS0 MEMS interface module through I2C code. - * - * @addtogroup lsm6ds0 - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#include "lsm6ds0.h" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Reads a generic sub-register value. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] message pointer to message - * @return register value. - */ -uint8_t lsm6ds0ReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message) { - - uint8_t txbuf, rxbuf[2]; -#if defined(STM32F103_MCUCONF) - txbuf = LSM303DLHC_SUB_MSB | sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 2, TIME_INFINITE); - } - return rxbuf[0]; -#else - txbuf = sub; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, &txbuf, 1, rxbuf, 1, TIME_INFINITE); - } - return rxbuf[0]; -#endif -} - -/** - * @brief Writes a value into a register. - * @pre The I2C interface must be initialized and the driver started. - * - * @param[in] i2cp pointer to the I2C interface - * @param[in] sad slave address without R bit - * @param[in] sub sub-register address - * @param[in] value the value to be written - * @param[out] message pointer to message - */ -void lsm6ds0WriteRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message) { - - uint8_t txbuf[2]; - uint8_t rxbuf; - switch (sub) { - default: - /* Reserved register must not be written, according to the datasheet - * this could permanently damage the device. - */ - chDbgAssert(FALSE, "lsm6ds0WriteRegister(), reserved register"); - case LSM6DS0_SUB_WHO_AM_I: - case LSM6DS0_SUB_INT_GEN_SRC_G: - case LSM6DS0_SUB_OUT_TEMP_L: - case LSM6DS0_SUB_OUT_TEMP_H: - case LSM6DS0_SUB_STATUS_REG1: - case LSM6DS0_SUB_OUT_X_L_G: - case LSM6DS0_SUB_OUT_X_H_G: - case LSM6DS0_SUB_OUT_Y_L_G: - case LSM6DS0_SUB_OUT_Y_H_G: - case LSM6DS0_SUB_OUT_Z_L_G: - case LSM6DS0_SUB_OUT_Z_H_G: - case LSM6DS0_SUB_INT_GEN_SRC_XL: - case LSM6DS0_SUB_STATUS_REG2: - case LSM6DS0_SUB_OUT_X_L_XL: - case LSM6DS0_SUB_OUT_X_H_XL: - case LSM6DS0_SUB_OUT_Y_L_XL: - case LSM6DS0_SUB_OUT_Y_H_XL: - case LSM6DS0_SUB_OUT_Z_L_XL: - case LSM6DS0_SUB_OUT_Z_H_XL: - case LSM6DS0_SUB_FIFO_SRC: - /* Read only registers cannot be written, the command is ignored.*/ - return; - case LSM6DS0_SUB_ACT_THS: - case LSM6DS0_SUB_ACT_DUR: - case LSM6DS0_SUB_INT_GEN_CFG_XL: - case LSM6DS0_SUB_INT_GEN_THS_X_XL: - case LSM6DS0_SUB_INT_GEN_THS_Y_XL: - case LSM6DS0_SUB_INT_GEN_THS_Z_XL: - case LSM6DS0_SUB_INT_GEN_DUR_XL: - case LSM6DS0_SUB_REFERENCE_G: - case LSM6DS0_SUB_INT_CTRL: - case LSM6DS0_SUB_CTRL_REG1_G: - case LSM6DS0_SUB_CTRL_REG2_G: - case LSM6DS0_SUB_CTRL_REG3_G: - case LSM6DS0_SUB_ORIENT_CFG_G: - case LSM6DS0_SUB_CTRL_REG4: - case LSM6DS0_SUB_CTRL_REG5_XL: - case LSM6DS0_SUB_CTRL_REG6_XL: - case LSM6DS0_SUB_CTRL_REG7_XL: - case LSM6DS0_SUB_CTRL_REG8: - case LSM6DS0_SUB_CTRL_REG9: - case LSM6DS0_SUB_CTRL_REG10: - case LSM6DS0_SUB_FIFO_CTRL: - case LSM6DS0_SUB_INT_GEN_CFG_G: - case LSM6DS0_SUB_INT_GEN_THS_XH_G: - case LSM6DS0_SUB_INT_GEN_THS_XL_G: - case LSM6DS0_SUB_INT_GEN_THS_YH_G: - case LSM6DS0_SUB_INT_GEN_THS_YL_G: - case LSM6DS0_SUB_INT_GEN_THS_ZH_G: - case LSM6DS0_SUB_INT_GEN_THS_ZL_G: - case LSM6DS0_SUB_INT_GEN_DUR_G: - txbuf[0] = sub; - txbuf[1] = value; - if(message != NULL){ - *message = i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, - TIME_INFINITE); - } - else{ - i2cMasterTransmitTimeout(i2cp, sad, txbuf, 2, &rxbuf, 0, TIME_INFINITE); - } - break; - } -} - -/** @} */ diff --git a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.h b/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.h deleted file mode 100644 index 57e2057..0000000 --- a/ChibiOS_16.1.5/community/os/various/devices_lib/mems/lsm6ds0.h +++ /dev/null @@ -1,482 +0,0 @@ -/* - Pretty LAYer for ChibiOS/RT - Copyright (C) 2015 Rocco Marco Guglielmi - - This file is part of PLAY for ChibiOS/RT. - - PLAY is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - PLAY 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -/* - Special thanks to Giovanni Di Sirio for teachings, his moral support and - friendship. Note that some or every piece of this file could be part of - the ChibiOS project that is intellectual property of Giovanni Di Sirio. - Please refer to ChibiOS/RT license before use this file. - - For suggestion or Bug report - roccomarco.guglielmi@playembedded.org - */ - -/** - * @file lsm6ds0.h - * @brief LSM6DS0 MEMS interface module header. - * - * @{ - */ - -#ifndef _LSM6DS0_H_ -#define _LSM6DS0_H_ - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -#define LSM6DS0_ACC_SENS_2G ((float)1671.095f) /*!< Accelerometer sensitivity with 2 G full scale [LSB * s^2 / m] */ -#define LSM6DS0_ACC_SENS_4G ((float)835.547f) /*!< Accelerometer sensitivity with 4 G full scale [LSB * s^2 / m] */ -#define LSM6DS0_ACC_SENS_8G ((float)417.774) /*!< Accelerometer sensitivity with 8 G full scale [LSB * s^2 / m] */ -#define LSM6DS0_ACC_SENS_16G ((float)139.258f) /*!< Accelerometer sensitivity with 16 G full scale [LSB * s^2 / m] */ - -#define LSM6DS0_GYRO_SENS_245DPS ((float)114.286f) /*!< Gyroscope sensitivity with 245 dps full scale [LSB * s / °] */ -#define LSM6DS0_GYRO_SENS_500DPS ((float)57.143f) /*!< Gyroscope sensitivity with 500 dps full scale [LSB * s / °] */ -#define LSM6DS0_GYRO_SENS_2000DPS ((float)14.286f) /*!< Gyroscope sensitivity with 2000 dps full scale [LSB * s / °] */ -/** - * @name LSM6DS0 register names - * @{ - */ -/******************************************************************************/ -/* */ -/* LSM6DS0 on board MEMS */ -/* */ -/******************************************************************************/ -/***************** Bit definition for I2C/SPI communication *****************/ -#define LSM6DS0_SUB ((uint8_t)0x7F) /*!< SUB[6:0] Sub-registers address Mask */ -#define LSM6DS0_SUB_0 ((uint8_t)0x01) /*!< bit 0 */ -#define LSM6DS0_SUB_1 ((uint8_t)0x02) /*!< bit 1 */ -#define LSM6DS0_SUB_2 ((uint8_t)0x08) /*!< bit 3 */ -#define LSM6DS0_SUB_4 ((uint8_t)0x10) /*!< bit 4 */ -#define LSM6DS0_SUB_5 ((uint8_t)0x20) /*!< bit 5 */ -#define LSM6DS0_SUB_6 ((uint8_t)0x40) /*!< bit 6 */ - -#define LSM6DS0_SUB_MSB ((uint8_t)0x80) /*!< Multiple data read\write bit */ - -/***************** Bit definition for Registers Addresses *******************/ -#define LSM6DS0_SUB_ACT_THS ((uint8_t)0x04) /*!< Activity threshold register */ -#define LSM6DS0_SUB_ACT_DUR ((uint8_t)0x05) /*!< Inactivity duration register */ -#define LSM6DS0_SUB_INT_GEN_CFG_XL ((uint8_t)0x06) /*!< Accelerometer interrupt generator configuration register */ -#define LSM6DS0_SUB_INT_GEN_THS_X_XL ((uint8_t)0x07) /*!< Accelerometer X-axis interrupt threshold register */ -#define LSM6DS0_SUB_INT_GEN_THS_Y_XL ((uint8_t)0x08) /*!< Accelerometer Y-axis interrupt threshold register */ -#define LSM6DS0_SUB_INT_GEN_THS_Z_XL ((uint8_t)0x09) /*!< Accelerometer Z-axis interrupt threshold register */ -#define LSM6DS0_SUB_INT_GEN_DUR_XL ((uint8_t)0x0A) /*!< Accelerometer interrupt duration register */ -#define LSM6DS0_SUB_REFERENCE_G ((uint8_t)0x0B) /*!< Gyroscope reference value register for digital high-pass filter */ -#define LSM6DS0_SUB_INT_CTRL ((uint8_t)0x0C) /*!< INT pin control register */ -#define LSM6DS0_SUB_WHO_AM_I ((uint8_t)0x0F) /*!< Who_AM_I register */ -#define LSM6DS0_SUB_CTRL_REG1_G ((uint8_t)0x10) /*!< Gyroscope control register 1 */ -#define LSM6DS0_SUB_CTRL_REG2_G ((uint8_t)0x11) /*!< Gyroscope control register 2 */ -#define LSM6DS0_SUB_CTRL_REG3_G ((uint8_t)0x12) /*!< Gyroscope control register 3 */ -#define LSM6DS0_SUB_ORIENT_CFG_G ((uint8_t)0x13) /*!< Gyroscope sign and orientation register */ -#define LSM6DS0_SUB_INT_GEN_SRC_G ((uint8_t)0x14) /*!< Gyroscope interrupt source register */ -#define LSM6DS0_SUB_OUT_TEMP_L ((uint8_t)0x15) /*!< Temperature data output low register */ -#define LSM6DS0_SUB_OUT_TEMP_H ((uint8_t)0x16) /*!< Temperature data output high register */ -#define LSM6DS0_SUB_STATUS_REG1 ((uint8_t)0x17) /*!< Status register 1 */ -#define LSM6DS0_SUB_OUT_X_L_G ((uint8_t)0x18) /*!< Gyroscope X-axis low output register */ -#define LSM6DS0_SUB_OUT_X_H_G ((uint8_t)0x19) /*!< Gyroscope X-axis high output register */ -#define LSM6DS0_SUB_OUT_Y_L_G ((uint8_t)0x1A) /*!< Gyroscope Y-axis low output register */ -#define LSM6DS0_SUB_OUT_Y_H_G ((uint8_t)0x1B) /*!< Gyroscope Y-axis high output register */ -#define LSM6DS0_SUB_OUT_Z_L_G ((uint8_t)0x1C) /*!< Gyroscope Z-axis low output register */ -#define LSM6DS0_SUB_OUT_Z_H_G ((uint8_t)0x1D) /*!< Gyroscope Z-axis high output register */ -#define LSM6DS0_SUB_CTRL_REG4 ((uint8_t)0x1E) /*!< Control register 4 */ -#define LSM6DS0_SUB_CTRL_REG5_XL ((uint8_t)0x1F) /*!< Accelerometer Control Register 5 */ -#define LSM6DS0_SUB_CTRL_REG6_XL ((uint8_t)0x20) /*!< Accelerometer Control Register 6 */ -#define LSM6DS0_SUB_CTRL_REG7_XL ((uint8_t)0x21) /*!< Accelerometer Control Register 7 */ -#define LSM6DS0_SUB_CTRL_REG8 ((uint8_t)0x22) /*!< Control register 8 */ -#define LSM6DS0_SUB_CTRL_REG9 ((uint8_t)0x23) /*!< Control register 9 */ -#define LSM6DS0_SUB_CTRL_REG10 ((uint8_t)0x24) /*!< Control register 10 */ -#define LSM6DS0_SUB_INT_GEN_SRC_XL ((uint8_t)0x26) /*!< Accelerometer interrupt source register */ -#define LSM6DS0_SUB_STATUS_REG2 ((uint8_t)0x27) /*!< Status register */ -#define LSM6DS0_SUB_OUT_X_L_XL ((uint8_t)0x28) /*!< Accelerometer X-axis low output register */ -#define LSM6DS0_SUB_OUT_X_H_XL ((uint8_t)0x29) /*!< Accelerometer X-axis high output register */ -#define LSM6DS0_SUB_OUT_Y_L_XL ((uint8_t)0x2A) /*!< Accelerometer Y-axis low output register */ -#define LSM6DS0_SUB_OUT_Y_H_XL ((uint8_t)0x2B) /*!< Accelerometer Y-axis high output register */ -#define LSM6DS0_SUB_OUT_Z_L_XL ((uint8_t)0x2C) /*!< Accelerometer Z-axis low output register */ -#define LSM6DS0_SUB_OUT_Z_H_XL ((uint8_t)0x2D) /*!< Accelerometer Z-axis high output register */ -#define LSM6DS0_SUB_FIFO_CTRL ((uint8_t)0x2E) /*!< FIFO control register */ -#define LSM6DS0_SUB_FIFO_SRC ((uint8_t)0x2F) /*!< FIFO status control register */ -#define LSM6DS0_SUB_INT_GEN_CFG_G ((uint8_t)0x30) /*!< Gyroscope interrupt generator configuration register */ -#define LSM6DS0_SUB_INT_GEN_THS_XH_G ((uint8_t)0x31) /*!< Gyroscope X-axis low interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_THS_XL_G ((uint8_t)0x32) /*!< Gyroscope X-axis high interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_THS_YH_G ((uint8_t)0x33) /*!< Gyroscope Y-axis low interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_THS_YL_G ((uint8_t)0x34) /*!< Gyroscope Y-axis high interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_THS_ZH_G ((uint8_t)0x35) /*!< Gyroscope Z-axis low interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_THS_ZL_G ((uint8_t)0x36) /*!< Gyroscope Z-axis high interrupt generator threshold registers */ -#define LSM6DS0_SUB_INT_GEN_DUR_G ((uint8_t)0x37) /*!< Gyroscope interrupt generator duration register */ - -/** @} */ - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver data structures and types. */ -/*===========================================================================*/ - -/** - * @name Generic LSM6DS0 data structures and types - * @{ - */ - -/** - * @brief Accelerometer and Gyroscope Slave Address - */ -typedef enum { - LSM6DS0_SAD_GND = 0x6A, /*!< LSM6DS0 Slave Address when SA1 is to GND */ - LSM6DS0_SAD_VCC = 0x6B /*!< LSM6DS0 Slave Address when SA1 is to VCC */ -}LSM6DS0_SAD_t; - -/** - * @brief Accelerometer and Gyroscope Block Data Update - */ -typedef enum -{ - LSM6DS0_BDU_CONTINOUS = 0x00, /*!< Continuos Update */ - LSM6DS0_BDU_BLOCKED = 0x40 /*!< Single Update: output registers not updated until MSB and LSB reading */ -}LSM6DS0_BDU_t; - -/** - * @brief Accelerometer and Gyroscope Endianness - */ -typedef enum -{ - LSM6DS0_END_LITTLE = 0x00, /*!< Little Endian: data LSB @ lower address */ - LSM6DS0_END_BIG = 0x20 /*!< Big Endian: data MSB @ lower address */ -}LSM6DS0_END_t; -/** @} */ - -/** - * @name Accelerometer data structures and types - * @{ - */ - -/** - * @brief Accelerometer Decimation Mode - */ -typedef enum { - LSM6DS0_ACC_DEC_DISABLED = 0x00, /*!< NO decimation */ - LSM6DS0_ACC_DEC_X2 = 0x40, /*!< Decimation update every 2 sample */ - LSM6DS0_ACC_DEC_X4 = 0x80, /*!< Decimation update every 4 sample */ - LSM6DS0_ACC_DEC_X8 = 0xC0 /*!< Decimation update every 8 sample */ -}LSM6DS0_ACC_DEC_t; - -/** - * @brief Accelerometer Axes Enabling - */ -typedef enum{ - LSM6DS0_ACC_AE_DISABLED = 0x00, /*!< Axes all disabled */ - LSM6DS0_ACC_AE_X = 0x08, /*!< Only X-axis enabled */ - LSM6DS0_ACC_AE_Y = 0x10, /*!< Only Y-axis enabled */ - LSM6DS0_ACC_AE_XY = 0x18, /*!< X & Y axes enabled */ - LSM6DS0_ACC_AE_Z = 0x20, /*!< Only Z-axis enabled */ - LSM6DS0_ACC_AE_XZ = 0x28, /*!< X & Z axes enabled */ - LSM6DS0_ACC_AE_YZ = 0x30, /*!< Y & Z axes enabled */ - LSM6DS0_ACC_AE_XYZ = 0x38 /*!< All axes enabled */ -}LSM6DS0_ACC_AE_t; - -/** - * @brief Accelerometer Output Data Rate - */ -typedef enum { - LSM6DS0_ACC_ODR_PD = 0x00, /*!< Power down */ - LSM6DS0_ACC_ODR_10Hz = 0x20, /*!< Output Data Rate = 10 Hz */ - LSM6DS0_ACC_ODR_50Hz = 0x40, /*!< Output Data Rate = 50 Hz */ - LSM6DS0_ACC_ODR_119Hz = 0x60, /*!< Output Data Rate = 119 Hz */ - LSM6DS0_ACC_ODR_238Hz = 0x80, /*!< Output Data Rate = 238 Hz */ - LSM6DS0_ACC_ODR_476Hz = 0xA0, /*!< Output Data Rate = 476 Hz */ - LSM6DS0_ACC_ODR_952Hz = 0xC0 /*!< Output Data Rate = 952 Hz */ -}LSM6DS0_ACC_ODR_t; - -/** - * @brief Accelerometer Full Scale - */ -typedef enum { - LSM6DS0_ACC_FS_2G = 0x00, /*!< ±2 g m/s^2 */ - LSM6DS0_ACC_FS_4G = 0x10, /*!< ±4 g m/s^2 */ - LSM6DS0_ACC_FS_8G = 0x18, /*!< ±8 g m/s^2 */ - LSM6DS0_ACC_FS_16G = 0x08 /*!< ±16 g m/s^2 */ -}LSM6DS0_ACC_FS_t; - -/** - * @brief Accelerometer Antialiasing filter Bandwidth Selection - */ -typedef enum { - LSM6DS0_ACC_BW_408Hz = 0x00, /*!< AA filter bandwidth = 408 Hz */ - LSM6DS0_ACC_BW_211Hz = 0x01, /*!< AA filter bandwidth = 211 Hz */ - LSM6DS0_ACC_BW_105Hz = 0x02, /*!< AA filter bandwidth = 105 Hz */ - LSM6DS0_ACC_BW_50Hz = 0x03, /*!< AA filter bandwidth = 50 Hz */ - LSM6DS0_ACC_BW_ACCORDED = 0x04, /*!< AA filter bandwidth chosen by ODR selection */ -}LSM6DS0_ACC_BW_t; - -/** - * @brief Accelerometer High Resolution mode - */ -typedef enum -{ - LSM6DS0_ACC_HR_Disabled = 0x00, /*!< High resolution output mode disabled, FDS bypassed */ - LSM6DS0_ACC_HR_EN_9 = 0xC4, /*!< High resolution output mode enabled, LP cutoff = ODR/9, FDS enabled */ - LSM6DS0_ACC_HR_EN_50 = 0x84, /*!< High resolution output mode enabled, LP cutoff = ODR/50, FDS enabled */ - LSM6DS0_ACC_HR_EN_100 = 0xA4, /*!< High resolution output mode enabled, LP cutoff = ODR/100, FDS enabled */ - LSM6DS0_ACC_HR_EN_400 = 0xE4, /*!< High resolution output mode enabled, LP cutoff = ODR/400, FDS enabled */ -}LSM6DS0_ACC_HR_t; - -/** - * @brief HP filter for interrupt - */ -typedef enum -{ - LSM6DS0_ACC_HPIS1_BYPASSED = 0x00, /*!< High-pass filter bypassed */ - LSM6DS0_ACC_HPIS1_ENABLED = 0x01 /*!< High-pass filter enabled for accelerometer interrupt function on interrupt */ -}LSM6DS0_ACC_HPIS1_t; - -/** - * @brief Accelerometer configuration structure. - */ -typedef struct { - - /** - * @brief LSM6DS0 Slave Address - */ - LSM6DS0_SAD_t slaveaddress; - /** - * @brief Accelerometer Decimation Mode - */ - LSM6DS0_ACC_DEC_t decimation; - /** - * @brief Accelerometer Output Data Rate - */ - LSM6DS0_ACC_ODR_t outputdatarate; - /** - * @brief Accelerometer Antialiasing filter Bandwidth Selection - */ - LSM6DS0_ACC_BW_t bandwidth; - /** - * @brief Accelerometer Full Scale - */ - LSM6DS0_ACC_FS_t fullscale; - /** - * @brief Accelerometer Axes Enabling - */ - LSM6DS0_ACC_AE_t axesenabling; - /** - * @brief Accelerometer High Resolution mode - */ - LSM6DS0_ACC_HR_t highresmode; - /** - * @brief HP filter for interrupt - */ - LSM6DS0_ACC_HPIS1_t hpfirq; - /** - * @brief LSM6DS0 Endianness - */ - LSM6DS0_END_t endianess; - /** - * @brief LSM6DS0 Block Data Update - */ - LSM6DS0_BDU_t blockdataupdate; -} LSM6DS0_ACC_Config; -/** @} */ - -/** - * @name Gyroscope data structures and types - * @{ - */ - -/** - * @brief Gyroscope Output Data Rate - */ -typedef enum { - LSM6DS0_GYRO_ODR_PD = 0x00, /*!< Power down */ - LSM6DS0_GYRO_ODR_14_9Hz_CO_5Hz = 0x20, /*!< Output Data Rate = 14.9 Hz, CutOff = 5Hz */ - LSM6DS0_GYRO_ODR_59_5Hz_CO_16Hz = 0x40, /*!< Output Data Rate = 59.5 Hz, CutOff = 16Hz */ - LSM6DS0_GYRO_ODR_119Hz_CO_14Hz = 0x60, /*!< Output Data Rate = 119 Hz, CutOff = 14Hz */ - LSM6DS0_GYRO_ODR_119Hz_CO_31Hz = 0x61, /*!< Output Data Rate = 119 Hz, CutOff = 31Hz */ - LSM6DS0_GYRO_ODR_238Hz_CO_14Hz = 0x80, /*!< Output Data Rate = 238 Hz, CutOff = 14Hz */ - LSM6DS0_GYRO_ODR_238Hz_CO_29Hz = 0x81, /*!< Output Data Rate = 328 Hz, CutOff = 29Hz */ - LSM6DS0_GYRO_ODR_238Hz_CO_63Hz = 0x82, /*!< Output Data Rate = 238 Hz, CutOff = 63Hz */ - LSM6DS0_GYRO_ODR_238Hz_CO_78Hz = 0x83, /*!< Output Data Rate = 476 Hz, CutOff = 78Hz */ - LSM6DS0_GYRO_ODR_476Hz_CO_21Hz = 0xA0, /*!< Output Data Rate = 476 Hz, CutOff = 21Hz */ - LSM6DS0_GYRO_ODR_476Hz_CO_28Hz = 0xA1, /*!< Output Data Rate = 238 Hz, CutOff = 28Hz */ - LSM6DS0_GYRO_ODR_476Hz_CO_57Hz = 0xA2, /*!< Output Data Rate = 476 Hz, CutOff = 57Hz */ - LSM6DS0_GYRO_ODR_476Hz_CO_100Hz = 0xA3, /*!< Output Data Rate = 476 Hz, CutOff = 100Hz */ - LSM6DS0_GYRO_ODR_952Hz_CO_33Hz = 0xC0, /*!< Output Data Rate = 952 Hz, CutOff = 33Hz */ - LSM6DS0_GYRO_ODR_952Hz_CO_40Hz = 0xC1, /*!< Output Data Rate = 952 Hz, CutOff = 40Hz */ - LSM6DS0_GYRO_ODR_952Hz_CO_58Hz = 0xC2, /*!< Output Data Rate = 952 Hz, CutOff = 58Hz */ - LSM6DS0_GYRO_ODR_952Hz_CO_100Hz = 0xC3 /*!< Output Data Rate = 952 Hz, CutOff = 100Hz */ -}LSM6DS0_GYRO_ODR_t; - -/** - * @brief Gyroscope Full Scale - */ -typedef enum { - LSM6DS0_GYRO_FS_245DSP = 0x00, /*!< ±245 degrees per second */ - LSM6DS0_GYRO_FS_500DSP = 0x08, /*!< ±500 degrees per second */ - LSM6DS0_GYRO_FS_2000DSP = 0x18 /*!< ±2000 degrees per second */ -}LSM6DS0_GYRO_FS_t; - -/** - * @brief Gyroscope Output Selection - */ -typedef enum { - LSM6DS0_GYRO_OUT_SEL_BYPASS = 0x00, /*!< Output not filtered */ - LSM6DS0_GYRO_OUT_SEL_FILTERED = 0x01, /*!< Output filtered */ -}LSM6DS0_GYRO_OUT_SEL_t; - -/** - * @brief Gyroscope Interrupt Selection - */ -typedef enum { - LSM6DS0_GYRO_INT_SEL_BYPASS = 0x00, /*!< Interrupt generator signal not filtered */ - LSM6DS0_GYRO_INT_SEL_FILTERED = 0x08, /*!< Interrupt generator signal filtered */ -}LSM6DS0_GYRO_INT_SEL_t; - -/** - * @brief Gyroscope Low Power Mode - */ -typedef enum { - LSM6DS0_GYRO_LP_MODE_HIGH_PERFORMANCE = 0x00, /*!< High performance */ - LSM6DS0_GYRO_LP_MODE_LOW_POWER = 0x80, /*!< Low power */ -}LSM6DS0_GYRO_LP_MODE_t; - -/** - * @brief Gyroscope High Pass Filter Cutoff Selection - */ -typedef enum { - LSM6DS0_GYRO_HPCF_DISABLED = 0x00, /*!< HP filter disabled */ - LSM6DS0_GYRO_HPCF_0 = 0x40, /*!< Config 0 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_1 = 0x41, /*!< Config 1 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_2 = 0x42, /*!< Config 2 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_3 = 0x43, /*!< Config 3 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_4 = 0x44, /*!< Config 4 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_5 = 0x45, /*!< Config 5 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_6 = 0x46, /*!< Config 6 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_7 = 0x47, /*!< Config 7 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_8 = 0x48, /*!< Config 8 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_9 = 0x49, /*!< Config 9 refer to table 48 of DOcID025604 Rev 3 */ - LSM6DS0_GYRO_HPCF_10 = 0x4A /*!< Config 10 refer to table 48 of DOcID025604 Rev 3 */ -}LSM6DS0_GYRO_HPCF_t; - -/** - * @brief Gyroscope Axes Enabling - */ -typedef enum{ - LSM6DS0_GYRO_AE_DISABLED = 0x00, /*!< Axes all disabled */ - LSM6DS0_GYRO_AE_X = 0x08, /*!< Only X-axis enabled */ - LSM6DS0_GYRO_AE_Y = 0x10, /*!< Only Y-axis enabled */ - LSM6DS0_GYRO_AE_XY = 0x18, /*!< X & Y axes enabled */ - LSM6DS0_GYRO_AE_Z = 0x20, /*!< Only Z-axis enabled */ - LSM6DS0_GYRO_AE_XZ = 0x28, /*!< X & Z axes enabled */ - LSM6DS0_GYRO_AE_YZ = 0x30, /*!< Y & Z axes enabled */ - LSM6DS0_GYRO_AE_XYZ = 0x38 /*!< All axes enabled */ -}LSM6DS0_GYRO_AE_t; - -/** - * @brief Gyroscope Decimation Mode - */ -typedef enum { - LSM6DS0_GYRO_DEC_DISABLED = 0x00, /*!< NO decimation */ - LSM6DS0_GYRO_DEC_X2 = 0x40, /*!< Decimation update every 2 sample */ - LSM6DS0_GYRO_DEC_X4 = 0x80, /*!< Decimation update every 4 sample */ - LSM6DS0_GYRO_DEC_X8 = 0xC0 /*!< Decimation update every 8 sample */ -}LSM6DS0_GYRO_DEC_t; - -/** - * @brief Gyroscope Sleep Mode - */ -typedef enum { - LSM6DS0_GYRO_SLP_DISABLED = 0x00, /*!< Gyroscope sleep mode disabled */ - LSM6DS0_GYRO_SLP_ENABLED = 0x40 /*!< Gyroscope sleep mode enabled */ -}LSM6DS0_GYRO_SLP_t; -/** - * @brief Gyroscope configuration structure. - */ -typedef struct { - /** - * @brief LSM6DS0 Slave Address - */ - LSM6DS0_SAD_t slaveaddress; - /** - * @brief Gyroscope Output Data Rate - */ - LSM6DS0_GYRO_ODR_t outputdatarate; - /** - * @brief Gyroscope Full Scale - */ - LSM6DS0_GYRO_FS_t fullscale; - /** - * @brief Gyroscope Output Selection - */ - LSM6DS0_GYRO_OUT_SEL_t outputselect; - /** - * @brief Gyroscope Interrupt Selection - */ - LSM6DS0_GYRO_INT_SEL_t irqselect; - /** - * @brief Gyroscope Low Power Mode - */ - LSM6DS0_GYRO_LP_MODE_t lowpowermode; - /** - * @brief Gyroscope High Pass Filter Cutoff Selection - */ - LSM6DS0_GYRO_HPCF_t HPCfrequency; - /** - * @brief Gyroscope Axes Enabling - */ - LSM6DS0_GYRO_AE_t axesenabling; - /** - * @brief Gyroscope Decimation Mode - */ - LSM6DS0_GYRO_DEC_t decimation; - /** - * @brief LSM6DS0 Endianness - */ - LSM6DS0_END_t endianess; - /** - * @brief LSM6DS0 Block Data Update - */ - LSM6DS0_BDU_t blockdataupdate; -} LSM6DS0_GYRO_Config; -/** @} */ -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - - uint8_t lsm6ds0ReadRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - msg_t* message); - void lsm6ds0WriteRegister(I2CDriver *i2cp, uint8_t sad, uint8_t sub, - uint8_t value, msg_t* message); -#ifdef __cplusplus -} -#endif - -#endif /* _LSM6DS0_H_ */ - -/** @} */ |