mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Implement NRF cambus scan and gencall.
This commit is contained in:
parent
b0cfa3abb1
commit
25ec7349f5
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user