variant.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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_BUTTON2 (28) // Joystick Up
  71. #define PIN_BUTTON3 (4) // Joystick Down
  72. #define PIN_BUTTON4 (30) // Joystick Left
  73. #define PIN_BUTTON5 (31) // Joystick Right
  74. #define PIN_BUTTON6 (26) // Joystick Press
  75. #define PIN_BACK_BTN PIN_BUTTON1
  76. #define JOYSTICK_UP PIN_BUTTON2
  77. #define JOYSTICK_DOWN PIN_BUTTON3
  78. #define JOYSTICK_LEFT PIN_BUTTON4
  79. #define JOYSTICK_RIGHT PIN_BUTTON5
  80. #define JOYSTICK_PRESS PIN_BUTTON6
  81. #define PIN_USER_BTN PIN_BUTTON6
  82. // Analog pins
  83. #define PIN_VBAT_READ (5)
  84. #define ADC_MULTIPLIER (3 * 1.75 * 1.187 * 1000)
  85. /*
  86. * Analog pins
  87. */
  88. #define PIN_A0 (5) //(3)
  89. #define PIN_A1 (31) //(4)
  90. #define PIN_A2 (28)
  91. #define PIN_A3 (29)
  92. #define PIN_A4 (30)
  93. #define PIN_A5 (31)
  94. #define PIN_A6 (0xff)
  95. #define PIN_A7 (0xff)
  96. static const uint8_t A0 = PIN_A0;
  97. static const uint8_t A1 = PIN_A1;
  98. static const uint8_t A2 = PIN_A2;
  99. static const uint8_t A3 = PIN_A3;
  100. static const uint8_t A4 = PIN_A4;
  101. static const uint8_t A5 = PIN_A5;
  102. static const uint8_t A6 = PIN_A6;
  103. static const uint8_t A7 = PIN_A7;
  104. #define ADC_RESOLUTION 14
  105. // Power management boot protection threshold (millivolts)
  106. // Set to 0 to disable boot protection
  107. #define PWRMGT_VOLTAGE_BOOTLOCK 3300 // Won't boot below this voltage (mV)
  108. // LPCOMP wake configuration (voltage recovery from SYSTEMOFF)
  109. // AIN3 = P0.05 = PIN_A0 / PIN_VBAT_READ
  110. #define PWRMGT_LPCOMP_AIN 3
  111. #define PWRMGT_LPCOMP_REFSEL 4 // 5/8 VDD (~3.13-3.44V)
  112. // Other pins
  113. #define PIN_AREF (2)
  114. #define PIN_NFC1 (9)
  115. #define PIN_NFC2 (10)
  116. static const uint8_t AREF = PIN_AREF;
  117. /*
  118. * Serial interfaces
  119. */
  120. // TXD1 RXD1 on Base Board
  121. #define PIN_SERIAL1_RX (15)
  122. #define PIN_SERIAL1_TX (16)
  123. // TXD0 RXD0 on Base Board
  124. #define PIN_SERIAL2_RX (19)
  125. #define PIN_SERIAL2_TX (20)
  126. /*
  127. * SPI Interfaces
  128. */
  129. #define SPI_INTERFACES_COUNT 1
  130. #define PIN_SPI_MISO (29)
  131. #define PIN_SPI_MOSI (30)
  132. #define PIN_SPI_SCK (3)
  133. static const uint8_t SS = 26;
  134. static const uint8_t MOSI = PIN_SPI_MOSI;
  135. static const uint8_t MISO = PIN_SPI_MISO;
  136. static const uint8_t SCK = PIN_SPI_SCK;
  137. // LoRa radio module pins for RAK4631
  138. #define SX126X_POWER_EN (37)
  139. #define P_LORA_RESET (38)
  140. #define P_LORA_NSS (42)
  141. #define P_LORA_SCLK (43)
  142. #define P_LORA_MOSI (44)
  143. #define P_LORA_MISO (45)
  144. #define P_LORA_BUSY (46)
  145. #define P_LORA_DIO_1 (47)
  146. #define SX126X_DIO2_AS_RF_SWITCH true
  147. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  148. /*
  149. * Wire Interfaces
  150. */
  151. #define WIRE_INTERFACES_COUNT 2
  152. #define PIN_WIRE_SDA (13)
  153. #define PIN_WIRE_SCL (14)
  154. #define PIN_WIRE1_SDA (24)
  155. #define PIN_WIRE1_SCL (25)
  156. // QSPI Pins
  157. // QSPI occupied by GPIO's
  158. #define PIN_QSPI_SCK 3 // 19
  159. #define PIN_QSPI_CS 26 // 17
  160. #define PIN_QSPI_IO0 30 // 20
  161. #define PIN_QSPI_IO1 29 // 21
  162. #define PIN_QSPI_IO2 28 // 22
  163. #define PIN_QSPI_IO3 2 // 23
  164. // On-board QSPI Flash
  165. // No onboard flash
  166. #define EXTERNAL_FLASH_DEVICES IS25LP080D
  167. #define EXTERNAL_FLASH_USE_QSPI
  168. #define GPS_ADDRESS 0x42 //i2c address for GPS
  169. // GPS L76KB
  170. #define GPS_BAUD_RATE 9600
  171. #define GPS_THREAD_INTERVAL 50
  172. #define PIN_GPS_TX PIN_SERIAL1_RX
  173. #define PIN_GPS_RX PIN_SERIAL1_TX
  174. #define PIN_GPS_EN (33)
  175. #define PIN_GPS_PPS (17)
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. /*----------------------------------------------------------------------------
  180. * Arduino objects - C++ only
  181. *----------------------------------------------------------------------------*/
  182. #endif