Projet_BMC
/
MAX3010x_RD117_MBED_
MAXREFDES#117
Diff: MAX30102/MAX30102.cpp
- Revision:
- 5:e7b8e61b1fe1
- Parent:
- 4:5273ab1085ab
--- a/MAX30102/MAX30102.cpp Thu May 19 22:04:06 2016 +0000 +++ b/MAX30102/MAX30102.cpp Mon Jan 27 11:27:41 2020 +0000 @@ -1,3 +1,6 @@ + + + /** \file max30102.cpp ****************************************************** * * Project: MAXREFDES117# @@ -58,13 +61,13 @@ */ #include "mbed.h" #include "MAX30102.h" - + #ifdef TARGET_MAX32600MBED I2C i2c(I2C1_SDA, I2C1_SCL); #else I2C i2c(I2C_SDA, I2C_SCL); #endif - + bool maxim_max30102_write_reg(uint8_t uch_addr, uint8_t uch_data) /** * \brief Write a value to a MAX30102 register @@ -86,7 +89,7 @@ else return false; } - + bool maxim_max30102_read_reg(uint8_t uch_addr, uint8_t *puch_data) /** * \brief Read a MAX30102 register @@ -111,7 +114,7 @@ else return false; } - + bool maxim_max30102_init() /** * \brief Initialize the MAX30102 @@ -148,7 +151,7 @@ return false; return true; } - + 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 @@ -201,7 +204,7 @@ return true; } - + bool maxim_max30102_reset() /** * \brief Reset the MAX30102 @@ -218,3 +221,46 @@ else return true; } + + + + + + + + + + + + + + + + + + + + + +uint8_t MAX30102_begin(uint8_t reg) +{ + char data; + char temp[1] = {reg}; + i2c.write(I2C_WRITE_ADDR, temp , 1); + temp[1] = 0x00; + i2c.write(I2C_WRITE_ADDR, temp, 1); + int a = i2c.read(I2C_WRITE_ADDR, &data, 1); + return data; + +} + +int MAX30102_writeRegValue(uint8_t reg, char value) +{ + char cmdData[2] = { (char)reg, value }; + + if (i2c.write(I2C_WRITE_ADDR, cmdData, sizeof(cmdData)) != 0) { + return MAX30102_ERROR; + } + + return MAX30102_NO_ERROR; +} \ No newline at end of file