Fork of Maxim's human body temp sensor library that works with mbed-os 5
Fork of MAX30205 by
Revision 9:2b8357c91343, committed 2017-10-18
- Comitter:
- seppestas
- Date:
- Wed Oct 18 15:51:47 2017 +0000
- Parent:
- 8:2aeb45dd2bb9
- Commit message:
- Use single, 8-bit address to work with mbed I2C; ; Mbed uses 8-bit addresses, see https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/interfaces/digital/I2C/#api
Changed in this revision
MAX30205.cpp | Show annotated file Show diff for this revision Revisions of this file |
MAX30205.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2aeb45dd2bb9 -r 2b8357c91343 MAX30205.cpp --- a/MAX30205.cpp Thu Jul 27 22:49:16 2017 +0000 +++ b/MAX30205.cpp Wed Oct 18 15:51:47 2017 +0000 @@ -37,8 +37,7 @@ //****************************************************************************** MAX30205::MAX30205(I2C &i2c, uint8_t slaveAddress): -m_i2c(i2c), m_writeAddress(slaveAddress << 1), -m_readAddress((slaveAddress << 1) | 1) +m_i2c(i2c), m_address(slaveAddress) { } @@ -141,7 +140,7 @@ uint8_t lo = (value & 0xFF); char cmdData[3] = {reg, hi, lo}; - result = m_i2c.write(m_writeAddress, cmdData, 3); + result = m_i2c.write(m_address, cmdData, 3); return result; } @@ -155,10 +154,10 @@ char data[2]; char cmdData[1] = {reg}; - result = m_i2c.write(m_writeAddress, cmdData, 1); + result = m_i2c.write(m_address, cmdData, 1); if(result == 0) { - result = m_i2c.read(m_readAddress, data, 2); + result = m_i2c.read(m_address, data, 2); if (result == 0) { value = (data[0] << 8) + data[1];
diff -r 2aeb45dd2bb9 -r 2b8357c91343 MAX30205.h --- a/MAX30205.h Thu Jul 27 22:49:16 2017 +0000 +++ b/MAX30205.h Wed Oct 18 15:51:47 2017 +0000 @@ -188,7 +188,7 @@ /// I2C object I2C & m_i2c; /// Device slave addresses - uint8_t m_writeAddress, m_readAddress; + uint8_t m_address; }; #endif /* __MAX30205_H_ */