|
| 1 | +/* |
| 2 | +
|
| 3 | +Module: getconfig_catena4802.cpp |
| 4 | +
|
| 5 | +Function: |
| 6 | + Arduino-LMIC C++ HAL pinmaps for various boards |
| 7 | +
|
| 8 | +Copyright & License: |
| 9 | + See accompanying LICENSE file. |
| 10 | +
|
| 11 | +Author: |
| 12 | + Dhinesh Kumar Pitchai, MCCI November 2020 |
| 13 | +
|
| 14 | +*/ |
| 15 | + |
| 16 | +#if defined(ARDUINO_MCCI_CATENA_4802) || \ |
| 17 | + /* legacy names */ \ |
| 18 | + defined(ARDUINO_CATENA_4802) |
| 19 | + |
| 20 | +#include <arduino_lmic_hal_boards.h> |
| 21 | +#include <Arduino.h> |
| 22 | + |
| 23 | +#include "../lmic/oslmic.h" |
| 24 | + |
| 25 | +namespace Arduino_LMIC { |
| 26 | + |
| 27 | +class HalConfiguration_Catena4802_t : public HalConfiguration_t |
| 28 | + { |
| 29 | +public: |
| 30 | + enum DIGITAL_PINS : uint8_t |
| 31 | + { |
| 32 | + PIN_SX1276_NSS = D7, |
| 33 | + PIN_SX1276_NRESET = D8, |
| 34 | + PIN_SX1276_DIO0 = D25, |
| 35 | + PIN_SX1276_DIO1 = D26, |
| 36 | + PIN_SX1276_DIO2 = D27, |
| 37 | + PIN_SX1276_ANT_SWITCH_RX = D29, |
| 38 | + PIN_SX1276_ANT_SWITCH_TX_BOOST = D30, |
| 39 | + PIN_SX1276_ANT_SWITCH_TX_RFO = D31, |
| 40 | + PIN_VDD_BOOST_ENABLE = A0, |
| 41 | + PIN_TCXO_VDD = D33, |
| 42 | + }; |
| 43 | + |
| 44 | + virtual void begin(void) override |
| 45 | + { |
| 46 | + digitalWrite(PIN_TCXO_VDD, 0); |
| 47 | + pinMode(PIN_TCXO_VDD, OUTPUT); |
| 48 | + } |
| 49 | + |
| 50 | + virtual void end(void) override |
| 51 | + { |
| 52 | + digitalWrite(PIN_TCXO_VDD, 0); |
| 53 | + pinMode(PIN_TCXO_VDD, INPUT); |
| 54 | + } |
| 55 | + |
| 56 | + virtual bool queryUsingTcxo(void) override { return true; }; |
| 57 | + |
| 58 | + virtual ostime_t setModuleActive(bool state) override |
| 59 | + { |
| 60 | + ostime_t result; |
| 61 | + const int oldState = digitalRead(PIN_TCXO_VDD); |
| 62 | + |
| 63 | + // if turning on, we need to delay. |
| 64 | + result = 0; |
| 65 | + if (state && ! oldState) |
| 66 | + result = ms2osticksCeil(3); |
| 67 | + |
| 68 | + if (state != oldState) |
| 69 | + digitalWrite(PIN_TCXO_VDD, state); |
| 70 | + |
| 71 | + return result; |
| 72 | + } |
| 73 | + }; |
| 74 | + |
| 75 | +// save some typing by bringing the pin numbers into scope |
| 76 | +static HalConfiguration_Catena4802_t myConfig; |
| 77 | + |
| 78 | +static const HalPinmap_t myPinmap = |
| 79 | + { |
| 80 | + .nss = HalConfiguration_Catena4802_t::PIN_SX1276_NSS, // chip select is D7 |
| 81 | + .rxtx = HalConfiguration_Catena4802_t::PIN_SX1276_ANT_SWITCH_RX, // RXTX is D29 |
| 82 | + .rst = HalConfiguration_Catena4802_t::PIN_SX1276_NRESET, // NRESET is D8 |
| 83 | + |
| 84 | + .dio = {HalConfiguration_Catena4802_t::PIN_SX1276_DIO0, // DIO0 (IRQ) is D25 |
| 85 | + HalConfiguration_Catena4802_t::PIN_SX1276_DIO1, // DIO1 is D26 |
| 86 | + HalConfiguration_Catena4802_t::PIN_SX1276_DIO2, // DIO2 is D27 |
| 87 | + }, |
| 88 | + .rxtx_rx_active = 1, |
| 89 | + .rssi_cal = 10, |
| 90 | + .spi_freq = 8000000, /* 8MHz */ |
| 91 | + .pConfig = &myConfig |
| 92 | + }; |
| 93 | + |
| 94 | +const HalPinmap_t *GetPinmap_Catena4802(void) |
| 95 | + { |
| 96 | + return &myPinmap; |
| 97 | + } |
| 98 | + |
| 99 | +}; // namespace Arduino_LMIC |
| 100 | + |
| 101 | +#endif /* defined(ARDUINO_CATENA_4611) || defined(ARDUINO_CATENA_4802) */ |
0 commit comments