心拍・酸素飽和度モニタモジュール MAXREFDES117から取得した心拍の値でmicro:bit上のLEDに表示したハートを鼓動させるプログラムです。
Fork of microbit-Heartbeat-serial by
MAX30102.h
00001 #ifndef MAX30102_H_ 00002 #define MAX30102_H_ 00003 00004 #include "mbed.h" 00005 00006 class MAX30102 00007 { 00008 public: 00009 MAX30102(PinName sda, PinName scl) : _i2c(sda, scl) { 00010 00011 } 00012 bool init(); 00013 bool read_fifo(uint32_t *pun_red_led, uint32_t *pun_ir_led); 00014 bool reset(); 00015 00016 private: 00017 static const uint8_t I2C_ADDR = 0xAE; 00018 00019 static const uint8_t REG_INTR_STATUS_1 = 0x00; 00020 static const uint8_t REG_INTR_STATUS_2 = 0x01; 00021 static const uint8_t REG_INTR_ENABLE_1 = 0x02; 00022 static const uint8_t REG_INTR_ENABLE_2 = 0x03; 00023 static const uint8_t REG_FIFO_WR_PTR = 0x04; 00024 static const uint8_t REG_OVF_COUNTER = 0x05; 00025 static const uint8_t REG_FIFO_RD_PTR = 0x06; 00026 static const uint8_t REG_FIFO_DATA = 0x07; 00027 static const uint8_t REG_FIFO_CONFIG = 0x08; 00028 static const uint8_t REG_MODE_CONFIG = 0x09; 00029 static const uint8_t REG_SPO2_CONFIG = 0x0A; 00030 static const uint8_t REG_LED1_PA = 0x0C; 00031 static const uint8_t REG_LED2_PA = 0x0D; 00032 static const uint8_t REG_PILOT_PA = 0x10; 00033 static const uint8_t REG_MULTI_LED_CTRL1 = 0x11; 00034 static const uint8_t REG_MULTI_LED_CTRL2 = 0x12; 00035 static const uint8_t REG_TEMP_INTR = 0x1F; 00036 static const uint8_t REG_TEMP_FRAC = 0x20; 00037 static const uint8_t REG_TEMP_CONFIG = 0x21; 00038 static const uint8_t REG_PROX_INT_THRESH = 0x30; 00039 static const uint8_t REG_REV_ID = 0xFE; 00040 static const uint8_t REG_PART_ID = 0xFF; 00041 00042 I2C _i2c; 00043 00044 bool write_reg(uint8_t uch_addr, uint8_t uch_data); 00045 bool read_reg(uint8_t uch_addr, uint8_t *puch_data); 00046 00047 }; 00048 00049 #endif /* MAX30102_H_ */
Generated on Fri Jul 15 2022 02:06:55 by 1.7.2