Hello
I'm trying to get spi to work on nrf52. First tried to use it with adxl372 driver but got nothing on device_binding returns null. Next I tried to create own driver for testing the functionality.
The code I used attached below. I have no clock or mosi signal in oscilloscope. Only chip select signal was responding.
prj.conf
CONFIG_GPIO=y
CONFIG_UART_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_LOG=y
CONFIG_SPI=y
CONFIG_SPI_NRFX=y
CONFIG_SPI_1=y
CONFIG_SPI_1_NRF_SPI=y
static void spiTest()
{
struct device *spi = device_get_binding("SPI_1");
struct device *gpio = device_get_binding(LED_PORT);
struct spi_cs_control cs;
struct spi_config cfg;
gpio_pin_configure(gpio, LED, GPIO_DIR_OUT);
cs.gpio_dev = gpio;
cs.gpio_pin = LED;
cfg.frequency = 2000000;
cfg.operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8);
cfg.slave = 0;
cfg.cs = &cs;
if(spi == NULL){
printk("spi not found\n");
return;
// Write some data
u8_t data[] = {1,2,3,4};
struct spi_buf tx_buf = {.buf = data, .len = 4};
struct spi_buf_set tx_bufs = {.buffers = &tx_buf, .count = 1};
spi_write(spi, &cfg, &tx_bufs);
}