Hello,
i need a very sample code for ,open a SPI device ad send , receive a byte.
In particular how open the device tree spi device,
how write a byte
how read a byte.
Best Regards.
Fausto
Hello,
i need a very sample code for ,open a SPI device ad send , receive a byte.
In particular how open the device tree spi device,
how write a byte
how read a byte.
Best Regards.
Fausto
Hello,
There are many ways this can be done:
1. Use the zephyr spi driver, then see this example for reference (made for the nRF5340, but should be portable for the nRF52-series):
https://devzone.nordicsemi.com/f/nordic-q-a/67065/how-to-configure-and-setup-an-spi-device-to-nrf5340/275002#275002
If you are using nRF52-series it should be a bit simpler than nRF53 in terms of configuration, since you don't have to consider that there are two cores like on the nRF5340 (network and app core, e.g. remove CONFIG_BOARD_ENABLE_CPUNET from prj.conf).
2. Use the nrfx spi driver directly, then see this example for reference (made for nRF52-DK):
https://devzone.nordicsemi.com/f/nordic-q-a/66488/using-spi-with-ppi-in-zephyr/272139#272139
3. Setup spi from scratch, then see this example this example for reference (the example show i2c, so you need to change to spi):
https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/peripherals/posts/twi-ic2-implementation-with-nrfx-twis-driver
Best regards,
Kenneth