-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom SPI pins #121
Comments
There's already a Lines 38 to 51 in b7c21ff
You should be able to create a new SPI class with the correct pins or change the pins of the default SPI prior to calling |
Hi Jan, thanks for you fast reply. There's no way to change the pins pior calling Module constructor, seems that the only way to change them is via begin(sck, miso, mosi, ss). I'll extend SPI and wrap Thanks. P.S: Feel free to re-open if you spot a smarter way to do it! |
Not with the default examples, but there's no reason you can't do something like this (untested with HW but does compile): #include <RadioLib.h>
SPIClass newSPI(HSPI);
Module* mod;
SX1268* radio;
void setup() {
newSPI.begin(5, 19, 18, SS);
mod = new Module(10, 2, 3, 9, newSPI);
radio = new SX1268(mod);
} |
Looking over Module.cpp however, I came across this: Line 61 in b7c21ff
It's not entirely clear whether that will re-initialize SPI on the default pins, this will have to be tested (and preferrably only initialize SPI if the user hasn't done so). |
That double call to begin was the reason why I was proposing the wrapper 😄 I’ll anyway test your solution and check what happens, I’ll let you know soon. Thank you |
I think it should be enough to discard the default SPI arguments in Module constructors and add new constructors that don't have SPIClass and SPISettings args. That way, when user wants to use the default SPI, they can just call the constructor with no SPI arguments. |
@Guglio95 |
Hi Jan, Thanks, I was about to text you, I found an easier way for my specific case, I discovered that when using the right platformio's board definition the default pins (miso/mosi/...) are changed according to the labels printed on the board. Thanks 😄 |
Hi Jan,
I was testing out RadioLib on a Adafruit HUZZAH32 – ESP32 Feather and spot a strange issue: the labeled SPI pins are (MOSI: 18, MISO: 19, SCK: 5) which differ from the default ones (MOSI: 23, MISO: 19, SCK: 18).
Unfortunately, all the feather boards/radios agree on this pin mapping.
Meaning that i had to manually patch
Module.cpp
, specifying the pinout as:_spi->begin(5, 19, 18, SS);
.Have you already faced this sort of issue?
I was wondering about adding some parameters to Module's constructor, but I'm not sure about compatibility with other boards: seems that ESP822's SPI::begin is not accepting custom mapping.
Let me know 😄
The text was updated successfully, but these errors were encountered: