variant.h 6.3 KB

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