Struggling for several days to get SPI working w/ Zephyr

Hi, I can get ahold of the SPI device and call the spi_transceive function wihtout returning error codes.  Logic analyzer shows nothing happening, such as SCK clocking.  I am using the NRF52833-DK board.

In pj.conf:

CONFIG_SPI=y

In .dts:

can_spi: &spi1 {
    compatible = "nordic,nrf-spim";
    cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";
};

&pinctrl {
    spi1_default: spi1_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
                <NRF_PSEL(SPIM_MISO, 1, 2)>,
                <NRF_PSEL(SPIM_MOSI, 1, 3)>;
        };
    };

    spi1_sleep: spi1_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 1, 1)>,
                <NRF_PSEL(SPIM_MISO, 1, 2)>,
                <NRF_PSEL(SPIM_MOSI, 1, 3)>;
            low-power-enable;
        };
    };
};
In C module for SPI transactions:

#include <stdint.h>
#include <string.h>

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>                                                                                                                                                    
#include <zephyr/drivers/spi.h>
#include <zephyr/logging/log.h>

#include "spi_interface.h"

LOG_MODULE_REGISTER(spi_interface, LOG_LEVEL_INF);

static struct device * spi_dev;
static struct spi_buf tx_spi_buffer[1];
static struct spi_buf rx_spi_buffer[1];

static struct spi_config spi_cfg = {
    .frequency = 500000,
    .operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE,
};

static const struct spi_buf_set api_tx_buff = { tx_spi_buffer, 1 };
static const struct spi_buf_set api_rx_buff = { rx_spi_buffer, 1 };

void spi_init(void)
{
    spi_dev = device_get_binding(DEVICE_DT_NAME(DT_NODELABEL(spi1)));

    if (spi_dev == NULL) {
        /* No such node, or the node does not have status "okay". */
        LOG_ERR("\nError: no device found.\n");
    }
    else if (!device_is_ready(spi_dev)) {
        LOG_ERR("\nError: Device \"%s\" is not ready; "
               "check the driver initialization logs for errors.\n",
               spi_dev->name);
    }
    else
    {
        LOG_INF("Found device \"%s\", getting sensor data\n", spi_dev->name);
    }
}

void spi_trx(uint8_t* tx_buf, uint8_t write_size, uint8_t* rx_buf, uint8_t read_size)
{
    tx_spi_buffer[0].buf = tx_buf;
    tx_spi_buffer[0].len = write_size;
 
    rx_spi_buffer[0].buf = rx_buf;
    rx_spi_buffer[0].len = read_size;

    int ret = spi_transceive(spi_dev,
                   &spi_cfg,
                   &api_tx_buff,
                   &api_rx_buff);

    if (ret < 0)
    {
        LOG_ERR("err code %d", ret);
    }
}
Related