QSPI chip select pin control and configuration in Zephyr RTOS question

Viewed 225

I am trying to use QSPI bus to access a serial NOR flash in Zephyr. The CS(chip select) pin stays high all the time. It should be active low when the flash chip is selected. Just wondering if the QSPI CS is working in Zephyr or I need to configure the CS pin as GPIO and control it by my software.

Anyone had CS pin of QSPI working in Zephyr ?? I am using rNF52480 from Nordic semiconductor.

Thanks,

JC

1 Answers

I think you need to configure it yourself:

...
#include <drivers/gpio.h>
#include <drivers/spi.h>

struct spi_cs_control spi_cs = {
    /* PA4 as CS pin */
    .gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpioa)),
    .gpio_pin = 4,
    .gpio_dt_flags = GPIO_ACTIVE_LOW,
    /* delay in microseconds to wait before starting the transmission and before releasing the CS line */
    .delay = 10,
};

#define SPI_CS (&spi_cs)

struct spi_config spi_cfg = {
    .frequency = 350000,
    .operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_QUAD | SPI_LOCK_ON,
    .cs = SPI_CS,
};

void spi_init()
{
    spi = device_get_binding("SPI_1");
    ....
}
Related