BME280にアクセスするためのライブラリ
Diff: BME280_reg.h
- Revision:
- 2:42725d11023b
- Parent:
- 0:95f2b96cdc7f
- Child:
- 3:df1107ddf502
--- a/BME280_reg.h Tue Jul 10 07:53:16 2018 +0000 +++ b/BME280_reg.h Tue Jul 10 07:59:58 2018 +0000 @@ -1,101 +1,101 @@ #ifndef BME280_REG_H -#define BME280_REG_H +#define BMP280_BME280_REG_H - const char BME280_add = 0x76<<1; + #define BME280_add 0x76<<1 /* - const char HUM_LSB = 0xFE; - const char HUM_MSB = 0xFD; - const char TEMP_XLSB = 0xFC; - const char TEMP_LSB = 0xFB; - const char TEMP_MSB = 0xFA; - const char PRESS_XLSB = 0xF9; - const char PRESS_LSB = 0xF8; + #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 */ - const char PRESS_MSB = 0xF7; - const char CONFIG = 0xF5; - const char CTRL_MEAS = 0xF4; - const char STATUS = 0xF3; - const char CTRL_HUM = 0xF2; - const char RESET_REG = 0xE0; - const char ID = 0xD0; + #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 - const char CALIB00 = 0x88; - const char CALIB25 = 0xA1; - const char CALIB26 = 0xE1; + #define BMP280_CALIB00 0x88 + #define BMP280_CALIB25 0xA1 + #define BMP280_CALIB26 0xE1 //ID //IDの規定値 - const char ID_VALUE = 0b01100000; + #define BMP280_ID_VALUE 0b01100000 //RESET //リセットをかけるための値 - const char RESET_VALUE = 0xB6; + #define BMP280_RESET_VALUE 0xB6 //CTRL_HUM //湿度のオーバーサンプリング制御 - const char HUM_SKIP = 0x00; - const char HUM_OVER_SAMPL1 = 0x01; - const char HUM_OVER_SAMPL2 = 0x02; - const char HUM_OVER_SAMPL4 = 0x03; - const char HUM_OVER_SAMPL8 = 0x04; - const char HUM_OVER_SAMPL16 = 0x05; + #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 STATUS_IS_MEASURING (sensor.read_reg(BME280_add,STATUS) & 0x08) + #define BMP280_STATUS_IS_MEASURING (sensor.read_reg(BME280_add,BMP280_STATUS) & 0x08) //コピー中 - #define STATUS_IS_COPYING (sensor.read_reg(BME280_add,STATUS) & 0x01) + #define BMP280_STATUS_IS_COPYING (sensor.read_reg(BME280_add,BMP280_STATUS) & 0x01) //なにも起きていないときの判定式(測定待ちなどに使う予定) - #define STATUS_IS_NOTHING (sensor.read_reg(BME280_add,STATUS) == 0x00) + #define BMP280_STATUS_IS_NOTHING (sensor.read_reg(BME280_add,BMP280_STATUS) =0x00) //CTRL_MEAS //温度のオーバーサンプリング制御 - const char TEMP_SKIP = 0x00; - const char TEMP_OVER_SAMPL1 = (0x01<<5); - const char TEMP_OVER_SAMPL2 = (0x02<<5); - const char TEMP_OVER_SAMPL4 = (0x03<<5); - const char TEMP_OVER_SAMPL8 = (0x04<<5); - const char TEMP_OVER_SAMPL16 = (0x05<<5); + #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) //気圧のオーバーサンプリング制御 - const char PRESS_SKIP = 0x00; - const char PRESS_OVER_SAMPL1 = (0x01<<2); - const char PRESS_OVER_SAMPL2 = (0x02<<2); - const char PRESS_OVER_SAMPL4 = (0x03<<2); - const char PRESS_OVER_SAMPL8 = (0x04<<2); - const char PRESS_OVER_SAMPL16 = (0x05<<2); + #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) //モード選択 - const char SLEEP_MODE = 0x00; - const char FORCE_MODE = 0x02; - const char NORMAL_MODE = 0x03; + #define BMP280_SLEEP_MODE 0x00 + #define BMP280_FORCE_MODE 0x02 + #define BMP280_NORMAL_MODE 0x03 //CONFIG //ノーマルモードにおける休止状態の継続時間設定(5.3.4項を参照) - const char NORMAL_STANBY_0_5 = 0x00; - const char NORMAL_STANBY_62_5 = (0x01<<5); - const char NORMAL_STANBY_125 = (0x02<<5); - const char NORMAL_STANBY_250 = (0x03<<5); - const char NORMAL_STANBY_500 = (0x04<<5); - const char NORMAL_STANBY_1000 = (0x05<<5); - const char NORMAL_STANBY_10 = (0x06<<5); - const char NORMAL_STANBY_20 = (0x07<<5); + #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フィルタの時定数設定 - const char IIR_OFF = 0x00; - const char IIR_2 = (0x01<<2); - const char IIR_4 = (0x02<<2); - const char IIR_8 = (0x03<<2); - const char IIR_16 = (0x04<<2); + #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線) 使わない /* - const char SPI4 = 0x00; - const char SPI3 = 0x01; + #define BMP280_SPI4 0x00 + #define BMP280_SPI3 0x01 */ #endif \ No newline at end of file