JDI_MIP on ThunderBoardSense2(Silicon-Labs)

JDI_MIP (LPM013M126A) Sample on ThunderBoard2(Silicon-Labs)

/media/uploads/STakayama/mip8_tb2_sample0_.jpg LPM013M126A /media/uploads/STakayama/mip8_tb2_sample1.jpg

Links

https://os.mbed.com/teams/JapanDisplayInc/

https://os.mbed.com/teams/JapanDisplayInc/wiki/MIP-reflective-color-display

Committer:
STakayama
Date:
Tue Jan 22 10:23:39 2019 +0000
Revision:
13:9fb661dd4b2a
Parent:
10:525bcf8907fc
BackColor = Cyan

Who changed what in which revision?

UserRevisionLine numberNew contents of line
STakayama 10:525bcf8907fc 1 /***************************************************************************//**
STakayama 10:525bcf8907fc 2 * @file Si7210.h
STakayama 10:525bcf8907fc 3 * @brief Driver class for the Silicon Labs Si7210 I2C Hall-effect sensor
STakayama 10:525bcf8907fc 4 *******************************************************************************
STakayama 10:525bcf8907fc 5 * @section License
STakayama 10:525bcf8907fc 6 * <b>(C) Copyright 2017 Silicon Labs, http://www.silabs.com</b>
STakayama 10:525bcf8907fc 7 *******************************************************************************
STakayama 10:525bcf8907fc 8 *
STakayama 10:525bcf8907fc 9 * Permission is granted to anyone to use this software for any purpose,
STakayama 10:525bcf8907fc 10 * including commercial applications, and to alter it and redistribute it
STakayama 10:525bcf8907fc 11 * freely, subject to the following restrictions:
STakayama 10:525bcf8907fc 12 *
STakayama 10:525bcf8907fc 13 * 1. The origin of this software must not be misrepresented; you must not
STakayama 10:525bcf8907fc 14 * claim that you wrote the original software.
STakayama 10:525bcf8907fc 15 * 2. Altered source versions must be plainly marked as such, and must not be
STakayama 10:525bcf8907fc 16 * misrepresented as being the original software.
STakayama 10:525bcf8907fc 17 * 3. This notice may not be removed or altered from any source distribution.
STakayama 10:525bcf8907fc 18 *
STakayama 10:525bcf8907fc 19 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
STakayama 10:525bcf8907fc 20 * obligation to support this Software. Silicon Labs is providing the
STakayama 10:525bcf8907fc 21 * Software "AS IS", with no express or implied warranties of any kind,
STakayama 10:525bcf8907fc 22 * including, but not limited to, any implied warranties of merchantability
STakayama 10:525bcf8907fc 23 * or fitness for any particular purpose or warranties against infringement
STakayama 10:525bcf8907fc 24 * of any proprietary rights of a third party.
STakayama 10:525bcf8907fc 25 *
STakayama 10:525bcf8907fc 26 * Silicon Labs will not be liable for any consequential, incidental, or
STakayama 10:525bcf8907fc 27 * special damages, or any other relief, or for any claim by any third party,
STakayama 10:525bcf8907fc 28 * arising from your use of this Software.
STakayama 10:525bcf8907fc 29 *
STakayama 10:525bcf8907fc 30 ******************************************************************************/
STakayama 10:525bcf8907fc 31 #ifndef SI7210_H
STakayama 10:525bcf8907fc 32 #define SI7210_H
STakayama 10:525bcf8907fc 33
STakayama 10:525bcf8907fc 34 #include "mbed.h"
STakayama 10:525bcf8907fc 35
STakayama 10:525bcf8907fc 36 /* Possible I2C slave addresses */
STakayama 10:525bcf8907fc 37 #define SI7210_ADDRESS_0 (0x30U << 1)
STakayama 10:525bcf8907fc 38 #define SI7210_ADDRESS_1 (0x31U << 1)
STakayama 10:525bcf8907fc 39 #define SI7210_ADDRESS_2 (0x32U << 1)
STakayama 10:525bcf8907fc 40 #define SI7210_ADDRESS_3 (0x33U << 1)
STakayama 10:525bcf8907fc 41
STakayama 10:525bcf8907fc 42 /* Register addresses */
STakayama 10:525bcf8907fc 43 #define SI72XX_HREVID 0xC0U
STakayama 10:525bcf8907fc 44 #define SI72XX_DSPSIGM 0xC1U
STakayama 10:525bcf8907fc 45 #define SI72XX_DSPSIGL 0xC2U
STakayama 10:525bcf8907fc 46 #define SI72XX_DSPSIGSEL 0xC3U
STakayama 10:525bcf8907fc 47 #define SI72XX_POWER_CTRL 0xC4U
STakayama 10:525bcf8907fc 48 #define SI72XX_ARAUTOINC 0xC5U
STakayama 10:525bcf8907fc 49 #define SI72XX_CTRL1 0xC6U
STakayama 10:525bcf8907fc 50 #define SI72XX_CTRL2 0xC7U
STakayama 10:525bcf8907fc 51 #define SI72XX_SLTIME 0xC8U
STakayama 10:525bcf8907fc 52 #define SI72XX_CTRL3 0xC9U
STakayama 10:525bcf8907fc 53 #define SI72XX_A0 0xCAU
STakayama 10:525bcf8907fc 54 #define SI72XX_A1 0xCBU
STakayama 10:525bcf8907fc 55 #define SI72XX_A2 0xCCU
STakayama 10:525bcf8907fc 56 #define SI72XX_CTRL4 0xCDU
STakayama 10:525bcf8907fc 57 #define SI72XX_A3 0xCEU
STakayama 10:525bcf8907fc 58 #define SI72XX_A4 0xCFU
STakayama 10:525bcf8907fc 59 #define SI72XX_A5 0xD0U
STakayama 10:525bcf8907fc 60 #define SI72XX_OTP_ADDR 0xE1U
STakayama 10:525bcf8907fc 61 #define SI72XX_OTP_DATA 0xE2U
STakayama 10:525bcf8907fc 62 #define SI72XX_OTP_CTRL 0xE3U
STakayama 10:525bcf8907fc 63 #define SI72XX_TM_FG 0xE4U
STakayama 10:525bcf8907fc 64
STakayama 10:525bcf8907fc 65 #define SI72XX_ERROR_BUSY 0xFEU
STakayama 10:525bcf8907fc 66 #define SI72XX_ERROR_NODATA 0xFDU
STakayama 10:525bcf8907fc 67
STakayama 10:525bcf8907fc 68 /* Possible (bipolar) measurement range settings */
STakayama 10:525bcf8907fc 69 typedef enum {
STakayama 10:525bcf8907fc 70 RANGE_20mT,
STakayama 10:525bcf8907fc 71 RANGE_200mT
STakayama 10:525bcf8907fc 72 } Si7210_range_t;
STakayama 10:525bcf8907fc 73
STakayama 10:525bcf8907fc 74 namespace silabs {
STakayama 10:525bcf8907fc 75 class Si7210
STakayama 10:525bcf8907fc 76 {
STakayama 10:525bcf8907fc 77 public:
STakayama 10:525bcf8907fc 78 Si7210(PinName sda, PinName scl, uint8_t address);
STakayama 10:525bcf8907fc 79 Si7210(I2C *i2c_bus, uint8_t address = SI7210_ADDRESS_0);
STakayama 10:525bcf8907fc 80 ~Si7210();
STakayama 10:525bcf8907fc 81
STakayama 10:525bcf8907fc 82 /*
STakayama 10:525bcf8907fc 83 * Get last measured temperature data
STakayama 10:525bcf8907fc 84 * return: int = temperature in 1/4th degrees centigrade
STakayama 10:525bcf8907fc 85 */
STakayama 10:525bcf8907fc 86 int getTemperature();
STakayama 10:525bcf8907fc 87
STakayama 10:525bcf8907fc 88 /*
STakayama 10:525bcf8907fc 89 * Get last measured field strength
STakayama 10:525bcf8907fc 90 * return: int = field strength in micro-Tesla.
STakayama 10:525bcf8907fc 91 */
STakayama 10:525bcf8907fc 92 int getFieldStrength();
STakayama 10:525bcf8907fc 93
STakayama 10:525bcf8907fc 94 /*
STakayama 10:525bcf8907fc 95 * Set measurement range.
STakayama 10:525bcf8907fc 96 * Return true if successful, false if device is not responding.
STakayama 10:525bcf8907fc 97 */
STakayama 10:525bcf8907fc 98 bool setFieldStrength(Si7210_range_t range);
STakayama 10:525bcf8907fc 99
STakayama 10:525bcf8907fc 100 /*
STakayama 10:525bcf8907fc 101 * Return true if successful, false if device is not responding.
STakayama 10:525bcf8907fc 102 */
STakayama 10:525bcf8907fc 103 bool fetchFieldStrength();
STakayama 10:525bcf8907fc 104
STakayama 10:525bcf8907fc 105 bool measureOnce();
STakayama 10:525bcf8907fc 106
STakayama 10:525bcf8907fc 107 /*
STakayama 10:525bcf8907fc 108 * Check if the sensor is active and responding.
STakayama 10:525bcf8907fc 109 */
STakayama 10:525bcf8907fc 110 bool check();
STakayama 10:525bcf8907fc 111
STakayama 10:525bcf8907fc 112 /* Read a register from Si7210 */
STakayama 10:525bcf8907fc 113 bool readRegister(uint8_t reg, uint8_t *result);
STakayama 10:525bcf8907fc 114 bool writeRegister(uint8_t reg, uint8_t data);
STakayama 10:525bcf8907fc 115
STakayama 10:525bcf8907fc 116 bool wakeup();
STakayama 10:525bcf8907fc 117 bool sleep();
STakayama 10:525bcf8907fc 118
STakayama 10:525bcf8907fc 119 private:
STakayama 10:525bcf8907fc 120
STakayama 10:525bcf8907fc 121 I2C *_i2c;
STakayama 10:525bcf8907fc 122 bool _ownI2C;
STakayama 10:525bcf8907fc 123
STakayama 10:525bcf8907fc 124 uint8_t _address;
STakayama 10:525bcf8907fc 125
STakayama 10:525bcf8907fc 126 int8_t _temperatureOffset;
STakayama 10:525bcf8907fc 127 int8_t _temperatureGain;
STakayama 10:525bcf8907fc 128
STakayama 10:525bcf8907fc 129 int _rawTemperature;
STakayama 10:525bcf8907fc 130 int _rawField;
STakayama 10:525bcf8907fc 131
STakayama 10:525bcf8907fc 132 Si7210_range_t _range;
STakayama 10:525bcf8907fc 133
STakayama 10:525bcf8907fc 134 }; // class Si7210
STakayama 10:525bcf8907fc 135
STakayama 10:525bcf8907fc 136 } // namespace silabs
STakayama 10:525bcf8907fc 137
STakayama 10:525bcf8907fc 138 #endif