Component class library for PCT2075 and LM75B. The PCT2075 is a temperature-to-digital converter featuring +/-1 degree-C accuracy over -25 degree-C to +100 degree-C range. It uses an on-chip band gap temperature sensor and Sigma-Delta A-to-D conversion technique with an overtemperature detection output that is a drop-in replacement for other LM75 series thermal sensors.
Dependents: PCT2075_Hello Brushless_STM3_ESC_2019_10 Alternator2020_06
base_class/I2CTempSensor.h@1:0cdfb3ea5969, 2015-03-05 (annotated)
- Committer:
- okano
- Date:
- Thu Mar 05 06:14:19 2015 +0000
- Revision:
- 1:0cdfb3ea5969
- Parent:
- 0:ae0333775d7e
comment added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:ae0333775d7e | 1 | /** PCT2075 and LM75B component class library |
okano | 0:ae0333775d7e | 2 | * PCT2075 と LM75B 用のコンポーネント・クラス・ライブラリです |
okano | 0:ae0333775d7e | 3 | * |
okano | 0:ae0333775d7e | 4 | * This is new NXP PCT2075 and classic LM75B component class library |
okano | 0:ae0333775d7e | 5 | * This works for both PCT2075 and LM75B |
okano | 0:ae0333775d7e | 6 | * |
okano | 0:ae0333775d7e | 7 | * @author Tedd OKANO |
okano | 0:ae0333775d7e | 8 | * @version 1.0 |
okano | 0:ae0333775d7e | 9 | * @date 05-Mar-2015 |
okano | 0:ae0333775d7e | 10 | * |
okano | 1:0cdfb3ea5969 | 11 | * Released under the Apache 2 license License |
okano | 1:0cdfb3ea5969 | 12 | * |
okano | 0:ae0333775d7e | 13 | * For the details of PCT2075 and LM75B.. |
okano | 0:ae0333775d7e | 14 | * PCT2075 and LM75Bの詳細は.. |
okano | 0:ae0333775d7e | 15 | * http://www.nxp.com/documents/data_sheet/PCT2075.pdf |
okano | 0:ae0333775d7e | 16 | * http://www.nxp.com/documents/data_sheet/LM75B.pdf |
okano | 0:ae0333775d7e | 17 | */ |
okano | 0:ae0333775d7e | 18 | |
okano | 0:ae0333775d7e | 19 | #ifndef MBED_I2CTempSensor_H |
okano | 0:ae0333775d7e | 20 | #define MBED_I2CTempSensor_H |
okano | 0:ae0333775d7e | 21 | |
okano | 0:ae0333775d7e | 22 | #include "mbed.h" |
okano | 0:ae0333775d7e | 23 | |
okano | 0:ae0333775d7e | 24 | /** I2CTempSensor class library クラスライブラリ |
okano | 0:ae0333775d7e | 25 | * |
okano | 0:ae0333775d7e | 26 | * This class is an abstract class. So no instance can be made. |
okano | 0:ae0333775d7e | 27 | * このクラスは抽象クラスなのでインスタンスを作成することはできません |
okano | 0:ae0333775d7e | 28 | * クラスライブラリは非常にシンプルなインターフェースを提供します |
okano | 0:ae0333775d7e | 29 | */ |
okano | 0:ae0333775d7e | 30 | |
okano | 0:ae0333775d7e | 31 | class I2CTempSensor |
okano | 0:ae0333775d7e | 32 | { |
okano | 0:ae0333775d7e | 33 | public: |
okano | 0:ae0333775d7e | 34 | virtual float read( void ) = 0; |
okano | 0:ae0333775d7e | 35 | virtual operator float( void ) = 0; |
okano | 0:ae0333775d7e | 36 | |
okano | 0:ae0333775d7e | 37 | protected: |
okano | 0:ae0333775d7e | 38 | |
okano | 0:ae0333775d7e | 39 | /** LM75Bのレジスタ名とアドレス */ |
okano | 0:ae0333775d7e | 40 | enum command_reg { |
okano | 0:ae0333775d7e | 41 | LM75B_Temp = 0x00, |
okano | 0:ae0333775d7e | 42 | LM75B_Conf, |
okano | 0:ae0333775d7e | 43 | LM75B_Thyst, |
okano | 0:ae0333775d7e | 44 | LM75B_Tos |
okano | 0:ae0333775d7e | 45 | }; |
okano | 0:ae0333775d7e | 46 | |
okano | 0:ae0333775d7e | 47 | /** I2Cピンとスレーブアドレスを指定し,インスタンスを作成します |
okano | 0:ae0333775d7e | 48 | * |
okano | 0:ae0333775d7e | 49 | * @param i2c_sda I2C-bus i2c_sdaピン |
okano | 0:ae0333775d7e | 50 | * @param i2c_scl I2C-bus i2c_sclピン |
okano | 0:ae0333775d7e | 51 | * @param address (オプション) I2C-bus スレーブアドレス (デフォルト: 0x90) |
okano | 0:ae0333775d7e | 52 | */ |
okano | 0:ae0333775d7e | 53 | I2CTempSensor( PinName i2c_sda, PinName i2c_scl, char address ); |
okano | 0:ae0333775d7e | 54 | |
okano | 0:ae0333775d7e | 55 | /** I2Cオブジェクトとスレーブアドレスを指定し,インスタンスを作成します |
okano | 0:ae0333775d7e | 56 | * |
okano | 0:ae0333775d7e | 57 | * @param i2c_obj I2C オブジェクト (インスタンス) |
okano | 0:ae0333775d7e | 58 | * @param address (オプション) I2C-bus スレーブアドレス (デフォルト: 0x90) |
okano | 0:ae0333775d7e | 59 | */ |
okano | 0:ae0333775d7e | 60 | I2CTempSensor( I2C &i2c_obj, char address ); |
okano | 0:ae0333775d7e | 61 | |
okano | 0:ae0333775d7e | 62 | /** デストラクタ |
okano | 0:ae0333775d7e | 63 | */ |
okano | 0:ae0333775d7e | 64 | ~I2CTempSensor(); |
okano | 0:ae0333775d7e | 65 | |
okano | 0:ae0333775d7e | 66 | /** 初期化 |
okano | 0:ae0333775d7e | 67 | */ |
okano | 0:ae0333775d7e | 68 | void init( void ); |
okano | 0:ae0333775d7e | 69 | |
okano | 0:ae0333775d7e | 70 | /** 温度の読み出し |
okano | 0:ae0333775d7e | 71 | * |
okano | 0:ae0333775d7e | 72 | * @return 摂氏温度を返します(float型) |
okano | 0:ae0333775d7e | 73 | */ |
okano | 0:ae0333775d7e | 74 | short read16( void ); |
okano | 0:ae0333775d7e | 75 | |
okano | 0:ae0333775d7e | 76 | private: |
okano | 0:ae0333775d7e | 77 | I2C *i2c_p; |
okano | 0:ae0333775d7e | 78 | I2C &i2c; |
okano | 0:ae0333775d7e | 79 | char adr; |
okano | 0:ae0333775d7e | 80 | }; |
okano | 0:ae0333775d7e | 81 | |
okano | 0:ae0333775d7e | 82 | #endif // MBED_I2CTempSensor_H |
okano | 0:ae0333775d7e | 83 |