sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.63k stars 626 forks source link

1 SPI master and 2 LoRa SPI as slave again. #370

Closed IoTThinks closed 3 years ago

IoTThinks commented 4 years ago

I have an ESP32 with 2 SPI SX1278.

This is the architecture image

The mapping is below. MISO, MOSI and SCK are shared for 2 LoRa.

// LoRa 1 pins
#define LORA_SS          23
**#define LORA_SCK         18
#define LORA_MOSI         5
#define LORA_MISO        36**
#define LORA_DIO012      39
#define LORA_RST         13

// LoRa 2 pins
#define LORA2_SS         32
**#define LORA2_SCK        18 // Shared
#define LORA2_MOSI        5 // Shared
#define LORA2_MISO       36 // Shared**
#define LORA2_DIO012     34
#define LORA2_RST        15

For LoRa 1

  SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI);
  SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS);
  LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO012);

For LoRa 2

  SPI.begin(LORA2_SCK, LORA2_MISO, LORA2_MOSI, LORA2_SS);  <======= Feel something wrong here.
  LoRa2.setPins(LORA2_SS, LORA2_RST, LORA2_DIO012);

I feel something wrong in SPI.begin for LoRa 2 already as it overwrite the SPI begin in LoRa 1. From the code of this library, I see SS will be set HIGH or LOW before/after read/write registers.

My scenario is to receive via LoRa 1 and to send async with LoRa 2. How the library enable my LoRa_SS and LoRa2_SS in this case?

Thanks a lot.