Alexandru Radu
/
RD117_LCD_copy
gg
Fork of RD117_MBED by
Diff: MAX30102/MAX30102.cpp
- Revision:
- 3:7c0fb55eb3ff
- Parent:
- 0:346a7fa07998
- Child:
- 4:5273ab1085ab
--- a/MAX30102/MAX30102.cpp Thu Apr 21 18:25:34 2016 +0000 +++ b/MAX30102/MAX30102.cpp Thu Apr 21 19:38:17 2016 +0000 @@ -80,24 +80,24 @@ * \retval true on success */ { - char ch_i2c_data[2]; - ch_i2c_data[0]=uch_addr; - ch_i2c_data[1]=uch_data; + char ach_i2c_data[2]; + ach_i2c_data[0]=uch_addr; + ach_i2c_data[1]=uch_data; - if(i2c.write(I2C_WRITE_ADDR, ch_i2c_data, 2, false)==0) + if(i2c.write(I2C_WRITE_ADDR, ach_i2c_data, 2, false)==0) return true; else return false; } -bool maxim_max30102_read_reg(uint8_t uch_addr, uint8_t *uch_data) +bool maxim_max30102_read_reg(uint8_t uch_addr, uint8_t *puch_data) /** * \brief Read a MAX30102 register * \par Details * This function reads a MAX30102 register * * \param[in] uch_addr - register address -* \param[out] uch_data - pointer that stores the register data +* \param[out] puch_data - pointer that stores the register data * * \retval true on success */ @@ -108,7 +108,7 @@ return false; if(i2c.read(I2C_READ_ADDR, &ch_i2c_data, 1, false)==0) { - *uch_data=(uint8_t) ch_i2c_data; + *puch_data=(uint8_t) ch_i2c_data; return true; } else @@ -152,54 +152,54 @@ return true; } -bool maxim_max30102_read_fifo(uint32_t *un_red_led, uint32_t *un_ir_led) +bool maxim_max30102_read_fifo(uint32_t *pun_red_led, uint32_t *pun_ir_led) /** * \brief Read a set of samples from the MAX30102 FIFO register * \par Details * This function reads a set of samples from the MAX30102 FIFO register * -* \param[out] *un_red_led - pointer that stores the red LED reading data -* \param[out] *un_ir_led - pointer that stores the IR LED reading data +* \param[out] *pun_red_led - pointer that stores the red LED reading data +* \param[out] *pun_ir_led - pointer that stores the IR LED reading data * * \retval true on success */ { uint32_t un_temp; unsigned char uch_temp; - *un_red_led=0; - *un_ir_led=0; - char ch_i2c_data[6]; + *pun_red_led=0; + *pun_ir_led=0; + char ach_i2c_data[6]; //read and clear status register maxim_max30102_read_reg(REG_INTR_STATUS_1, &uch_temp); maxim_max30102_read_reg(REG_INTR_STATUS_2, &uch_temp); - ch_i2c_data[0]=REG_FIFO_DATA; - if(i2c.write(I2C_WRITE_ADDR, ch_i2c_data, 1, true)!=0) + ach_i2c_data[0]=REG_FIFO_DATA; + if(i2c.write(I2C_WRITE_ADDR, ach_i2c_data, 1, true)!=0) return false; - if(i2c.read(I2C_READ_ADDR, ch_i2c_data, 6, false)!=0) + if(i2c.read(I2C_READ_ADDR, ach_i2c_data, 6, false)!=0) { return false; } - un_temp=(unsigned char) ch_i2c_data[0]; + un_temp=(unsigned char) ach_i2c_data[0]; un_temp<<=16; - *un_red_led+=un_temp; - un_temp=(unsigned char) ch_i2c_data[1]; + *pun_red_led+=un_temp; + un_temp=(unsigned char) ach_i2c_data[1]; un_temp<<=8; - *un_red_led+=un_temp; - un_temp=(unsigned char) ch_i2c_data[2]; - *un_red_led+=un_temp; + *pun_red_led+=un_temp; + un_temp=(unsigned char) ach_i2c_data[2]; + *pun_red_led+=un_temp; - un_temp=(unsigned char) ch_i2c_data[3]; + un_temp=(unsigned char) ach_i2c_data[3]; un_temp<<=16; - *un_ir_led+=un_temp; - un_temp=(unsigned char) ch_i2c_data[4]; + *pun_ir_led+=un_temp; + un_temp=(unsigned char) ach_i2c_data[4]; un_temp<<=8; - *un_ir_led+=un_temp; - un_temp=(unsigned char) ch_i2c_data[5]; - *un_ir_led+=un_temp; - *un_red_led&=0x03FFFF; //Mask MSB [23:18] - *un_ir_led&=0x03FFFF; //Mask MSB [23:18] + *pun_ir_led+=un_temp; + un_temp=(unsigned char) ach_i2c_data[5]; + *pun_ir_led+=un_temp; + *pun_red_led&=0x03FFFF; //Mask MSB [23:18] + *pun_ir_led&=0x03FFFF; //Mask MSB [23:18] return true;