Hello,
I have an external flash w25q32 spi nor flash. I tried to communicate with my flash using spi_nor driver code in zephery however it didn't detect the external flash saying "flash driver was not found" .The device get binding was returning false. Then I tried to just read the jedec id with spi_transceive. I am sending 9F command and dummy bytes to detect the jedec id however still I am not able to get the jedec id. You can see the logic analyzer output attached. The jedec id has to be ef 40 16.
My main.c is:
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include <sys/printk.h>
#include <drivers/spi.h>
//addition for combining blinky
static struct spi_config spi_cfg = {
.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB |
SPI_MODE_CPOL | SPI_MODE_CPHA,
.frequency = 4000000,
.slave = 0,
};
struct device * spi_dev;
static void spi_init(void) {
const char *
const spiName = "SPI_3";
spi_dev = device_get_binding(spiName);
if (spi_dev == NULL) {
printk("Could not get %s device\n", spiName);
return;
}
}
void spi_test_send(void) {
int err;
//static u8_t tx_buffer[1];
//static u8_t rx_buffer[1];
static u8_t tx_buffer[5] = {
0X9F,
0x00,
0x00,
0x00,
0x00
};
static u8_t rx_buffer[5];
const struct spi_buf tx_buf = {
.buf = tx_buffer,
.len = sizeof(tx_buffer)
};
const struct spi_buf_set tx = {
.buffers = & tx_buf,
.count = 1
};
struct spi_buf rx_buf = {
.buf = rx_buffer,
.len = sizeof(rx_buffer),
};
const struct spi_buf_set rx = {
.buffers = & rx_buf,
.count = 1
};
struct device * gpio_dev;
struct spi_cs_control cs_control;
gpio_dev = device_get_binding("GPIO_0");
if (!gpio_dev) {
printk("could not find GPIO device\n");
return;
}
gpio_pin_configure(gpio_dev,13,GPIO_OUTPUT_ACTIVE);
gpio_pin_set(gpio_dev,13,0);
err = spi_transceive(spi_dev, & spi_cfg, & tx, & rx);
gpio_pin_set(gpio_dev,13,1);
if (err) {
printk("SPI error: %d\n", err);
} else {
/* Connect MISO to MOSI for loopback */
for (int i = 0; i < sizeof(tx_buffer); i++) {
printk("TX transmit: %x\n", tx_buffer[i]);
}
for (int i = 0; i <sizeof(rx_buffer); i++) {
printk("RX recv: %x\n", rx_buffer[i]);
}
}
}
void main(void) {
printk("SPIM Example\n");
spi_init();
printk("After init\n");
while (1) {
spi_test_send();
k_sleep(K_MSEC(10));
printk(".");
}
},
my overlay is:
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
sck-pin = <10>;
mosi-pin = <11>;
miso-pin = <12>;
//cs-gpios = <&gpio0 13 0>;
};
My proj.conf:
CONFIG_SPI=y CONFIG_MAIN_STACK_SIZE=4096 # CONFIG_SPI_0=y # UART, SPIM, and I2C are shared peripherals on nrf9160 # therefore we choose SPI3 CONFIG_SPI_3=y CONFIG_SPI_NRFX=y CONFIG_DEPRECATED_ZEPHYR_INT_TYPES=y #addition for combining blinky CONFIG_GPIO=y
The logic analyzer output is:

Can you help me with this issue. I couldn't understand why it is not working for detecting jedec id. Any help would be so helpful.
Thank you