Implement NRF cambus scan and gencall.
@@ -86,11 +86,24 @@ int cambus_deinit(cambus_t *bus)
int cambus_scan(cambus_t *bus)
{
+ uint8_t data;
+ uint32_t xfer_flags = 0;
+ for (uint8_t addr=0x09; addr<=0x77; addr++) {
+ nrfx_twi_xfer_desc_t desc = NRFX_TWI_XFER_DESC_RX(addr, &data, 1);
+ if (nrfx_twi_xfer(&bus->i2c, &desc, xfer_flags) == NRFX_SUCCESS) {
+ return (addr << 1);
+ }
+ }
return 0;
}
int cambus_gencall(cambus_t *bus, uint8_t cmd)
{
+ uint32_t xfer_flags = 0;
+ nrfx_twi_xfer_desc_t desc = NRFX_TWI_XFER_DESC_TX(0x00, &cmd, 1);
+ if (nrfx_twi_xfer(&bus->i2c, &desc, xfer_flags) != NRFX_SUCCESS) {
+ return -1;
+ }
return 0;
}
