variant.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. Copyright (c) 2014-2015 Arduino LLC. All right reserved.
  3. Copyright (c) 2016 Sandeep Mistry All right reserved.
  4. Copyright (c) 2018, Adafruit Industries (adafruit.com)
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. See the GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. */
  17. #ifndef _VARIANT_R1NEO_
  18. #define _VARIANT_R1NEO_
  19. #define RAK4630
  20. /** Master clock frequency */
  21. #define VARIANT_MCK (64000000ul)
  22. #define USE_LFXO // Board uses 32khz crystal for LF
  23. // define USE_LFRC // Board uses RC for LF
  24. /*----------------------------------------------------------------------------
  25. * Headers
  26. *----------------------------------------------------------------------------*/
  27. #include "WVariant.h"
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #endif // __cplusplus
  32. /* Number of pins defined in PinDescription array */
  33. #define PINS_COUNT (48)
  34. #define NUM_DIGITAL_PINS (48)
  35. #define NUM_ANALOG_INPUTS (8)
  36. #define NUM_ANALOG_OUTPUTS (0)
  37. /* R1Neo peculiarities */
  38. #define PIN_DCDC_EN_MCU_HOLD (13) // P0.13 (04) DCDC_EN_MCU_HOLD
  39. #define PIN_SOFT_SHUTDOWN (29) // P0.29 (32) SOFT_SHUTDOWN_SIGNAL
  40. #define PIN_MCU_SIGNAL (30) // P0.30 (33) MCU_SIGNAL
  41. /* R1Neo LoRa Radio */
  42. // RAK4630/4631 pins
  43. #define P_LORA_DIO_1 (47) // P1.15 (SX)
  44. #define P_LORA_NSS (42) // P1.10 (SX)
  45. #define P_LORA_RESET RADIOLIB_NC // P1.06 (SX) -- 38
  46. #define P_LORA_BUSY (46) // P1.14 (SX)
  47. #define P_LORA_SCLK (43) // P1.11 (SX)
  48. #define P_LORA_MISO (45) // P1.13 (SX)
  49. #define P_LORA_MOSI (44) // P1.12 (SX)
  50. #define SX126X_POWER_EN (37) // P1.05 (SX)
  51. #define SX126X_DIO2_AS_RF_SWITCH true
  52. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  53. /* R1Neo peripherals */
  54. /* GPS */
  55. #define GPS_RX (24) // P0.24 (23) UART_GPS_RX
  56. #define GPS_TX (25) // P0.25 (24) UART_GPS_TX
  57. #define GPS_EN (33) // P1.01 (25) GPS_EN
  58. #define GPS_PPS (2) // P0.02 (30) GPS_PPS
  59. #define PIN_GPS_1PPS GPS_PPS
  60. #define GPS_BAUD_RATE 9600
  61. /* RTC */
  62. #define RTC_SDA (19) // P0.19 (9) RTC_SDA
  63. #define RTC_SCL (20) // P0.20 (10) RTC_SCL
  64. /* LEDs */
  65. #define LED_GREEN (36) // P1.04 (28) GRN_LED_RAK
  66. #define LED_BLUE (28) // P0.28 (31) BLU_LED_RAK
  67. #define LED_BUILTIN (0xFF)
  68. #ifndef P_LORA_TX_LED
  69. #define P_LORA_TX_LED LED_GREEN
  70. #endif
  71. #define LED_STATE_ON 1 // State when LED is lit
  72. /* Buttons */
  73. #define PIN_USER_BTN (26)
  74. /* Buzzer */
  75. #define PIN_BUZZER (3)
  76. /* Analog pins */
  77. // Arduino makes me angry
  78. #define PIN_A0 (0xFF) // NOT_PRESENT
  79. #define PIN_A1 (0xFF) // NOT_PRESENT
  80. #define PIN_A2 (4) // P0.04 (41) NC
  81. #define PIN_A3 (5) // P0.05 (40) NC
  82. #define PIN_A4 (0xFF) // NOT_PRESENT
  83. #define PIN_A5 (0xFF) // NOT_PRESENT
  84. #define PIN_A6 (0xFF) // NOT_PRESENT
  85. #define PIN_A7 (31) // P0.31 (39) ADC_VBAT
  86. static const uint8_t A0 = PIN_A0;
  87. static const uint8_t A1 = PIN_A1;
  88. static const uint8_t A2 = PIN_A2;
  89. static const uint8_t A3 = PIN_A3;
  90. static const uint8_t A4 = PIN_A4;
  91. static const uint8_t A5 = PIN_A5;
  92. static const uint8_t A6 = PIN_A6;
  93. static const uint8_t A7 = PIN_A7;
  94. #define ADC_RESOLUTION 14
  95. // Other pins
  96. #define PIN_AREF (0xFF) // No analog reference
  97. static const uint8_t AREF = PIN_AREF;
  98. /* Serial interfaces */
  99. #define PIN_GPS_TX (GPS_TX)
  100. #define PIN_GPS_RX (GPS_RX)
  101. #define PIN_GPS_EN (GPS_EN)
  102. #define PIN_SERIAL1_TX (PIN_GPS_TX)
  103. #define PIN_SERIAL1_RX (PIN_GPS_RX)
  104. /* SPI Interfaces */
  105. // unused pins - define anyways
  106. #define SPI_INTERFACES_COUNT 1
  107. #define PIN_SPI_MOSI (9) // P0.09 (13) NC
  108. #define PIN_SPI_MISO (10) // P0.10 (12) NC
  109. #define PIN_SPI_SCK (21) // P0.21 (11) NC
  110. /* I2C Interfaces */
  111. #define WIRE_INTERFACES_COUNT 1
  112. #define PIN_WIRE_SDA (RTC_SDA)
  113. #define PIN_WIRE_SCL (RTC_SCL)
  114. /* QSPI Pins */
  115. // interface occupied by peripherals, define anyways
  116. #define PIN_QSPI_SCK (3) // P0.03 (29) BUZZER
  117. #define PIN_QSPI_CS (26) // P0.26 (34) USER_BUTTON
  118. #define PIN_QSPI_IO0 (30) // P0.30 (33) MCU_SIGNAL
  119. #define PIN_QSPI_IO1 (29) // P0.29 (32) SOFT_SHUTDOWN
  120. #define PIN_QSPI_IO2 (28) // P0.28 (31) BLU_LED_RAK
  121. #define PIN_QSPI_IO3 (2) // P0.02 (30) GPS_PPS
  122. /* On-board QSPI Flash */
  123. // No QSPI (define anyways)
  124. #define EXTERNAL_FLASH_DEVICES IS25LP080D
  125. #define EXTERNAL_FLASH_USE_QSPI
  126. /* Battery */
  127. #define PIN_VBAT_READ (31) // P0.31 (39) ADC_VBAT
  128. #define PIN_BAT_CHG (34) // P1.02 (26) BAT_CHG_STATUS
  129. #define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
  130. // Power management boot protection threshold (millivolts)
  131. // Set to 0 to disable boot protection
  132. // disabled for now until I can figure this out
  133. #define PWRMGT_VOLTAGE_BOOTLOCK 0 // Won't boot below this voltage (mV)
  134. // LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
  135. // AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ
  136. #define PWRMGT_LPCOMP_AIN 5
  137. #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V)
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. /*----------------------------------------------------------------------------
  142. * Arduino objects - C++ only
  143. *----------------------------------------------------------------------------*/
  144. #endif