Converting Arduino Library for STM32
Posted: Wed Apr 05, 2023 11:48 am
Hello everyone,
I'm having some trouble converting the DFRobot SEN0344 sensor library for STM32. The sensor uses the MAX30102 integrated sensor and DFRobot has provided a library specifically for this sensor. However, this library only works on the Arduino platform and I'm having trouble converting it to STM32.
Specifically, I'm stuck on the writereg() function, which is responsible for writing data to the sensor's registers. The function looks like this:
void DFRobot_BloodOxygen_S_I2C::writeReg(uint16_t reg_addr, uint8_t *data_buf, uint8_t len)
{
_pWire->beginTransmission(this->_I2C_addr);
_pWire->write(reg_addr);
for (uint8_t i = 0; i < len; i++)
{
_pWire->write(data_buf);
}
_pWire->endTransmission();
}
I've tried using all the correct registers and I2C addresses, but I'm still struggling with writing this code for STM32. If anyone could provide any help or guidance, I would be very grateful.
For context, I'm using the STM32L152RE microcontroller. Thank you in advance for any assistance!
Link of DFRobot SEN0344: https://wiki.dfrobot.com/Heart_Rate_and ... KU_SEN0344
Link of Libary Github: https://github.com/DFRobot/DFRobot_BloodOxygen_S
I'm having some trouble converting the DFRobot SEN0344 sensor library for STM32. The sensor uses the MAX30102 integrated sensor and DFRobot has provided a library specifically for this sensor. However, this library only works on the Arduino platform and I'm having trouble converting it to STM32.
Specifically, I'm stuck on the writereg() function, which is responsible for writing data to the sensor's registers. The function looks like this:
void DFRobot_BloodOxygen_S_I2C::writeReg(uint16_t reg_addr, uint8_t *data_buf, uint8_t len)
{
_pWire->beginTransmission(this->_I2C_addr);
_pWire->write(reg_addr);
for (uint8_t i = 0; i < len; i++)
{
_pWire->write(data_buf);
}
_pWire->endTransmission();
}
I've tried using all the correct registers and I2C addresses, but I'm still struggling with writing this code for STM32. If anyone could provide any help or guidance, I would be very grateful.
For context, I'm using the STM32L152RE microcontroller. Thank you in advance for any assistance!
Link of DFRobot SEN0344: https://wiki.dfrobot.com/Heart_Rate_and ... KU_SEN0344
Link of Libary Github: https://github.com/DFRobot/DFRobot_BloodOxygen_S