Skip to content

Commit

Permalink
working lmic with sx1262
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberman54 committed Jun 30, 2024
1 parent 0ddabc2 commit b0c1938
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
11 changes: 5 additions & 6 deletions shared/hal/ttgotsupremes3.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
// button and led
#define HAS_BUTTON GPIO_NUM_0 // SW3 button is on GPIO0
#define HAS_LED NOT_A_PIN
// SW2 -> CHIP_PU
// SW3 -> PWR_KEY

// GPS settings
#define HAS_GPS 1 // use on board GPS
Expand All @@ -50,17 +48,18 @@
#define GPS_WAKEUP GPIO_NUM_7 // currently unused in code

// LORA settings
#define HAS_LORA 0 // use on board LORA
#define HAS_LORA 1 // use on board LORA
#define CFG_sx1262_radio 1 // HPD16A
// Pins for LORA chip SPI interface, reset line and interrupt lines
#define LORA_RST (5)
#define LORA_SCK (12)
#define LORA_CS (10)
#define LORA_MISO (13)
#define LORA_MOSI (11)
#define LORA_IRQ NOT_A_PIN
#define LORA_IO1 (1) // RADIO_DIO1
#define LORA_IO2 (4) // RADIO_BUSY
#define LORA_IRQ (1)
#define LORA_IO1 LMIC_UNUSED_PIN
#define LORA_IO2 LMIC_UNUSED_PIN
#define PIN_SX1262_BUSY (4)

// BME280 sensor on I2C bus
//#define HAS_BME 1 // Enable BME sensors in general
Expand Down
11 changes: 9 additions & 2 deletions shared/lmic_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,16 @@
//#define LMIC_USE_INTERRUPTS 1
//#endif

// avoid lmic warning if we don't configure radio in case we haven't one
#if !(defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio))
// ensure that a radio is defined.
#if !(defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio) || defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio))
# warning Target radio not defined, assuming CFG_sx1276_radio
#define CFG_sx1276_radio 1
#elif defined(CFG_sx1272_radio) && (defined(CFG_sx1276_radio) || defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio))
# error You can define at most one target radio
#elif defined(CFG_sx1276_radio) && (defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio))
# error You can define at most one target radio
#elif defined(CFG_sx1261_radio) && (defined(CFG_sx1261_radio))
# error You can define at most one target radio
#endif

// time sync via LoRaWAN network, note: not supported by TTNv2
Expand Down
18 changes: 16 additions & 2 deletions src/lorawan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,30 @@ class MyHalConfig_t : public Arduino_LMIC::HalConfiguration_t {
// void end(void) override

// ostime_t setModuleActive(bool state) override

virtual u1_t queryBusyPin(void) override {
#ifdef PIN_SX1262_BUSY
return PIN_SX1262_BUSY;
#else
return LMIC_UNUSED_PIN;
#endif
}

virtual bool queryUsingDcdc(void) override { return true; }
virtual bool queryUsingDIO2AsRfSwitch(void) override { return true; }
virtual bool queryUsingDIO3AsTCXOSwitch(void) override { return true; }

};

static MyHalConfig_t myHalConfig{};

// LMIC pin mapping for Hope RFM95 / HPDtek HPD13A transceivers
// LMIC pin mapping for Hope RFM95 / HPDtek HPD13A/HPD16A transceivers
static const lmic_pinmap myPinmap = {
.nss = LORA_CS,
.rxtx = LMIC_UNUSED_PIN,
.rst = LORA_RST == NOT_A_PIN ? LMIC_UNUSED_PIN : LORA_RST,
.dio = {LORA_IRQ, LORA_IO1,
.dio = {LORA_IRQ == NOT_A_PIN ? LMIC_UNUSED_PIN : LORA_IRQ,
LORA_IO1 == NOT_A_PIN ? LMIC_UNUSED_PIN : LORA_IO1,
LORA_IO2 == NOT_A_PIN ? LMIC_UNUSED_PIN : LORA_IO2},
.rxtx_rx_active = LMIC_UNUSED_PIN,
.rssi_cal = 10,
Expand Down

0 comments on commit b0c1938

Please sign in to comment.