Closed mccolljr closed 2 years ago
I spent some more time with this today and I think the issue was that I was mis-reading the documents. The bit-banging SPI implementation I used was following the pattern described in the datasheet for the chip. I just mis-interpreted what SPI mode it would map to. Running this with a clock divider of 2 and in SPI mode 0 worked how I expected.
Closing, as I think this was entirely my fault, haha.
Hey,
first of all - thanks for this awesome suite of crates. I've been making heavy use of these in some projects lately and they've been a spectacular productivity booster.
Yesterday I burned a few hours trying to get my RF24L01+ chip working via the hardware SPI.
I verified that the devices were working correctly on both an Arduino Nano and an Arduino Uno using the NRF24 example sketches via the Arduino IDE. Packet transmission & reception both tested correctly.
This tells me that the peripheral hardware and the SPI hardware on the Arduinos are both in working order. I could not for the life of me get SPI communication working reliably with the NRF chip via rust on either Arduino board, either Uno or Nano. I tried 2 3rd-party drivers (
embedded_nrf24l01
andnrf24_rs
), both of which intermittently failed to initialize the device. I then implemented a driver myself, but ran into the same problem. I also noticed that register reads done after reset were returning incorrect values. I checked to see if the issue was reversed bits, but0
is the same in both directions and isn't the reset value for one of the registers in question. The NRF24L01+ chip operates in SPI mode 1, and uses MSBit / LSByte ordering. I tried several different configurations for the built-in SPI bus to see if maybe I was messing up there, but I didn't have any success.I finally had success when I switched to a bit-banging SPI interface that I set up myself - register reads started returning expected values, and I finally got Rx/Tx working correctly.
I'm at a loss, could this possibly be an issue with how the SPI bus is initialized via this crate? I'm new to these Arduino boards and especially to the SPI interface on them (I've only been doing embedded development for a little over a year), so I'm not sure how I can best troubleshoot this. I'm happy to do some digging if you have any guidance