RAK3401Board.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <Arduino.h>
  2. #include <Wire.h>
  3. #include "RAK3401Board.h"
  4. void RAK3401Board::begin() {
  5. NRF52BoardDCDC::begin();
  6. pinMode(PIN_VBAT_READ, INPUT);
  7. #ifdef PIN_USER_BTN
  8. pinMode(PIN_USER_BTN, INPUT_PULLUP);
  9. #endif
  10. #ifdef PIN_USER_BTN_ANA
  11. pinMode(PIN_USER_BTN_ANA, INPUT_PULLUP);
  12. #endif
  13. #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
  14. Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
  15. #endif
  16. Wire.begin();
  17. // PIN_3V3_EN (WB_IO2, P0.34) controls the 3V3_S switched peripheral rail
  18. // AND the 5V boost regulator (U5) on the RAK13302 that powers the SKY66122 PA.
  19. // Must stay HIGH during radio operation — do not toggle for power saving.
  20. pinMode(PIN_3V3_EN, OUTPUT);
  21. digitalWrite(PIN_3V3_EN, HIGH);
  22. // Enable SKY66122-11 FEM on the RAK13302 module.
  23. // CSD and CPS are tied together on the RAK13302 PCB, routed to IO3 (P0.21).
  24. // HIGH = FEM active (LNA for RX, PA path available for TX).
  25. // TX/RX switching (CTX) is handled by SX1262 DIO2 via SetDIO2AsRfSwitchCtrl.
  26. pinMode(SX126X_POWER_EN, OUTPUT);
  27. digitalWrite(SX126X_POWER_EN, HIGH);
  28. delay(1); // SKY66122 turn-on settling time (tON = 3us typ)
  29. }
  30. #ifdef NRF52_POWER_MANAGEMENT
  31. void RAK3401Board::initiateShutdown(uint8_t reason) {
  32. // Disable SKY66122 FEM (CSD+CPS LOW = shutdown, <1 uA)
  33. digitalWrite(SX126X_POWER_EN, LOW);
  34. // Disable 3V3 switched peripherals and 5V boost
  35. digitalWrite(PIN_3V3_EN, LOW);
  36. enterSystemOff(reason);
  37. }
  38. #endif