variant.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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_RAK4630_
  18. #define _VARIANT_RAK4630_
  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. /*
  33. * WisBlock Base GPIO definitions
  34. */
  35. static const uint8_t WB_IO1 = 17; // SLOT_A SLOT_B
  36. static const uint8_t WB_IO2 = 34; // SLOT_A SLOT_B
  37. static const uint8_t WB_IO3 = 21; // SLOT_C
  38. static const uint8_t WB_IO4 = 4; // SLOT_C
  39. static const uint8_t WB_IO5 = 9; // SLOT_D
  40. static const uint8_t WB_IO6 = 10; // SLOT_D
  41. static const uint8_t WB_SW1 = 33; // IO_SLOT
  42. static const uint8_t WB_A0 = 5; // IO_SLOT
  43. static const uint8_t WB_A1 = 31; // IO_SLOT
  44. static const uint8_t WB_I2C1_SDA = 13; // SENSOR_SLOT IO_SLOT
  45. static const uint8_t WB_I2C1_SCL = 14; // SENSOR_SLOT IO_SLOT
  46. static const uint8_t WB_I2C2_SDA = 24; // IO_SLOT
  47. static const uint8_t WB_I2C2_SCL = 25; // IO_SLOT
  48. static const uint8_t WB_SPI_CS = 26; // IO_SLOT
  49. static const uint8_t WB_SPI_CLK = 3; // IO_SLOT
  50. static const uint8_t WB_SPI_MISO = 29; // IO_SLOT
  51. static const uint8_t WB_SPI_MOSI = 30; // IO_SLOT
  52. // Number of pins defined in PinDescription array
  53. #define PINS_COUNT (48)
  54. #define NUM_DIGITAL_PINS (48)
  55. #define NUM_ANALOG_INPUTS (6)
  56. #define NUM_ANALOG_OUTPUTS (0)
  57. // LEDs
  58. #define PIN_LED1 (35)
  59. #define PIN_LED2 (36)
  60. #define LED_BUILTIN PIN_LED1
  61. #define LED_CONN PIN_LED2
  62. #define LED_GREEN PIN_LED1
  63. #define LED_BLUE PIN_LED2
  64. #define LED_STATE_ON 1 // State when LED is litted
  65. // #define P_LORA_TX_LED LED_GREEN
  66. /*
  67. * Buttons
  68. */
  69. #define PIN_BUTTON1 (9) // Menu / User Button
  70. #define PIN_BACK_BTN PIN_BUTTON1
  71. #define PIN_USER_BTN PIN_BUTTON1
  72. // Analog pins
  73. #define PIN_VBAT_READ (5)
  74. #define ADC_MULTIPLIER (3 * 1.75 * 1.187 * 1000)
  75. /*
  76. * Analog pins
  77. */
  78. #define PIN_A0 (5) //(3)
  79. #define PIN_A1 (31) //(4)
  80. #define PIN_A2 (28)
  81. #define PIN_A3 (29)
  82. #define PIN_A4 (30)
  83. #define PIN_A5 (31)
  84. #define PIN_A6 (0xff)
  85. #define PIN_A7 (0xff)
  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. // Power management boot protection threshold (millivolts)
  96. // Set to 0 to disable boot protection
  97. #define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV)
  98. // LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
  99. // AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ
  100. #define PWRMGT_LPCOMP_AIN 3
  101. #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V)
  102. // Other pins
  103. #define PIN_AREF (2)
  104. #define PIN_NFC1 (9)
  105. #define PIN_NFC2 (10)
  106. static const uint8_t AREF = PIN_AREF;
  107. /*
  108. * Serial interfaces
  109. */
  110. // TXD1 RXD1 on Base Board
  111. #define PIN_SERIAL1_RX (15)
  112. #define PIN_SERIAL1_TX (16)
  113. // TXD0 RXD0 on Base Board
  114. #define PIN_SERIAL2_RX (19)
  115. #define PIN_SERIAL2_TX (20)
  116. /*
  117. * SPI Interfaces
  118. */
  119. #define SPI_INTERFACES_COUNT 1
  120. #define PIN_SPI_MISO (29)
  121. #define PIN_SPI_MOSI (30)
  122. #define PIN_SPI_SCK (3)
  123. static const uint8_t SS = 26;
  124. static const uint8_t MOSI = PIN_SPI_MOSI;
  125. static const uint8_t MISO = PIN_SPI_MISO;
  126. static const uint8_t SCK = PIN_SPI_SCK;
  127. // LoRa radio module pins for RAK4631
  128. #define SX126X_POWER_EN (37)
  129. #define P_LORA_RESET (38)
  130. #define P_LORA_NSS (42)
  131. #define P_LORA_SCLK (43)
  132. #define P_LORA_MOSI (44)
  133. #define P_LORA_MISO (45)
  134. #define P_LORA_BUSY (46)
  135. #define P_LORA_DIO_1 (47)
  136. #define SX126X_DIO2_AS_RF_SWITCH true
  137. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  138. /*
  139. * Wire Interfaces
  140. */
  141. #define WIRE_INTERFACES_COUNT 2
  142. #define PIN_WIRE_SDA (13)
  143. #define PIN_WIRE_SCL (14)
  144. #define PIN_WIRE1_SDA (24)
  145. #define PIN_WIRE1_SCL (25)
  146. // QSPI Pins
  147. // QSPI occupied by GPIO's
  148. #define PIN_QSPI_SCK 3 // 19
  149. #define PIN_QSPI_CS 26 // 17
  150. #define PIN_QSPI_IO0 30 // 20
  151. #define PIN_QSPI_IO1 29 // 21
  152. #define PIN_QSPI_IO2 28 // 22
  153. #define PIN_QSPI_IO3 2 // 23
  154. // On-board QSPI Flash
  155. // No onboard flash
  156. #define EXTERNAL_FLASH_DEVICES IS25LP080D
  157. #define EXTERNAL_FLASH_USE_QSPI
  158. #define GPS_ADDRESS 0x42 //i2c address for GPS
  159. // GPS L76KB
  160. #define GPS_BAUD_RATE 9600
  161. #define GPS_THREAD_INTERVAL 50
  162. #define PIN_GPS_TX PIN_SERIAL1_RX
  163. #define PIN_GPS_RX PIN_SERIAL1_TX
  164. #define PIN_GPS_EN (33)
  165. #define PIN_GPS_PPS (17)
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. /*----------------------------------------------------------------------------
  170. * Arduino objects - C++ only
  171. *----------------------------------------------------------------------------*/
  172. #endif