BME280にアクセスするためのライブラリ

Revision:
3:df1107ddf502
Parent:
2:42725d11023b
Child:
4:4c4e3ec9a2c4
--- a/BME280_reg.h	Tue Jul 10 07:59:58 2018 +0000
+++ b/BME280_reg.h	Tue Jul 10 08:57:26 2018 +0000
@@ -1,101 +1,101 @@
 #ifndef BME280_REG_H
-#define BMP280_BME280_REG_H
+#define BME280_BME280_REG_H
+
+//コンストラクタに入れる定数の定義終わり
+
+    //測定動作モード
+    #define BME280_SLEEP_MODE         0x00
+    #define BME280_FORCE_MODE         0x02
+    #define BME280_NORMAL_MODE        0x03
+
+    //気圧のオーバーサンプリング制御
+    #define BME280_PRESS_SKIP         0x00
+    #define BME280_PRESS_OVER_SAMPL1  (0x01<<2)
+    #define BME280_PRESS_OVER_SAMPL2  (0x02<<2)
+    #define BME280_PRESS_OVER_SAMPL4  (0x03<<2)
+    #define BME280_PRESS_OVER_SAMPL8  (0x04<<2)
+    #define BME280_PRESS_OVER_SAMPL16 (0x05<<2)
+
+    //温度のオーバーサンプリング制御
+    #define BME280_TEMP_SKIP          0x00
+    #define BME280_TEMP_OVER_SAMPL1   (0x01<<5)
+    #define BME280_TEMP_OVER_SAMPL2   (0x02<<5)
+    #define BME280_TEMP_OVER_SAMPL4   (0x03<<5)
+    #define BME280_TEMP_OVER_SAMPL8   (0x04<<5)
+    #define BME280_TEMP_OVER_SAMPL16  (0x05<<5)
 
+    //湿度のオーバーサンプリング制御
+    #define BME280_HUM_SKIP           0x00
+    #define BME280_HUM_OVER_SAMPL1    0x01
+    #define BME280_HUM_OVER_SAMPL2    0x02
+    #define BME280_HUM_OVER_SAMPL4    0x03
+    #define BME280_HUM_OVER_SAMPL8    0x04
+    #define BME280_HUM_OVER_SAMPL16   0x05
+
+    //IIRフィルタの時定数設定
+    #define BME280_IIR_OFF            0x00
+    #define BME280_IIR_2              (0x01<<2)
+    #define BME280_IIR_4              (0x02<<2)
+    #define BME280_IIR_8              (0x03<<2)
+    #define BME280_IIR_16             (0x04<<2)
+
+    //測定後休止時間設定(ノーマルモードのみ有効)
+    #define BME280_NORMAL_STANBY_0_5  0x00
+    #define BME280_NORMAL_STANBY_62_5 (0x01<<5)
+    #define BME280_NORMAL_STANBY_125  (0x02<<5)
+    #define BME280_BME280_NORMAL_STANBY_250  (0x03<<5)
+    #define BME280_NORMAL_STANBY_500  (0x04<<5)
+    #define BME280_NORMAL_STANBY_1000 (0x05<<5)
+    #define BME280_NORMAL_STANBY_10   (0x06<<5)
+    #define BME280_NORMAL_STANBY_20   (0x07<<5)
+
+//コンストラクタに入れる定数の定義終わり
+
+
+//デバイスアドレス8bit
     #define BME280_add  0x76<<1
+
+//レジスタアドレス
+
+    //データ読み込みレジスタ
     /*           
-    #define BMP280_HUM_LSB     0xFE
-    #define BMP280_HUM_MSB     0xFD
-    #define BMP280_TEMP_XLSB   0xFC
-    #define BMP280_TEMP_LSB    0xFB
-    #define BMP280_TEMP_MSB    0xFA
-    #define BMP280_PRESS_XLSB  0xF9
-    #define BMP280_PRESS_LSB   0xF8
+    #define BME280_HUM_LSB     0xFE
+    #define BME280_HUM_MSB     0xFD
+    #define BME280_TEMP_XLSB   0xFC
+    #define BME280_TEMP_LSB    0xFB
+    #define BME280_TEMP_MSB    0xFA
+    #define BME280_PRESS_XLSB  0xF9
+    #define BME280_PRESS_LSB   0xF8
     */
-    #define BMP280_PRESS_MSB   0xF7
-    #define BMP280_CONFIG      0xF5
-    #define BMP280_CTRL_MEAS   0xF4
-    #define BMP280_STATUS      0xF3
-    #define BMP280_CTRL_HUM    0xF2
-    #define BMP280_RESET_REG   0xE0
-    #define BMP280_ID          0xD0
-    
-    #define BMP280_CALIB00     0x88
-    #define BMP280_CALIB25     0xA1
-    #define BMP280_CALIB26     0xE1               
+    #define BME280_PRESS_MSB   0xF7
+
+    //設定系レジスタ
+    #define BME280_CONFIG      0xF5
+    #define BME280_CTRL_MEAS   0xF4
+    #define BME280_STATUS      0xF3
+    #define BME280_CTRL_HUM    0xF2
+    #define BME280_RESET_REG   0xE0
+    #define BME280_ID          0xD0
+
+    //補正係数格納レジスタ(読み込みのみ)
+    #define BME280_CALIB00     0x88
+    #define BME280_CALIB25     0xA1
+    #define BME280_CALIB26     0xE1               
 
 
 //ID
