variant.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. // Other pins
  66. #define WB_I2C1_SDA (13) // SENSOR_SLOT IO_SLOT
  67. #define WB_I2C1_SCL (14) // SENSOR_SLOT IO_SLOT
  68. #define PIN_AREF (2)
  69. #define PIN_NFC1 (9)
  70. #define WB_IO5 PIN_NFC1
  71. #define WB_IO4 (4)
  72. #define PIN_NFC2 (10)
  73. static const uint8_t AREF = PIN_AREF;
  74. /*
  75. * Serial interfaces
  76. */
  77. // TXD1 RXD1 on Base Board
  78. #define PIN_SERIAL1_RX (15)
  79. #define PIN_SERIAL1_TX (16)
  80. // Connected to Jlink CDC
  81. #define PIN_SERIAL2_RX (8)
  82. #define PIN_SERIAL2_TX (6)
  83. /*
  84. * SPI Interfaces
  85. */
  86. #define SPI_INTERFACES_COUNT 2
  87. #define PIN_SPI_MISO (45)
  88. #define PIN_SPI_MOSI (44)
  89. #define PIN_SPI_SCK (43)
  90. #define PIN_SPI1_MISO (29)
  91. #define PIN_SPI1_MOSI (30)
  92. #define PIN_SPI1_SCK (3)
  93. static const uint8_t SS = 42;
  94. static const uint8_t MOSI = PIN_SPI_MOSI;
  95. static const uint8_t MISO = PIN_SPI_MISO;
  96. static const uint8_t SCK = PIN_SPI_SCK;
  97. /*
  98. * Wire Interfaces
  99. */
  100. #define WIRE_INTERFACES_COUNT 1
  101. #define PIN_WIRE_SDA (WB_I2C1_SDA)
  102. #define PIN_WIRE_SCL (WB_I2C1_SCL)
  103. // QSPI Pins
  104. // QSPI occupied by GPIO's
  105. #define PIN_QSPI_SCK 3
  106. #define PIN_QSPI_CS 26
  107. #define PIN_QSPI_IO0 30
  108. #define PIN_QSPI_IO1 29
  109. #define PIN_QSPI_IO2 28
  110. #define PIN_QSPI_IO3 2
  111. // On-board QSPI Flash
  112. // No onboard flash
  113. #define EXTERNAL_FLASH_DEVICES IS25LP080D
  114. #define EXTERNAL_FLASH_USE_QSPI
  115. #define P_LORA_SCK PIN_SPI1_SCK
  116. #define P_LORA_MISO PIN_SPI1_MISO
  117. #define P_LORA_MOSI PIN_SPI1_MOSI
  118. #define P_LORA_CS 26
  119. #define USE_SX1262
  120. #define SX126X_CS (26)
  121. #define SX126X_DIO1 (10)
  122. #define SX126X_BUSY (9)
  123. #define SX126X_RESET (4)
  124. #define SX126X_POWER_EN (21)
  125. // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
  126. #define SX126X_DIO2_AS_RF_SWITCH
  127. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  128. // enables 3.3V periphery like GPS or IO Module
  129. // Do not toggle this for GPS power savings
  130. #define PIN_3V3_EN (34)
  131. #define WB_IO2 PIN_3V3_EN
  132. // RAK1910 GPS module
  133. // If using the wisblock GPS module and pluged into Port A on WisBlock base
  134. // IO1 is hooked to PPS (pin 12 on header) = gpio 17
  135. // 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).
  136. // Therefore must be 1 to keep peripherals powered
  137. // Power is on the controllable 3V3_S rail
  138. #define PIN_GPS_PPS (17) // Pulse per second input from the GPS
  139. #define PIN_GPS_RX PIN_SERIAL1_RX
  140. #define PIN_GPS_TX PIN_SERIAL1_TX
  141. // Battery
  142. // The battery sense is hooked to pin A0 (5)
  143. #define BATTERY_PIN PIN_A0
  144. // and has 12 bit resolution
  145. #define BATTERY_SENSE_RESOLUTION_BITS 12
  146. #define BATTERY_SENSE_RESOLUTION 4096.0
  147. #undef AREF_VOLTAGE
  148. #define AREF_VOLTAGE 3.0
  149. #define VBAT_AR_INTERNAL AR_INTERNAL_3_0
  150. #define ADC_MULTIPLIER 1.73
  151. #define HAS_RTC 1
  152. #define RAK_4631 1
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156. /*----------------------------------------------------------------------------
  157. * Arduino objects - C++ only
  158. *----------------------------------------------------------------------------*/
  159. #endif