#BL602 SPI Chip Select has a problem ... It goes High after EVERY byte ... Which is no-no for SX1262 ... Solution: We control Chip Select via GPIO
Our #NuttX App transmits an SPI Command to SX1262 ... And reads the SPI Response from SX1262
We implement the Read Operation for our #NuttX SPI Driver ... So that we can fetch the SPI Response from SX1262
https://github.com/lupyuen/incubator-nuttx/blob/spi_test/drivers/rf/spi_test_driver.c#L210-L233
Let's test #NuttX SPI with #BL602 and Semtech SX1262 LoRa Transceiver
https://www.semtech.com/products/wireless-rf/lora-core/sx1262
We can swap MISO and MOSI on #BL602 by setting a Hardware Register ... Let's do this on #NuttX
https://lupyuen.github.io/articles/pinedio#spi-pins-are-swapped
Logic Analyser connected to #BL602 shows that MISO and MOSI are swapped! This happens in BL602 IoT SDK ... Also in #NuttX!
https://lupyuen.github.io/articles/spi#spi-data-pins-are-flipped
#NuttX's SPI Pins match the #BL602 Reference Manual: MOSI = GPIO 1, MISO = GPIO 0 ... But we're about to witness a BL602 SPI Quirk
https://github.com/bouffalolab/bl_docs/tree/main/BL602_RM/en
How to verify the #NuttX SPI Output? We sniff the #BL602 SPI Bus with a Logic Analyser
https://lupyuen.github.io/articles/spi#appendix-troubleshoot-bl602-spi-with-logic-analyser
Now we see every byte transferred by #NuttX's SPI Driver for #BL602!
https://github.com/lupyuen/incubator-nuttx/blob/spi_test/drivers/rf/spi_test_driver.c
To watch what happens inside #NuttX's SPI Driver for #BL602 ... Turn on SPI Debug Logging
https://github.com/lupyuen/incubator-nuttx/blob/spi_test/arch/risc-v/src/bl602/bl602_spi.c
Here's how we configure the #NuttX SPI Interface
https://github.com/lupyuen/incubator-nuttx/blob/spi_test/drivers/rf/spi_test_driver.c#L95-L117
In the write() operation for our #NuttX SPI Test Driver, we 1️⃣ Lock the SPI Bus 2️⃣ Config the SPI Interface 3️⃣ Select the SPI Device 4️⃣ Transfer SPI Data 5️⃣ Deselect and Unlock
https://github.com/lupyuen/incubator-nuttx/blob/spi_test/drivers/rf/spi_test_driver.c#L182-L239
IoT Techie and Educator / Apache NuttX PMC