I'm having problems with the spi api for zephyr, maybe my spi peripherals are not configured correctly, I can see normal signal outputs from the clock and mosi signal lines, but the cs line stays pulled up and doesn't use any other outputs;
I am using the nrf52840dk and trying to drive the st7789v display via spi;
The sdk version I'm using is 2.5.0; the dts used is nrf52840dk_nrf52840;.
Here is the contents of my .overlay file:
&spi1 {
status = "disabled";
};
&spi3 {
status = "disabled";
};
&i2c0 {
status = "disabled";
};
&qspi {
status = "disabled";
};
&adc {
status = "disabled";
};
&spi0 {
status = "okay";
cs-gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
};
&spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 3)>, <NRF_PSEL(SPIM_MOSI, 0, 4)>;
};
};
Here are the contents of my prj.conf:
CONFIG_NRFX_SPIM3=y CONFIG_SPI=y
My spi does it like this:
const struct device *spi= DEVICE_DT_GET(DT_NODELABEL(spi0));
struct spi_config spi_cfg = {
.operation = SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE ,
.frequency = 8000000,
.slave = 1,
.cs = {
.gpio = SPI_CS_GPIOS_DT_SPEC_GET(spi),
.delay = 2,
}
};
int SPI_init(void)
{
if(!device_is_ready(spi))
{
printk("SPI device is not ready\n");
return -1;
}
printk("is gpio %s\r\n", spi_cs_is_gpio(&spi_cfg.cs) ? "GPIO" : "Hardware CS");
return 0;
}
void SPI_write(uint8_t *data, uint16_t len)
{
struct spi_buf tx_buf = {
.buf = data,
.len = len
};
struct spi_buf_set tx = {
.buffers = &tx_buf,
.count = 1
};
int ret = spi_write(spi, &spi_cfg, &tx);
}
Here is the git link to my code:
Any help I can get would be appreciated and very much appreciated!