variant.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. Copyright (c) 2014-2015 Arduino LLC. All right reserved.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. #ifndef _VARIANT_CURRENT_RANGER_NEXTION_
  16. #define _VARIANT_CURRENT_RANGER_NEXTION_
  17. // The definitions here needs a SAMD core >=1.6.10
  18. #define ARDUINO_SAMD_VARIANT_COMPLIANCE 10610
  19. /*----------------------------------------------------------------------------
  20. * Definitions
  21. *----------------------------------------------------------------------------*/
  22. /** Frequency of the board main oscillator */
  23. #define VARIANT_MAINOSC (32768ul)
  24. /** Master clock frequency */
  25. #define VARIANT_MCK (F_CPU)
  26. /*----------------------------------------------------------------------------
  27. * Headers
  28. *----------------------------------------------------------------------------*/
  29. #include "WVariant.h"
  30. #ifdef __cplusplus
  31. #include "SERCOM.h"
  32. #include "Uart.h"
  33. #endif // __cplusplus
  34. #ifdef __cplusplus
  35. extern "C"
  36. {
  37. #endif // __cplusplus
  38. /*----------------------------------------------------------------------------
  39. * Pins
  40. *----------------------------------------------------------------------------*/
  41. // Number of pins defined in PinDescription array
  42. #ifdef __cplusplus
  43. extern "C" unsigned int PINCOUNT_fn();
  44. #endif
  45. #define PINS_COUNT (PINCOUNT_fn())
  46. #define NUM_DIGITAL_PINS (20u)
  47. #define NUM_ANALOG_INPUTS (7u)
  48. #define NUM_ANALOG_OUTPUTS (1u)
  49. #define analogInputToDigitalPin(p) ((p < 6u) ? (p) + 14u : -1)
  50. #define digitalPinToPort(P) ( &(PORT->Group[g_APinDescription[P].ulPort]) )
  51. #define digitalPinToBitMask(P) ( 1 << g_APinDescription[P].ulPin )
  52. //#define analogInPinToBit(P) ( )
  53. #define portOutputRegister(port) ( &(port->OUT.reg) )
  54. #define portInputRegister(port) ( &(port->IN.reg) )
  55. #define portModeRegister(port) ( &(port->DIR.reg) )
  56. #define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
  57. /*
  58. * digitalPinToTimer(..) is AVR-specific and is not defined for SAMD
  59. * architecture. If you need to check if a pin supports PWM you must
  60. * use digitalPinHasPWM(..).
  61. *
  62. * https://github.com/arduino/Arduino/issues/1833
  63. */
  64. // #define digitalPinToTimer(P)
  65. // LEDs
  66. #define PIN_LED_13 (13u)
  67. //#define PIN_LED_RXL (25u)
  68. #define PIN_LED_TXL (26u)
  69. #define PIN_LED PIN_LED_13
  70. //#define PIN_LED2 PIN_LED_RXL
  71. #define PIN_LED3 PIN_LED_TXL
  72. #define LED_BUILTIN PIN_LED_13
  73. #define SS_FLASHMEM (8u)
  74. /*
  75. * Analog pins
  76. */
  77. #define PIN_A0 (14ul)
  78. #define PIN_A1 (15ul)
  79. #define PIN_A2 (16ul)
  80. #define PIN_A3 (17ul)
  81. #define PIN_A4 (18ul)
  82. #define PIN_A5 (19ul)
  83. #define PIN_A6 (25ul)
  84. #define PIN_DAC0 (14ul)
  85. static const uint8_t A0 = PIN_A0;
  86. static const uint8_t A1 = PIN_A1;
  87. static const uint8_t A2 = PIN_A2;
  88. static const uint8_t A3 = PIN_A3;
  89. static const uint8_t A4 = PIN_A4;
  90. static const uint8_t A5 = PIN_A5;
  91. static const uint8_t A6 = PIN_A6;
  92. static const uint8_t DAC0 = PIN_DAC0;
  93. #define ADC_RESOLUTION 12
  94. // Other pins
  95. #define PIN_ATN (38ul)
  96. static const uint8_t ATN = PIN_ATN;
  97. /*
  98. * Serial interfaces
  99. */
  100. // SerialBT
  101. #define PIN_SERIAL0_RX (31ul)
  102. #define PIN_SERIAL0_TX (30ul)
  103. #define PAD_SERIAL0_TX (UART_TX_PAD_2)
  104. #define PAD_SERIAL0_RX (SERCOM_RX_PAD_3)
  105. // Serial1
  106. #define PIN_SERIAL1_RX (0ul)
  107. #define PIN_SERIAL1_TX (1ul)
  108. #define PAD_SERIAL1_TX (UART_TX_PAD_2)
  109. #define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
  110. //Serial2
  111. #define PIN_SERIAL2_RX (21ul)
  112. #define PIN_SERIAL2_TX (20ul)
  113. #define PAD_SERIAL2_TX (UART_TX_PAD_0)
  114. #define PAD_SERIAL2_RX (SERCOM_RX_PAD_1)
  115. /*
  116. * SPI Interfaces
  117. */
  118. #define SPI_INTERFACES_COUNT 1
  119. #define PIN_SPI_MISO (22u)
  120. #define PIN_SPI_MOSI (23u)
  121. #define PIN_SPI_SCK (24u)
  122. #define PERIPH_SPI sercom4
  123. #define PAD_SPI_TX SPI_PAD_2_SCK_3
  124. #define PAD_SPI_RX SERCOM_RX_PAD_0
  125. static const uint8_t SS = PIN_A2 ; // SERCOM4 last PAD is present on A2 but HW SS isn't used. Set here only for reference.
  126. static const uint8_t MOSI = PIN_SPI_MOSI ;
  127. static const uint8_t MISO = PIN_SPI_MISO ;
  128. static const uint8_t SCK = PIN_SPI_SCK ;
  129. /*
  130. * Wire Interfaces
  131. */
  132. #define WIRE_INTERFACES_COUNT 0
  133. /*
  134. #define PIN_WIRE_SDA (20u)
  135. #define PIN_WIRE_SCL (21u)
  136. #define PERIPH_WIRE sercom3
  137. #define WIRE_IT_HANDLER SERCOM3_Handler
  138. static const uint8_t SDA = PIN_WIRE_SDA;
  139. static const uint8_t SCL = PIN_WIRE_SCL;
  140. */
  141. /*
  142. * USB
  143. */
  144. #define PIN_USB_HOST_ENABLE (27ul)
  145. #define PIN_USB_DM (28ul)
  146. #define PIN_USB_DP (29ul)
  147. #define USB_HOST_EN PIN_USB_HOST_ENABLE
  148. #define USB_HOST_ENABLE PIN_USB_HOST_ENABLE
  149. #define PIN_AUTO_OFF PIN_USB_HOST_ENABLE
  150. /*
  151. * I2S Interfaces
  152. */
  153. #define I2S_INTERFACES_COUNT 1
  154. #define I2S_DEVICE 0
  155. #define I2S_CLOCK_GENERATOR 3
  156. #define PIN_I2S_SD (9u)
  157. #define PIN_I2S_SCK (1u)
  158. #define PIN_I2S_FS (0u)
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. /*----------------------------------------------------------------------------
  163. * Arduino objects - C++ only
  164. *----------------------------------------------------------------------------*/
  165. #ifdef __cplusplus
  166. /* =========================
  167. * ===== SERCOM DEFINITION
  168. * =========================
  169. */
  170. extern SERCOM sercom0;
  171. extern SERCOM sercom1;
  172. extern SERCOM sercom2;
  173. extern SERCOM sercom3;
  174. extern SERCOM sercom4;
  175. extern SERCOM sercom5;
  176. extern Uart SerialBT;
  177. extern Uart SerialNextion;
  178. //extern Uart Serial1;
  179. #endif
  180. #ifdef __cplusplus
  181. extern "C" {
  182. #endif
  183. unsigned int PINCOUNT_fn();
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. // These serial port names are intended to allow libraries and architecture-neutral
  188. // sketches to automatically default to the correct port name for a particular type
  189. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  190. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  191. //
  192. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  193. //
  194. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  195. //
  196. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  197. //
  198. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  199. //
  200. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  201. // pins are NOT connected to anything by default.
  202. #define SERIAL_PORT_USBVIRTUAL Serial
  203. #define SerialUSB Serial //for compatibility with v1.4.0 and prior
  204. #define SERIAL_PORT_MONITOR Serial
  205. // Serial has no physical pins broken out, so it's not listed as HARDWARE port
  206. #define SERIAL_PORT_HARDWARE SerialBT
  207. #define SERIAL_PORT_HARDWARE_OPEN SerialBT
  208. #endif