I've got a little further with this as follows:
I started with one of the Bela examples that uses I2c communication:
https://github.com/BelaPlatform/Bela/tree/master/examples/Sensors/MPR121
And have been modifying the Adafruit Arduino code from here;
https://github.com/adafruit/Adafruit_APDS9960
My code so far is here: https://github.com/coldesstu/Bela_Adafruit_9960/tree/main
Please ignore the fact that I've not renamed all the functions to something more relevant like APDS9960, for now I've just been trying to get it to work!
So far I believe I have managed to establish communication with the 9960 as this:
std::cout << "checking connection\n";
uint8_t c = readRegister8(APDS9960_ID);
if (c != 0xAB) {
rt_printf("MPR121 read 0x%x instead of 0xAB\n", c);
return false;
} else {
std::cout << static_cast<int>(c)<< "\n";
}
Outputs as follows:
command sent to device 146 - (92 in hex)
171 (AB in hex)
I'm not sure if the write register code is working, although it doesn't return an error:
Outputs as follows:
command sent to device 146 - (92 in hex)
171 (AB in hex)
I'm not sure if the write register code is working, although it doesn't return an error:
And when I run the auxiliary task in the Bela program, I just get 0 returned for the proximity reading.
One major difference from the Arduino code seems to be the interrupt pin, do I need to have this in order to read the proximity values? The only thing I seem to be able to read from the device is it's ID...
Any help or tips much appreciated!