-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
This is the better solution. Use as much ready made code as possible. Maybe you could work together with @oll3 on this as you both seem to have figured it out independently. |
Excellent! Tested this with SX1272 chip (PR #34) and seems to be working. |
Hmm I think https://github.com/embassy-rs/embassy/blob/main/embassy-lora/src/iv.rs#L223 also has to change. But I hit the problem that This is my current code without this patch. So it seems that I use Now it is working but I have to update the dependency of three crates.
|
You're absolutely correct about needing a change in Embassy. I apologize for not noting and linking that initially. I made the exact same change to embassy here. The responsibility of controlling the chip select pin is moved from InterfaceVariant to SpiDevice. This is a good reference for what the SpiDevice is responsible for. The SpiDeviceWithConfig type provided by embassy additionally changes mode/freq/etc, which is very similar to what your SpiBusWithConfig does. This change should not require any changes downstream crates such as lorawan-rust, except to bump the version when everything is ready to be released. The interdependence of these 3 projects is currently a bit messy, and we've been discussing potential changes in the matrix channel. It's likely that embassy-lora and lora-phy will be merged, which will prevent this kind of confusion in the future. |
Because we now use SpiDevice, each read/write/transfer also toggles the CS pin this means we need to use a single transaction or the radio will send back garbage. This should also make spi transfers more effiecient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, will be a major breaking change but that is okay
Should close #31. Will also conflict with #29, but because the change from SpiBus to SpiDevice also required switching to spi transactions, it should have a similar effect on perf as #29.
I've tested on my hardware (custom rp240 board and sx1262 boards), and it works here. I don't have an sx1261 or sx127x to test against, though I doubt this will cause issues for those parts. I'm more concerned about the stm32wl, as I don't know how it's weird internal spi interface works, and as such have marked this a draft.
This is also a breaking change that would require a major version bump.