Hi, i have the SparkFun Pulse Oximeter and Heart Rate Sensor - MAX30101 & MAX32664 that i want to interface it with the SparkFun nRF52832 Breakout (using the nRF52 SDK). I am working on the library for Arduino created by your team and i found it really helpful. I have some questions about this library. Would you have suggestions or example on how i can modify the functions used to Read and Write the bytes on the SparkFun_Bio_Sensor_Hub_Library? I need to use a “C” source code and so i decomposed the object, setting “free” functions. Do you have any example of the source code in #C or tips about this conversion?
Thanks to all,
Polimarte
What read/write functions are you referring to? There are functions for the MAX30101 and separate functions for MAX32664.
Hi,
I would like to convert the read byte function:
uint8_t readByte(uint8_t _familyByte, uint8_t _indexByte,\
uint8_t _writeByte)
{
uint8_t returnByte;
uint8_t statusByte;
_i2cPort->beginTransmission(_address);
_i2cPort->write(_familyByte);
_i2cPort->write(_indexByte);
_i2cPort->write(_writeByte);
_i2cPort->endTransmission();
delay(CMD_DELAY);
_i2cPort->requestFrom(_address, sizeof(returnByte) + sizeof(statusByte));
statusByte = _i2cPort->read();
if (statusByte)// SUCCESS (0x00)
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
returnByte = _i2cPort->read();
return returnByte; // If good then return the actual byte.
}
in something like this:
uint32_t nrf_drv_read_registers(uint8_t reg, uint8_t* p_data, uint32_t length)
{
uint32_t err_code;
uint32_t timeout = OXI_TWI_TIMEOUT;
err_code = nrf_drv_twi_tx(&m_twi_instance, OXI_ADDRESS, ®, 1, false);
if (err_code != NRF_SUCCESS) return err_code;
while ((!twi_tx_done) && --timeout) ;
if (!timeout) return NRF_ERROR_TIMEOUT;
twi_tx_done = false;
err_code = nrf_drv_twi_rx(&m_twi_instance, OXI_ADDRESS, p_data, length);
if (err_code != NRF_SUCCESS) return err_code;
timeout = OXI_TWI_TIMEOUT;
while ((!twi_rx_done) && --timeout) ;
if (!timeout) return NRF_ERROR_TIMEOUT;
twi_rx_done = false;
return err_code;
}
In this function i am using the TWI drivers function for the nRF52832. I undersand that this is a very specific but my question is more basic.
I don’t understand the use of the family, index and write byte to get a register.
thanks,
polimarte
Hello @polimarte,
I suggest you read page 15 and 16 to get a handle on the I2C transaction process with the MAX32664 here:
https://github.com/sparkfun/SparkFun_Bi … minary.pdf
The library is written to communicate with the MAX32664 which is actually a small ARM Cortex-M4F microcontroller. With that in mind you’re not reading/writing a small amount of registers as in smaller dedicated ICs but rather a microcontroller with much more memory. As specified in the datasheet, the family byte categorizes a subset of registers - the index bytes, and sometimes each index byte has a subset of bytes that are reached with the write byte. Each index byte is different of course and are described in detail in the datasheet. Another thing to watch out for: the MAX32664 on the pulse oximeter is “version A” meaning that it’s specifically tailored to calculate data from the MAX30101 and MAX30102 pulse Oximeter (we actually sell it in its own breakout board here: https://www.sparkfun.com/products/16474). When you’re looking through the datasheet linked above, make sure you’re looking at family bytes for that version. At the same time the library has enabled all of the possible family bytes listed in the datasheet, so you can probably just reference the library alone. There’s a lot going on with this one, so if you have any more questions please leave them here.
Hello polimarte,
Currently I am trying to convert the arduino library into software conpatible with the nrf52 sdk. Were you able to achieve your goal with this? If so, I would really appreciate your help.
Thank you