I need to connect a device to an nRF5340 SPI port without creating a custom driver. I'm tempted to use the nrfx_spim driver directly, but I'm trying to do it with Zephyr and the device tree. I've looked for examples of how to use the Zephyr SPI driver directly (without having to extend it to a custom device driver like the BME280 example), but I could only find the following examples:
- The SPI FRAM Module Sample (spi_fujitsu_fram) from the zephyr/sample/drivers sample apps - This seems incomplete since it doesn't show to get the CS pin working, and it is missing any overlay files
- https://github.com/sigurdnev/ncs-playground/tree/master/samples/spi_test is out of date
I've tried to combine the information from these and have code that compiles and runs, but the pins don't move (viewed by a logic analyzer). The SCK, MOSI and MISO lines stay low, and the CS# line seems to be floating since it is just noise. Can you tell me what is missing from my code?
Here is the edited file (fpga_spi_init is called by the main() in main.c, and the LOG information is seen on the console):
The device_is_ready call returns true, and the read returns, but with zero data, and no movement on the pins. Note that this uses SPI4 which is capable of 32 MHz, and lowering the frequency to 8 MHz doesn't work either.
Here is the nrf7002dk_nrf5340_cpuapp.overlay file which removes the nRF7002DK's mx25R6435f Flash chip support and sets the alias. The board has been modified to cut power to the Flash chip and solder jump the SPI4 pins to the headers as described in the nRF7002DK documentation and board.
I checked the build/zephyr/zephyr.dts file to confirm that the device tree is compiling the way I intend it, and it looks ok to me, with `status = "okay"`, the cs-gpios set to pin 0.11, etc. Here are the relevant sections:
What am I missing to get the SPI pins to actually work?