hi,...... i am merging the nRF52832 and heart rate sensor BH1790, SEGGER 15.2V i want to read the heart rate sensor , for that i want to write the paramater of address, 41h 42h ... how to write , which function i have to use......
hi,...... i am merging the nRF52832 and heart rate sensor BH1790, SEGGER 15.2V i want to read the heart rate sensor , for that i want to write the paramater of address, 41h 42h ... how to write , which function i have to use......
write the paramater of address, 41h 42h
I don't understand what you mean by that - please clarify
Hi, I just have merged the nRF52832 and heart rate sensor BH1792GLC.
https://github.com/takurx/BH1792GLC-nRF52832-Example
It's better use example of twi-sensor.
You want to set_data_to/get_data_from register(41h, 42h, ...) of slave address.
It can solve nRF SDK's function of nrf_drv_twi_tx/nrf_drv_twi_rx.
One point,
TWI write only use nrf_drv_twi_tx,
But TWI read need to use both nrf_drv_twi_tx and nrf_drv_twi_rx. Thanks.
// Note: I2C access should be completed within 0.5ms
int32_t i2c_write(uint8_t slv_adr, uint8_t reg_adr, uint8_t *reg, uint8_t reg_size)
{
ret_code_t err_code;
/*
// m_bh1792.prm.msr = BH1792_PRM_MSR_SINGLE, none
if (m_bh1792.prm.msr <= BH1792_PRM_MSR_1024HZ) {
if((slv_adr != BH1792_SLAVE_ADDR) || (reg_adr != BH1792_ADDR_MEAS_SYNC)) {
while(FlexiTimer2::count == 1999);
}
}
*/
uint32_t timeout = BH1792_TWI_TIMEOUT;
twi_tx_buffer[0] = reg_adr;
memcpy(&twi_tx_buffer[1], ®[0], reg_size);
err_code = nrf_drv_twi_tx(&m_twi, slv_adr, &twi_tx_buffer[0], reg_size + 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;
//return rc; //rc is return value that arduino, Wire endTransmission, rc:0 is normal
return 0;
}
// Note: I2C access should be completed within 0.5ms
int32_t i2c_read(uint8_t slv_adr, uint8_t reg_adr, uint8_t *reg, uint8_t reg_size)
{
ret_code_t err_code;
/*
// m_bh1792.prm.msr = BH1792_PRM_MSR_SINGLE, none
if (m_bh1792.prm.msr <= BH1792_PRM_MSR_1024HZ) {
while(FlexiTimer2::count == 1999);
}
*/
uint32_t timeout = BH1792_TWI_TIMEOUT;
err_code = nrf_drv_twi_tx(&m_twi, slv_adr, ®_adr, 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, slv_adr, reg, reg_size);
if(err_code != NRF_SUCCESS) return err_code;
timeout = BH1792_TWI_TIMEOUT;
while((!twi_rx_done) && --timeout);
if(!timeout) return NRF_ERROR_TIMEOUT;
twi_rx_done = false;
//return rc; //rc:0 is normal, rc:4 is error. but in nrf5 when case of error, already return
return 0;
}
I also will try BH1790GLC. It have to exist heart rate(BPM, Upper one is only measured raw data) example.
BH1790GLC_HeartRate.zip - http://micro.rohm.com/en/download_support/sensor_module/kiyaku.php?file=data/software/BH1790GLC_HeartRate.zip