I2C 接続の温度センサ ADT7410 用のライブラリ. Library for temperature sensor ADT7410 connected using I2C interface.

Dependents:   Mbed2_ConnectTestAll Demo_ADT7410

Revision:
0:b6dc7c54b451
Child:
1:ad3046485a3e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADT7410.hpp	Mon Jun 15 05:43:19 2015 +0000
@@ -0,0 +1,50 @@
+//--------------------------------------------------------------
+//  Class for using ADT7410 (Header)
+//  2015/06/10, Copyright (c) 2015 MIKAMI, Naoki
+//--------------------------------------------------------------
+
+#ifndef ADT7410_HPP
+#define ADT7410_HPP
+
+#include "mbed.h"
+
+namespace Mikami
+{
+    class ADT7410
+    {
+    public:
+        // Constructor
+        ADT7410(PinName sda = D14,      // SDA
+                PinName scl = D15,      // SCL
+                uint8_t addr = 0x90);   // I2C bus address
+                
+        // Set configuration register
+        void SetConfig(char val);
+    
+        // Get value in configuration register
+        uint8_t GetConfig();
+
+        // Get temperature
+        float Get();
+
+    protected:
+        // Write single byte
+        // "STOP" を送らずにふたたび "START" を送る,つまりリスタート・コンディションに
+        // する場合は,"repeated" を "true" にする
+        void WriteSingleByte(char reg, bool repeated = false)
+        { i2c_.write(addr_, &reg, 1, repeated); };
+    
+    private:
+        // Register addresses
+        static const uint8_t TEMPER_ = 0x00;   // Temperature value MSByte
+        static const uint8_t CONFIG_ = 0x03;   // Configuration
+        static const uint8_t RESET_  = 0x2F;   // Software reset
+        
+        const uint8_t addr_;    // left-justified 7-bit slave address of ADT7410
+        I2C i2c_;               // Object of I2C
+
+        // Reset
+        void Reset();
+    };
+}
+#endif  // ADT7410_HPP
\ No newline at end of file