Hello
I am developing peripheral interfaces on nrf9160 dk, For I2C, sPI and ADC I am not able find exapmle codes. ALso could not find api required for the same to develop the code
Hello
I am developing peripheral interfaces on nrf9160 dk, For I2C, sPI and ADC I am not able find exapmle codes. ALso could not find api required for the same to develop the code
Hi,
For ADC, I2C, and SPI you have two alternatives:
* Use Zephyr API (which uses nrfx in the deep)
* Use nrfx driver API
Zephyr API:
* ADC sample : https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/adc - Change this to CONFIG_BOARD_NRF9160_PCA10090NS if using non-secure region.
* SPI sample available here. This is a bit old (device tree properties has changed since the sample was created), so the overlay files needs to be trimmed down - let me know if you need help here.
* I2C samples can be found on different threads on devzone, for instance this one: https://devzone.nordicsemi.com/f/nordic-q-a/44939/how-to-implement-i2c-on-nrf9160
nrfx API:
Each nrfx component has a dedicated config option, CONFIG_NRFX_$(COMPONENT), for instance CONFIG_NRFX_SPIM and CONFIG_NRFX_TWIM. Once enabled, include the respective header into your application and use the API directly. You can have a look at samples in nRF5 SDK for examples on using nrfx API, and port these to zephyr.
One special note when using bus peripherals:
Most of these are shared peripherals. This means that you cannot have SPIM0 and TWIM0 enabled simultaneously. You need to use for instance SPIM1, TWIM2, and UARTE0.
See the list here: https://infocenter.nordicsemi.com/topic/ps_nrf9160/memory.html?cp=2_0_0_3_1_1#topic
If devices share the same address offset, then they are shared and shall not be used simultaneously.
Kind regards,
Håkon