Tedd OKANO / PCT2075

Dependents:   PCT2075_Hello Brushless_STM3_ESC_2019_10 Alternator2020_06

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers I2CTempSensor.h Source File

I2CTempSensor.h

00001 /** PCT2075 and LM75B component class library
00002  *  PCT2075 と LM75B 用のコンポーネント・クラス・ライブラリです
00003  *
00004  *  This is new NXP PCT2075 and classic LM75B component class library
00005  *  This works for both PCT2075 and LM75B
00006  *
00007  *  @author  Tedd OKANO
00008  *  @version 1.0
00009  *  @date    05-Mar-2015
00010  *
00011  *  Released under the Apache 2 license License
00012  *
00013  *  For the details of PCT2075 and LM75B..
00014  *  PCT2075 and LM75Bの詳細は..
00015  *      http://www.nxp.com/documents/data_sheet/PCT2075.pdf
00016  *      http://www.nxp.com/documents/data_sheet/LM75B.pdf
00017  */
00018 
00019 #ifndef MBED_I2CTempSensor_H
00020 #define MBED_I2CTempSensor_H
00021 
00022 #include "mbed.h"
00023 
00024 /** I2CTempSensor class library クラスライブラリ
00025  *
00026  *  This class is an abstract class. So no instance can be made.
00027  *  このクラスは抽象クラスなのでインスタンスを作成することはできません
00028  *  クラスライブラリは非常にシンプルなインターフェースを提供します
00029  */
00030 
00031 class I2CTempSensor
00032 {
00033 public:
00034     virtual float   read( void )    = 0;
00035     virtual operator float( void )  = 0;
00036 
00037 protected:
00038 
00039     /** LM75Bのレジスタ名とアドレス */
00040     enum command_reg    {
00041         LM75B_Temp  = 0x00,
00042         LM75B_Conf,
00043         LM75B_Thyst,
00044         LM75B_Tos
00045     };
00046 
00047     /** I2Cピンとスレーブアドレスを指定し,インスタンスを作成します
00048      *
00049      * @param i2c_sda I2C-bus i2c_sdaピン
00050      * @param i2c_scl I2C-bus i2c_sclピン
00051      * @param address (オプション) I2C-bus スレーブアドレス (デフォルト: 0x90)
00052      */
00053     I2CTempSensor( PinName i2c_sda, PinName i2c_scl, char address );
00054 
00055     /** I2Cオブジェクトとスレーブアドレスを指定し,インスタンスを作成します
00056      *
00057      * @param i2c_obj I2C オブジェクト (インスタンス)
00058      * @param address (オプション) I2C-bus スレーブアドレス (デフォルト: 0x90)
00059      */
00060     I2CTempSensor( I2C &i2c_obj, char address );
00061 
00062     /** デストラクタ
00063      */
00064     ~I2CTempSensor();
00065 
00066     /** 初期化
00067      */
00068     void    init( void );
00069 
00070     /** 温度の読み出し
00071      *
00072      *  @return 摂氏温度を返します(float型)
00073      */
00074     short   read16( void );
00075 
00076 private:
00077     I2C     *i2c_p;
00078     I2C     &i2c;
00079     char    adr;
00080 };
00081 
00082 #endif  //  MBED_I2CTempSensor_H
00083