![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Updated version for LoraWan GEII IUT
Dependencies: Servo Cayenne-LPP
driver_mbed_TH02.h@64:1e20d66960c3, 2022-03-04 (annotated)
- Committer:
- alainpegatoquet
- Date:
- Fri Mar 04 09:50:35 2022 +0000
- Revision:
- 64:1e20d66960c3
Maj des drivers mbed-os et mbed-lora-radio-drv
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alainpegatoquet | 64:1e20d66960c3 | 1 | /* |
alainpegatoquet | 64:1e20d66960c3 | 2 | * TH02_dev.h |
alainpegatoquet | 64:1e20d66960c3 | 3 | * Driver for DIGITAL I2C HUMIDITY AND TEMPERATURE SENSOR |
alainpegatoquet | 64:1e20d66960c3 | 4 | * |
alainpegatoquet | 64:1e20d66960c3 | 5 | * Copyright (c) 2014 seeed technology inc. |
alainpegatoquet | 64:1e20d66960c3 | 6 | * Website : www.seeed.cc |
alainpegatoquet | 64:1e20d66960c3 | 7 | * Author : Oliver Wang |
alainpegatoquet | 64:1e20d66960c3 | 8 | * Create Time: April 2014 |
alainpegatoquet | 64:1e20d66960c3 | 9 | * Change Log : |
alainpegatoquet | 64:1e20d66960c3 | 10 | * |
alainpegatoquet | 64:1e20d66960c3 | 11 | * The MIT License (MIT) |
alainpegatoquet | 64:1e20d66960c3 | 12 | * |
alainpegatoquet | 64:1e20d66960c3 | 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
alainpegatoquet | 64:1e20d66960c3 | 14 | * of this software and associated documentation files (the "Software"), to deal |
alainpegatoquet | 64:1e20d66960c3 | 15 | * in the Software without restriction, including without limitation the rights |
alainpegatoquet | 64:1e20d66960c3 | 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
alainpegatoquet | 64:1e20d66960c3 | 17 | * copies of the Software, and to permit persons to whom the Software is |
alainpegatoquet | 64:1e20d66960c3 | 18 | * furnished to do so, subject to the following conditions: |
alainpegatoquet | 64:1e20d66960c3 | 19 | * |
alainpegatoquet | 64:1e20d66960c3 | 20 | * The above copyright notice and this permission notice shall be included in |
alainpegatoquet | 64:1e20d66960c3 | 21 | * all copies or substantial portions of the Software. |
alainpegatoquet | 64:1e20d66960c3 | 22 | * |
alainpegatoquet | 64:1e20d66960c3 | 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
alainpegatoquet | 64:1e20d66960c3 | 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
alainpegatoquet | 64:1e20d66960c3 | 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
alainpegatoquet | 64:1e20d66960c3 | 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
alainpegatoquet | 64:1e20d66960c3 | 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
alainpegatoquet | 64:1e20d66960c3 | 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
alainpegatoquet | 64:1e20d66960c3 | 29 | * THE SOFTWARE. |
alainpegatoquet | 64:1e20d66960c3 | 30 | */ |
alainpegatoquet | 64:1e20d66960c3 | 31 | |
alainpegatoquet | 64:1e20d66960c3 | 32 | #ifndef _TH02_DEV_H |
alainpegatoquet | 64:1e20d66960c3 | 33 | #define _TH02_DEV_H |
alainpegatoquet | 64:1e20d66960c3 | 34 | |
alainpegatoquet | 64:1e20d66960c3 | 35 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 36 | /*** Including Files ***/ |
alainpegatoquet | 64:1e20d66960c3 | 37 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 38 | // #include <Wire.h> |
alainpegatoquet | 64:1e20d66960c3 | 39 | // #include <Arduino.h> |
alainpegatoquet | 64:1e20d66960c3 | 40 | # include "mbed.h" |
alainpegatoquet | 64:1e20d66960c3 | 41 | |
alainpegatoquet | 64:1e20d66960c3 | 42 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 43 | /*** Macro Definitions ***/ |
alainpegatoquet | 64:1e20d66960c3 | 44 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 45 | // #define TH02_I2C_DEV_ID 0x40 |
alainpegatoquet | 64:1e20d66960c3 | 46 | const int TH02_I2C_DEV_ID = 0x40<<1; |
alainpegatoquet | 64:1e20d66960c3 | 47 | //Address for mbed |
alainpegatoquet | 64:1e20d66960c3 | 48 | |
alainpegatoquet | 64:1e20d66960c3 | 49 | #define REG_STATUS 0x00 |
alainpegatoquet | 64:1e20d66960c3 | 50 | #define REG_DATA_H 0x01 |
alainpegatoquet | 64:1e20d66960c3 | 51 | #define REG_DATA_L 0x02 |
alainpegatoquet | 64:1e20d66960c3 | 52 | #define REG_CONFIG 0x03 |
alainpegatoquet | 64:1e20d66960c3 | 53 | #define REG_ID 0x11 |
alainpegatoquet | 64:1e20d66960c3 | 54 | |
alainpegatoquet | 64:1e20d66960c3 | 55 | #define STATUS_RDY_MASK 0x01 //poll RDY,0 indicate the conversion is done |
alainpegatoquet | 64:1e20d66960c3 | 56 | |
alainpegatoquet | 64:1e20d66960c3 | 57 | #define CMD_MEASURE_HUMI 0x01 //perform a humility measurement |
alainpegatoquet | 64:1e20d66960c3 | 58 | #define CMD_MEASURE_TEMP 0x11 //perform a temperature measurement |
alainpegatoquet | 64:1e20d66960c3 | 59 | |
alainpegatoquet | 64:1e20d66960c3 | 60 | #define TH02_WR_REG_MODE 0xC0 |
alainpegatoquet | 64:1e20d66960c3 | 61 | #define TH02_RD_REG_MODE 0x80 |
alainpegatoquet | 64:1e20d66960c3 | 62 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 63 | /*** Class Definition ***/ |
alainpegatoquet | 64:1e20d66960c3 | 64 | /****************************************************************************/ |
alainpegatoquet | 64:1e20d66960c3 | 65 | class TH02_dev |
alainpegatoquet | 64:1e20d66960c3 | 66 | { |
alainpegatoquet | 64:1e20d66960c3 | 67 | public: |
alainpegatoquet | 64:1e20d66960c3 | 68 | void begin(); |
alainpegatoquet | 64:1e20d66960c3 | 69 | uint8_t isAvailable(); |
alainpegatoquet | 64:1e20d66960c3 | 70 | float ReadTemperature(void); |
alainpegatoquet | 64:1e20d66960c3 | 71 | float ReadHumidity(void); |
alainpegatoquet | 64:1e20d66960c3 | 72 | private: |
alainpegatoquet | 64:1e20d66960c3 | 73 | void TH02_IIC_WriteCmd(uint8_t u8Cmd); |
alainpegatoquet | 64:1e20d66960c3 | 74 | uint8_t TH02_IIC_ReadReg(uint8_t u8Reg); |
alainpegatoquet | 64:1e20d66960c3 | 75 | void TH02_IIC_WriteReg(uint8_t u8Reg,uint8_t u8Data); |
alainpegatoquet | 64:1e20d66960c3 | 76 | uint16_t TH02_IIC_ReadData(void); |
alainpegatoquet | 64:1e20d66960c3 | 77 | uint16_t TH02_IIC_ReadData2byte(void); |
alainpegatoquet | 64:1e20d66960c3 | 78 | }; |
alainpegatoquet | 64:1e20d66960c3 | 79 | |
alainpegatoquet | 64:1e20d66960c3 | 80 | extern TH02_dev myTH02; |
alainpegatoquet | 64:1e20d66960c3 | 81 | |
alainpegatoquet | 64:1e20d66960c3 | 82 | #endif // _TH02_DEV_H |