|
Information
说明: |
建议参照本版块置顶帖内容输入必要信息 |
芯片型号: |
TLSR8251 |
驱动SDK版本: |
tc_ble_single_sdk-V3.4.2.7 |
集成HX3602,通过IIC实现。
原始代码中如下:
bool Hrs3602_write_reg(uint8_t addr, uint8_t data)
{
#ifdef TYHX_DEMO
uint8_t data_buf[2];
data_buf[0] = addr;
data_buf[1] = data;
twi_pin_switch(1);
twi_master_transfer(0x88, data_buf, 2, true); //write
#endif
return 0;
}
uint8_t Hrs3602_read_reg(uint8_t addr)
{
uint8_t data_buf = 0;
#ifdef TYHX_DEMO
twi_pin_switch(1);
twi_master_transfer(0x88, &addr, 1, false); //write
twi_master_transfer(0x89, &data_buf, 1, true);//read
#endif
return data_buf;
}
bool Hrs3602_brust_read_reg(uint8_t addr , uint8_t *buf, uint8_t length)
{
#ifdef TYHX_DEMO
twi_pin_switch(1);
twi_master_transfer(0x88, &addr, 1, false); //write
twi_master_transfer(0x89, buf, length, true); //read
#endif
return true;
}
需要配合主控MCU修改,如何实现?
|
|