variant.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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_RAK3401_
  18. #define _VARIANT_RAK3401_
  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 (6)
  36. #define NUM_ANALOG_OUTPUTS (0)
  37. // LEDs
  38. #define PIN_LED1 (35)
  39. #define PIN_LED2 (36)
  40. #define LED_BUILTIN PIN_LED1
  41. #define LED_CONN PIN_LED2
  42. #define LED_GREEN PIN_LED1
  43. #define LED_BLUE PIN_LED2
  44. #define LED_STATE_ON 1 // State when LED is litted
  45. /*
  46. * Analog pins
  47. */
  48. #define PIN_A0 (5) //(3)
  49. #define PIN_A1 (31) //(4)
  50. #define PIN_A2 (28)
  51. #define PIN_A3 (29)
  52. #define PIN_A4 (30)
  53. #define PIN_A5 (31)
  54. #define PIN_A6 (0xff)
  55. #define PIN_A7 (0xff)
  56. static const uint8_t A0 = PIN_A0;
  57. static const uint8_t A1 = PIN_A1;
  58. static const uint8_t A2 = PIN_A2;
  59. static const uint8_t A3 = PIN_A3;
  60. static const uint8_t A4 = PIN_A4;
  61. static const uint8_t A5 = PIN_A5;
  62. static const uint8_t A6 = PIN_A6;
  63. static const uint8_t A7 = PIN_A7;
  64. #define ADC_RESOLUTION 14
  65. // Power management boot protection threshold (millivolts)
  66. // Set to 0 to disable boot protection
  67. #define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV)
  68. // LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
  69. // AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ
  70. #define PWRMGT_LPCOMP_AIN 3
  71. #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V)
  72. // Other pins
  73. #define WB_I2C1_SDA (13) // SENSOR_SLOT IO_SLOT
  74. #define WB_I2C1_SCL (14) // SENSOR_SLOT IO_SLOT
  75. #define PIN_AREF (2)
  76. #define PIN_NFC1 (9)
  77. #define WB_IO5 PIN_NFC1
  78. #define WB_IO4 (4)
  79. #define PIN_NFC2 (10)
  80. static const uint8_t AREF = PIN_AREF;
  81. /*
  82. * Serial interfaces
  83. */
  84. // TXD1 RXD1 on Base Board
  85. #define PIN_SERIAL1_RX (15)
  86. #define PIN_SERIAL1_TX (16)
  87. // Connected to Jlink CDC
  88. #define PIN_SERIAL2_RX (8)
  89. #define PIN_SERIAL2_TX (6)
  90. /*
  91. * SPI Interfaces
  92. */
  93. #define SPI_INTERFACES_COUNT 2
  94. #define PIN_SPI_MISO (45)
  95. #define PIN_SPI_MOSI (44)
  96. #define PIN_SPI_SCK (43)
  97. #define PIN_SPI1_MISO (29)
  98. #define PIN_SPI1_MOSI (30)
  99. #define PIN_SPI1_SCK (3)
  100. static const uint8_t SS = 42;
  101. static const uint8_t MOSI = PIN_SPI_MOSI;
  102. static const uint8_t MISO = PIN_SPI_MISO;
  103. static const uint8_t SCK = PIN_SPI_SCK;
  104. /*
  105. * Wire Interfaces
  106. */
  107. #define WIRE_INTERFACES_COUNT 1
  108. #define PIN_WIRE_SDA (WB_I2C1_SDA)
  109. #define PIN_WIRE_SCL (WB_I2C1_SCL)
  110. // QSPI Pins
  111. // QSPI occupied by GPIO's
  112. #define PIN_QSPI_SCK 3
  113. #define PIN_QSPI_CS 26
  114. #define PIN_QSPI_IO0 30
  115. #define PIN_QSPI_IO1 29
  116. #define PIN_QSPI_IO2 28
  117. #define PIN_QSPI_IO3 2
  118. // On-board QSPI Flash
  119. // No onboard flash
  120. #define EXTERNAL_FLASH_DEVICES IS25LP080D
  121. #define EXTERNAL_FLASH_USE_QSPI
  122. #define USE_SX1262
  123. #define SX126X_CS (26)
  124. #define SX126X_DIO1 (10)
  125. #define SX126X_BUSY (9)
  126. #define SX126X_RESET (4)
  127. // SKY66122-11 FEM control on the RAK13302 module:
  128. // CSD + CPS are tied together on the PCB, routed to WisBlock IO3 (P0.21).
  129. // Setting IO3 HIGH enables the FEM (LNA for RX, PA path for TX).
  130. // CTX is connected to SX1262 DIO2 — the radio handles TX/RX switching
  131. // in hardware via SetDIO2AsRfSwitchCtrl (microsecond-accurate, no GPIO needed).
  132. // The 5V boost for the PA is enabled by WB_IO2 (P0.34 = PIN_3V3_EN).
  133. #define SX126X_POWER_EN (21) // P0.21 = IO3 -> SKY66122 CSD+CPS (FEM enable)
  134. // CTX is driven by SX1262 DIO2, not a GPIO
  135. #define SX126X_DIO2_AS_RF_SWITCH
  136. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  137. #define P_LORA_SCLK PIN_SPI1_SCK
  138. #define P_LORA_MISO PIN_SPI1_MISO
  139. #define P_LORA_MOSI PIN_SPI1_MOSI
  140. #define P_LORA_NSS SX126X_CS
  141. #define P_LORA_DIO_1 SX126X_DIO1
  142. #define P_LORA_BUSY SX126X_BUSY
  143. #define P_LORA_RESET SX126X_RESET
  144. // enables 3.3V periphery like GPS or IO Module
  145. // Do not toggle this for GPS power savings
  146. #define PIN_3V3_EN (34)
  147. #define WB_IO2 PIN_3V3_EN
  148. // RAK1910 GPS module
  149. // If using the wisblock GPS module and pluged into Port A on WisBlock base
  150. // IO1 is hooked to PPS (pin 12 on header) = gpio 17
  151. // IO2 is hooked to GPS RESET = gpio 34, but it can not be used to this because IO2 is ALSO used to control 3V3_S power (1 is on).
  152. // Therefore must be 1 to keep peripherals powered
  153. // Power is on the controllable 3V3_S rail
  154. #define PIN_GPS_PPS (17) // Pulse per second input from the GPS
  155. #define PIN_GPS_RX PIN_SERIAL1_RX
  156. #define PIN_GPS_TX PIN_SERIAL1_TX
  157. #define PIN_GPS_1PPS PIN_GPS_PPS
  158. #define GPS_BAUD_RATE 9600
  159. #define GPS_ADDRESS 0x42 //i2c address for GPS
  160. // Battery
  161. // The battery sense is hooked to pin A0 (5)
  162. #define BATTERY_PIN PIN_A0
  163. // and has 12 bit resolution
  164. #define BATTERY_SENSE_RESOLUTION_BITS 12
  165. #define BATTERY_SENSE_RESOLUTION 4096.0
  166. #undef AREF_VOLTAGE
  167. #define AREF_VOLTAGE 3.0
  168. #define VBAT_AR_INTERNAL AR_INTERNAL_3_0
  169. #define ADC_MULTIPLIER 1.73
  170. #define HAS_RTC 1
  171. #define RAK_4631 1
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. /*----------------------------------------------------------------------------
  176. * Arduino objects - C++ only
  177. *----------------------------------------------------------------------------*/
  178. #endif