I am just getting started with the nrf9160DK and need to prototype using that board as an SPI slave to receive data and send via cellular (the stock sample code compiles and runs perfectly). After reviewing multiple articles on the development forum [problems with SPI on nRF9160 and Zephyr] I am still unable to configure an SPI device and have it show with device_get_binding(). I am using Segger on Debian Linux as a development environment. Below are the changes I have made at this time. Can someone point my in the right direction? Since I am new to Zephyr, I will also need some guidance on how to asynchronously receive SPI data in the asset_tracker sample.
1. Start with the base asset_tracker sample
2. Add a file 'nrf9160_pca10090.overlay' with the following contents (changing to spi2, or removing the ss-pin definition does not help):
&spi3 {
status = "ok";
sck-pin = <26>;
mosi-pin = <27>;
miso-pin = <29>;
ss-pin = <28>;
spi-max-frequency = <4000000>;
};
3. Modify the existing prj.conf by adding the following settings:
CONFIG_LOG=Y
CONFIG_SERIAL=Y
CONFIG_STDOUT_CONSOLE=Y
CONFIG_UART_INTERRUPT_DRIVEN=Y
CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=Y
CONFIG_PRINTK=Y
CONFIG_LOG_PRINTK=Y
CONFIG_GPIO=Y
CONFIG_SPI=Y
CONFIG_SPI_NRFX=Y
CONFIG_SPI_3=Y
CONFIG_SPI_3_NRF_SPIM=Y
4. Add the following function to 'main.c' and call it after the first printk in main():
static void spi_init(void)
{
const char* const spiName = "SPI_3";
struct device *const spi_dev = device_get_binding(spiName);
if (spi_dev == NULL) {
printk("Could not get %s device\n", spiName);
return;
}
return;
}