Skip to content
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

Generalise SPI pin names #2970

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,24 +628,24 @@ void setup()
initSPI();
#ifdef ARCH_RP2040
#ifdef HW_SPI1_DEVICE
SPI1.setSCK(RF95_SCK);
SPI1.setTX(RF95_MOSI);
SPI1.setRX(RF95_MISO);
pinMode(RF95_NSS, OUTPUT);
digitalWrite(RF95_NSS, HIGH);
SPI1.setSCK(LORA_SCK);
SPI1.setTX(LORA_MOSI);
SPI1.setRX(LORA_MISO);
pinMode(LORA_CS, OUTPUT);
digitalWrite(LORA_CS, HIGH);
SPI1.begin(false);
#else // HW_SPI1_DEVICE
SPI.setSCK(RF95_SCK);
SPI.setTX(RF95_MOSI);
SPI.setRX(RF95_MISO);
SPI.setSCK(LORA_SCK);
SPI.setTX(LORA_MOSI);
SPI.setRX(LORA_MISO);
SPI.begin(false);
#endif // HW_SPI1_DEVICE
#elif !defined(ARCH_ESP32) // ARCH_RP2040
SPI.begin();
#else
// ESP32
SPI.begin(RF95_SCK, RF95_MISO, RF95_MOSI, RF95_NSS);
LOG_WARN("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)\n", RF95_SCK, RF95_MISO, RF95_MOSI, RF95_NSS);
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
LOG_WARN("SPI.begin(SCK=%d, MISO=%d, MOSI=%d, NSS=%d)\n", LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
SPI.setFrequency(4000000);
#endif

Expand Down Expand Up @@ -755,7 +755,7 @@ void setup()

#if defined(RF95_IRQ)
if (!rIf) {
rIf = new RF95Interface(RadioLibHAL, RF95_NSS, RF95_IRQ, RF95_RESET, RF95_DIO1);
rIf = new RF95Interface(RadioLibHAL, LORA_CS, RF95_IRQ, RF95_RESET, RF95_DIO1);
if (!rIf->init()) {
LOG_WARN("Failed to find RF95 radio\n");
delete rIf;
Expand Down
10 changes: 5 additions & 5 deletions src/platform/esp32/architecture.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@
// -----------------------------------------------------------------------------

// NRF52 boards will define this in variant.h
#ifndef RF95_SCK
#define RF95_SCK 5
#define RF95_MISO 19
#define RF95_MOSI 27
#define RF95_NSS 18
#ifndef LORA_SCK
#define LORA_SCK 5
#define LORA_MISO 19
#define LORA_MOSI 27
#define LORA_CS 18
#endif

#define SERIAL0_RX_GPIO 3 // Always GPIO3 on ESP32
2 changes: 1 addition & 1 deletion src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ void portduinoSetup()
gpioBind(new SimGPIOPin(LORA_DIO1, "fakeLoraIrq"));
}
// gpioBind((new SimGPIOPin(LORA_RESET, "LORA_RESET")));
// gpioBind((new SimGPIOPin(RF95_NSS, "RF95_NSS"))->setSilent());
// gpioBind((new SimGPIOPin(LORA_CS, "LORA_CS"))->setSilent());
#endif
}
10 changes: 5 additions & 5 deletions variants/ai-c3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#define LED_PIN 30 // RGB LED

#define USE_RF95
#define RF95_SCK 4
#define RF95_MISO 5
#define RF95_MOSI 6
#define RF95_NSS 7
#define LORA_SCK 4
#define LORA_MISO 5
#define LORA_MOSI 6
#define LORA_CS 7

#define LORA_DIO0 10
#define LORA_DIO1 3
Expand All @@ -19,7 +19,7 @@
// WaveShare Core1262-868M
// https://www.waveshare.com/wiki/Core1262-868M
#define USE_SX1262
#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY 10
#define SX126X_RESET LORA_RESET
Expand Down
8 changes: 4 additions & 4 deletions variants/betafpv_2400_tx_micro/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#undef GPS_RX_PIN
#undef GPS_TX_PIN

#define RF95_SCK 18
#define RF95_MISO 19
#define RF95_MOSI 23
#define RF95_NSS 5
#define LORA_SCK 18
#define LORA_MISO 19
#define LORA_MOSI 23
#define LORA_CS 5
#define RF95_FAN_EN 17

#define LED_PIN 16 // This is a LED_WS2812 not a standard LED
Expand Down
8 changes: 4 additions & 4 deletions variants/betafpv_900_tx_nano/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

#define USE_RF95

#define RF95_SCK 18
#define RF95_MISO 19
#define RF95_MOSI 23
#define RF95_NSS 5
#define LORA_SCK 18
#define LORA_MISO 19
#define LORA_MOSI 23
#define LORA_CS 5

#define LORA_DIO0 4
#define LORA_RESET 14
Expand Down
28 changes: 14 additions & 14 deletions variants/bpi_picow_esp32_s3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@

// #define USE_RF95 // RFM95/SX127x

#undef RF95_SCK
#undef RF95_MISO
#undef RF95_MOSI
#undef RF95_NSS
#undef LORA_SCK
#undef LORA_MISO
#undef LORA_MOSI
#undef LORA_CS

// WaveShare Core1262-868M OK
// https://www.waveshare.com/wiki/Core1262-868M
#define USE_SX1262

#ifdef USE_SX1262
#define RF95_MISO 39
#define RF95_SCK 21
#define RF95_MOSI 38
#define RF95_NSS 17
#define LORA_MISO 39
#define LORA_SCK 21
#define LORA_MOSI 38
#define LORA_CS 17
#define LORA_RESET 42
#define LORA_DIO1 5
#define LORA_BUSY 47
#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
Expand All @@ -49,14 +49,14 @@

// #define USE_SX1280
#ifdef USE_SX1280
#define RF95_MISO 1
#define RF95_SCK 3
#define RF95_MOSI 4
#define RF95_NSS 2
#define LORA_MISO 1
#define LORA_SCK 3
#define LORA_MOSI 4
#define LORA_CS 2
#define LORA_RESET 17
#define LORA_DIO1 12
#define LORA_BUSY 47
#define SX128X_CS RF95_NSS
#define SX128X_CS LORA_CS
#define SX128X_DIO1 LORA_DIO1
#define SX128X_BUSY LORA_BUSY
#define SX128X_RESET LORA_RESET
Expand Down
20 changes: 10 additions & 10 deletions variants/diy/dr-dev/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
// In receiving, set RXEN as high communication level, TXEN is lowlevel;
// Before powering off, set TXEN、RXEN as low level.

#undef RF95_SCK
#define RF95_SCK 18
#undef RF95_MISO
#define RF95_MISO 19
#undef RF95_MOSI
#define RF95_MOSI 23
#undef LORA_SCK
#define LORA_SCK 18
#undef LORA_MISO
#define LORA_MISO 19
#undef LORA_MOSI
#define LORA_MOSI 23

// PINS FOR THE 900M22S

Expand All @@ -38,8 +38,8 @@
// E22_TXEN_CONNECTED_TO_DIO2 wasn't defined, so RXEN wasn't controlled. Commented it out to maintain behavior, but shouldn't be.
// Need to comment out defining SX126X_RXEN as LORA_RXEN too
// #define LORA_RXEN 17 // Input - RF switch RX control, connecting external MCU IO, valid in high level
#undef RF95_NSS
#define RF95_NSS 16
#undef LORA_CS
#define LORA_CS 16
#define SX126X_BUSY 22
#define SX126X_CS 16

Expand All @@ -49,8 +49,8 @@
#define LORA_DIO2 35 // BUSY for SX1262/SX1268
#define LORA_TXEN NOT_A_PIN // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level
#define LORA_RXEN 21 // Input - RF switch RX control, connecting external MCU IO, valid in high level
#undef RF95_NSS
#define RF95_NSS 33
#undef LORA_CS
#define LORA_CS 33
#define SX126X_BUSY 35
#define SX126X_CS 33
*/
Expand Down
8 changes: 4 additions & 4 deletions variants/diy/hydra/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#define SX126X_TXEN 13 // Schematic connects EBYTE module's TXEN pin to MCU
#define SX126X_RXEN 14 // Schematic connects EBYTE module's RXEN pin to MCU

#define RF95_NSS SX126X_CS // Compatibility with variant file configuration structure
#define RF95_SCK SX126X_SCK // Compatibility with variant file configuration structure
#define RF95_MOSI SX126X_MOSI // Compatibility with variant file configuration structure
#define RF95_MISO SX126X_MISO // Compatibility with variant file configuration structure
#define LORA_CS SX126X_CS // Compatibility with variant file configuration structure
#define LORA_SCK SX126X_SCK // Compatibility with variant file configuration structure
#define LORA_MOSI SX126X_MOSI // Compatibility with variant file configuration structure
#define LORA_MISO SX126X_MISO // Compatibility with variant file configuration structure
#define LORA_DIO1 SX126X_DIO1 // Compatibility with variant file configuration structure
8 changes: 4 additions & 4 deletions variants/diy/v1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#define LORA_DIO2 32 // BUSY for SX1262/SX1268
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled

#define RF95_SCK 5
#define RF95_MISO 19
#define RF95_MOSI 27
#define RF95_NSS 18
#define LORA_SCK 5
#define LORA_MISO 19
#define LORA_MOSI 27
#define LORA_CS 18

// supported modules list
#define USE_RF95 // RFM95/SX127x
Expand Down
16 changes: 8 additions & 8 deletions variants/diy/v1_1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
#define LORA_RXEN 14 // Input - RF switch RX control, connecting external MCU IO, valid in high level
#define LORA_TXEN 13 // Input - RF switch TX control, connecting external MCU IO or DIO2, valid in high level

#undef RF95_SCK
#define RF95_SCK 18
#undef RF95_MISO
#define RF95_MISO 19
#undef RF95_MOSI
#define RF95_MOSI 23
#undef RF95_NSS
#define RF95_NSS 5
#undef LORA_SCK
#define LORA_SCK 18
#undef LORA_MISO
#define LORA_MISO 19
#undef LORA_MOSI
#define LORA_MOSI 23
#undef LORA_CS
#define LORA_CS 5

// RX/TX for RFM95/SX127x
#define RF95_RXEN LORA_RXEN
Expand Down
10 changes: 5 additions & 5 deletions variants/feather_diy/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ extern "C" {
#define LORA_DIO2 (0 + 8) // P0.08 12 // BUSY for SX1262/SX1268
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled

#define RF95_SCK SCK
#define RF95_MISO MI
#define RF95_MOSI MO
#define RF95_NSS SS
#define LORA_SCK SCK
#define LORA_MISO MI
#define LORA_MOSI MO
#define LORA_CS SS

// enables 3.3V periphery like GPS or IO Module
#define PIN_3V3_EN (-1)
Expand All @@ -95,7 +95,7 @@ extern "C" {
#define USE_SX1262

// common pinouts for SX126X modules
#define SX126X_CS RF95_NSS // NSS for SX126X
#define SX126X_CS LORA_CS // NSS for SX126X
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
Expand Down
18 changes: 9 additions & 9 deletions variants/heltec_esp32c3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
#undef GPS_RX_PIN
#undef GPS_TX_PIN

#undef RF95_SCK
#undef RF95_MISO
#undef RF95_MOSI
#undef RF95_NSS
#undef LORA_SCK
#undef LORA_MISO
#undef LORA_MOSI
#undef LORA_CS

#define USE_SX1262
#define RF95_SCK 10
#define RF95_MISO 6
#define RF95_MOSI 7
#define RF95_NSS 8
#define LORA_SCK 10
#define LORA_MISO 6
#define LORA_MOSI 7
#define LORA_CS 8
#define LORA_DIO0 RADIOLIB_NC
#define LORA_RESET 5
#define LORA_DIO1 3
#define LORA_DIO2 RADIOLIB_NC
#define LORA_BUSY 4
#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_BUSY
#define SX126X_RESET LORA_RESET
Expand Down
10 changes: 5 additions & 5 deletions variants/heltec_v3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#define LORA_DIO2 13 // SX1262 BUSY
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled

#define RF95_SCK 9
#define RF95_MISO 11
#define RF95_MOSI 10
#define RF95_NSS 8
#define LORA_SCK 9
#define LORA_MISO 11
#define LORA_MOSI 10
#define LORA_CS 8

#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
Expand Down
10 changes: 5 additions & 5 deletions variants/heltec_wireless_paper/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
#define LORA_DIO2 13 // SX1262 BUSY
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled

#define RF95_SCK 9
#define RF95_MISO 11
#define RF95_MOSI 10
#define RF95_NSS 8
#define LORA_SCK 9
#define LORA_MISO 11
#define LORA_MOSI 10
#define LORA_CS 8

#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
Expand Down
10 changes: 5 additions & 5 deletions variants/heltec_wireless_tracker/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
#define LORA_DIO2 13 // SX1262 BUSY
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled

#define RF95_SCK 9
#define RF95_MISO 11
#define RF95_MOSI 10
#define RF95_NSS 8
#define LORA_SCK 9
#define LORA_MISO 11
#define LORA_MOSI 10
#define LORA_CS 8

#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
Expand Down
10 changes: 5 additions & 5 deletions variants/heltec_wsl_v3/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#define LORA_DIO2 13 // SX1262 BUSY
#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled

#define RF95_SCK 9
#define RF95_MISO 11
#define RF95_MOSI 10
#define RF95_NSS 8
#define LORA_SCK 9
#define LORA_MISO 11
#define LORA_MOSI 10
#define LORA_CS 8

#define SX126X_CS RF95_NSS
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO2
#define SX126X_RESET LORA_RESET
Expand Down
Loading
Loading