-    //IDの規定値
-    #define BMP280_ID_VALUE    0b01100000
+    //IDの規定値(BME280_IDを読むといつもこの値,ハードウエアの接続確認用)
+    #define BME280_ID_VALUE    0b01100000
 
 //RESET
-    //リセットをかけるための値
-    #define BMP280_RESET_VALUE 0xB6
-
-//CTRL_HUM
-    //湿度のオーバーサンプリング制御
-    #define BMP280_HUM_SKIP           0x00
-    #define BMP280_HUM_OVER_SAMPL1    0x01
-    #define BMP280_HUM_OVER_SAMPL2    0x02
-    #define BMP280_HUM_OVER_SAMPL4    0x03
-    #define BMP280_HUM_OVER_SAMPL8    0x04
-    #define BMP280_HUM_OVER_SAMPL16   0x05
-
-//STATUS
-    //測定中の判定式
-    #define BMP280_STATUS_IS_MEASURING (sensor.read_reg(BME280_add,BMP280_STATUS) & 0x08)
-    //コピー中
-    #define BMP280_STATUS_IS_COPYING   (sensor.read_reg(BME280_add,BMP280_STATUS) & 0x01)
-    //なにも起きていないときの判定式(測定待ちなどに使う予定)
-    #define BMP280_STATUS_IS_NOTHING   (sensor.read_reg(BME280_add,BMP280_STATUS) =0x00)
-
-//CTRL_MEAS
-    //温度のオーバーサンプリング制御
-    #define BMP280_TEMP_SKIP          0x00
-    #define BMP280_TEMP_OVER_SAMPL1   (0x01<<5)
-    #define BMP280_TEMP_OVER_SAMPL2   (0x02<<5)
-    #define BMP280_TEMP_OVER_SAMPL4   (0x03<<5)
-    #define BMP280_TEMP_OVER_SAMPL8   (0x04<<5)
-    #define BMP280_TEMP_OVER_SAMPL16  (0x05<<5)
-
-    //気圧のオーバーサンプリング制御
-    #define BMP280_PRESS_SKIP         0x00
-    #define BMP280_PRESS_OVER_SAMPL1  (0x01<<2)
-    #define BMP280_PRESS_OVER_SAMPL2  (0x02<<2)
-    #define BMP280_PRESS_OVER_SAMPL4  (0x03<<2)
-    #define BMP280_PRESS_OVER_SAMPL8  (0x04<<2)
-    #define BMP280_PRESS_OVER_SAMPL16 (0x05<<2)
-
-    //モード選択
-    #define BMP280_SLEEP_MODE         0x00
-    #define BMP280_FORCE_MODE         0x02
-    #define BMP280_NORMAL_MODE        0x03
+    //リセットをかけるための値(BME280_RESET_REGに書き込むとリセットがかかる)
+    #define BME280_RESET_VALUE 0xB6
 
 
-
-
-//CONFIG
-    //ノーマルモードにおける休止状態の継続時間設定(5.3.4項を参照)
-    #define BMP280_NORMAL_STANBY_0_5  0x00
-    #define BMP280_NORMAL_STANBY_62_5 (0x01<<5)
-    #define BMP280_NORMAL_STANBY_125  (0x02<<5)
-    #define BMP280_BMP280_NORMAL_STANBY_250  (0x03<<5)
-    #define BMP280_NORMAL_STANBY_500  (0x04<<5)
-    #define BMP280_NORMAL_STANBY_1000 (0x05<<5)
-    #define BMP280_NORMAL_STANBY_10   (0x06<<5)
-    #define BMP280_NORMAL_STANBY_20   (0x07<<5)
-    
-    //IIRフィルタの時定数設定
-    #define BMP280_IIR_OFF            0x00
-    #define BMP280_IIR_2              (0x01<<2)
-    #define BMP280_IIR_4              (0x02<<2)
-    #define BMP280_IIR_8              (0x03<<2)
-    #define BMP280_IIR_16             (0x04<<2)
-    
-    //SPI線方式選択(4線OR3線) 使わない
-    /*
-    #define BMP280_SPI4               0x00
-    #define BMP280_SPI3               0x01
-*/
+//STATUS判定式
+    //測定中の判定式
+    #define BME280_STATUS_IS_MEASURING (sensor.read_reg(BME280_add,BME280_STATUS) & 0x08)
+    //コピー中
+    #define BME280_STATUS_IS_COPYING   (sensor.read_reg(BME280_add,BME280_STATUS) & 0x01)
 
 #endif
\ No newline at end of file