My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

variant.h 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. Copyright (c) 2011 Arduino. 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_ARDUINO_DUE_X_
  16. #define _VARIANT_ARDUINO_DUE_X_
  17. /*----------------------------------------------------------------------------
  18. * Definitions
  19. *----------------------------------------------------------------------------*/
  20. /** Frequency of the board main oscillator */
  21. #define VARIANT_MAINOSC 12000000
  22. /** Master clock frequency */
  23. #define VARIANT_MCK 84000000
  24. /*----------------------------------------------------------------------------
  25. * Headers
  26. *----------------------------------------------------------------------------*/
  27. #include "Arduino.h"
  28. #ifdef __cplusplus
  29. #include "UARTClass.h"
  30. #include "USARTClass.h"
  31. #endif
  32. #ifdef __cplusplus
  33. extern "C"{
  34. #endif // __cplusplus
  35. /**
  36. * Libc porting layers
  37. */
  38. #if defined ( __GNUC__ ) /* GCC CS3 */
  39. # include <syscalls.h> /** RedHat Newlib minimal stub */
  40. #endif
  41. /*----------------------------------------------------------------------------
  42. * Pins
  43. *----------------------------------------------------------------------------*/
  44. // Number of pins defined in PinDescription array
  45. #define PINS_COUNT 79
  46. #define NUM_DIGITAL_PINS 66
  47. #define NUM_ANALOG_INPUTS 12
  48. #define analogInputToDigitalPin(p) ((p < 12) ? (p) + 54 : -1)
  49. #define digitalPinToPort(P) ( g_APinDescription[P].pPort )
  50. #define digitalPinToBitMask(P) ( g_APinDescription[P].ulPin )
  51. //#define analogInPinToBit(P) ( )
  52. #define portOutputRegister(port) ( &(port->PIO_ODSR) )
  53. #define portInputRegister(port) ( &(port->PIO_PDSR) )
  54. #define digitalPinHasPWM(P) ( g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER )
  55. /*
  56. * portModeRegister(..) should return a register to set pin mode
  57. * INPUT or OUTPUT by setting the corresponding bit to 0 or 1.
  58. * Unfortunately on SAM architecture the PIO_OSR register is
  59. * read-only and can be set only through the enable/disable registers
  60. * pair PIO_OER/PIO_ODR.
  61. */
  62. // #define portModeRegister(port) ( &(port->PIO_OSR) )
  63. /*
  64. * digitalPinToTimer(..) is AVR-specific and is not defined for SAM
  65. * architecture. If you need to check if a pin supports PWM you must
  66. * use digitalPinHasPWM(..).
  67. *
  68. * https://github.com/arduino/Arduino/issues/1833
  69. */
  70. // #define digitalPinToTimer(P)
  71. // Interrupts
  72. #define digitalPinToInterrupt(p) ((p) < NUM_DIGITAL_PINS ? (p) : -1)
  73. // LEDs
  74. #define PIN_LED_13 (13U)
  75. #define PIN_LED_RXL (72U)
  76. #define PIN_LED_TXL (73U)
  77. #define PIN_LED PIN_LED_13
  78. #define PIN_LED2 PIN_LED_RXL
  79. #define PIN_LED3 PIN_LED_TXL
  80. #define LED_BUILTIN 13
  81. /*
  82. * SPI Interfaces
  83. */
  84. #define SPI_INTERFACES_COUNT 1
  85. #define SPI_INTERFACE SPI0
  86. #define SPI_INTERFACE_ID ID_SPI0
  87. #define SPI_CHANNELS_NUM 4
  88. #define PIN_SPI_SS0 (77U)
  89. #define PIN_SPI_SS1 (87U)
  90. #define PIN_SPI_SS2 (86U)
  91. #define PIN_SPI_SS3 (78U)
  92. #define PIN_SPI_MOSI (75U)
  93. #define PIN_SPI_MISO (74U)
  94. #define PIN_SPI_SCK (76U)
  95. #define BOARD_SPI_SS0 (77U) //(10U)
  96. #define BOARD_SPI_SS1 (4U)
  97. #define BOARD_SPI_SS2 (52U)
  98. #define BOARD_SPI_SS3 PIN_SPI_SS3
  99. #define BOARD_SPI_DEFAULT_SS BOARD_SPI_SS3
  100. #define BOARD_PIN_TO_SPI_PIN(x) \
  101. (x==BOARD_SPI_SS0 ? PIN_SPI_SS0 : \
  102. (x==BOARD_SPI_SS1 ? PIN_SPI_SS1 : \
  103. (x==BOARD_SPI_SS2 ? PIN_SPI_SS2 : PIN_SPI_SS3 )))
  104. #define BOARD_PIN_TO_SPI_CHANNEL(x) \
  105. (x==BOARD_SPI_SS0 ? 0 : \
  106. (x==BOARD_SPI_SS1 ? 1 : \
  107. (x==BOARD_SPI_SS2 ? 2 : 3)))
  108. static const uint8_t SS = BOARD_SPI_SS0;
  109. static const uint8_t SS1 = BOARD_SPI_SS1;
  110. static const uint8_t SS2 = BOARD_SPI_SS2;
  111. static const uint8_t SS3 = BOARD_SPI_SS3;
  112. static const uint8_t MOSI = PIN_SPI_MOSI;
  113. static const uint8_t MISO = PIN_SPI_MISO;
  114. static const uint8_t SCK = PIN_SPI_SCK;
  115. /*
  116. * Wire Interfaces
  117. */
  118. #define WIRE_INTERFACES_COUNT 2
  119. #define PIN_WIRE_SDA (20U)
  120. #define PIN_WIRE_SCL (21U)
  121. #define WIRE_INTERFACE TWI1
  122. #define WIRE_INTERFACE_ID ID_TWI1
  123. #define WIRE_ISR_HANDLER TWI1_Handler
  124. #define WIRE_ISR_ID TWI1_IRQn
  125. #define PIN_WIRE1_SDA (70U)
  126. #define PIN_WIRE1_SCL (71U)
  127. #define WIRE1_INTERFACE TWI0
  128. #define WIRE1_INTERFACE_ID ID_TWI0
  129. #define WIRE1_ISR_HANDLER TWI0_Handler
  130. #define WIRE1_ISR_ID TWI0_IRQn
  131. static const uint8_t SDA = PIN_WIRE_SDA;
  132. static const uint8_t SCL = PIN_WIRE_SCL;
  133. static const uint8_t SDA1 = PIN_WIRE1_SDA;
  134. static const uint8_t SCL1 = PIN_WIRE1_SCL;
  135. /*
  136. * UART/USART Interfaces
  137. */
  138. // Serial
  139. #define PINS_UART (81U)
  140. // Serial1
  141. #define PINS_USART0 (82U)
  142. // Serial2
  143. #define PINS_USART1 (83U)
  144. // Serial3
  145. #define PINS_USART3 (84U)
  146. /*
  147. * USB Interfaces
  148. */
  149. #define PINS_USB (85U)
  150. /*
  151. * Analog pins
  152. */
  153. static const uint8_t A0 = 54;
  154. static const uint8_t A1 = 55;
  155. static const uint8_t A2 = 56;
  156. static const uint8_t A3 = 57;
  157. static const uint8_t A4 = 58;
  158. static const uint8_t A5 = 59;
  159. static const uint8_t A6 = 60;
  160. static const uint8_t A7 = 61;
  161. static const uint8_t A8 = 62;
  162. static const uint8_t A9 = 63;
  163. static const uint8_t A10 = 64;
  164. static const uint8_t A11 = 65;
  165. static const uint8_t DAC0 = 66;
  166. static const uint8_t DAC1 = 67;
  167. static const uint8_t CANRX = 68;
  168. static const uint8_t CANTX = 69;
  169. #define ADC_RESOLUTION 12
  170. /*
  171. * Complementary CAN pins
  172. */
  173. static const uint8_t CAN1RX = 88;
  174. static const uint8_t CAN1TX = 89;
  175. // CAN0
  176. #define PINS_CAN0 (90U)
  177. // CAN1
  178. #define PINS_CAN1 (91U)
  179. /*
  180. * DACC
  181. */
  182. #define DACC_INTERFACE DACC
  183. #define DACC_INTERFACE_ID ID_DACC
  184. #define DACC_RESOLUTION 12
  185. #define DACC_ISR_HANDLER DACC_Handler
  186. #define DACC_ISR_ID DACC_IRQn
  187. /*
  188. * PWM
  189. */
  190. #define PWM_INTERFACE PWM
  191. #define PWM_INTERFACE_ID ID_PWM
  192. #define PWM_FREQUENCY 31000
  193. #define PWM_MAX_DUTY_CYCLE 255
  194. #define PWM_MIN_DUTY_CYCLE 0
  195. #define PWM_RESOLUTION 8
  196. /*
  197. * TC
  198. */
  199. #define TC_INTERFACE TC0
  200. #define TC_INTERFACE_ID ID_TC0
  201. #define TC_FREQUENCY 100000
  202. #define TC_MAX_DUTY_CYCLE 255
  203. #define TC_MIN_DUTY_CYCLE 0
  204. #define TC_RESOLUTION 8
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208. /*----------------------------------------------------------------------------
  209. * Arduino objects - C++ only
  210. *----------------------------------------------------------------------------*/
  211. #ifdef __cplusplus
  212. extern UARTClass Serial;
  213. extern USARTClass Serial1;
  214. extern USARTClass Serial2;
  215. extern USARTClass Serial3;
  216. #endif
  217. // These serial port names are intended to allow libraries and architecture-neutral
  218. // sketches to automatically default to the correct port name for a particular type
  219. // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
  220. // the first hardware serial port whose RX/TX pins are not dedicated to another use.
  221. //
  222. // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
  223. //
  224. // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
  225. //
  226. // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
  227. //
  228. // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
  229. //
  230. // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
  231. // pins are NOT connected to anything by default.
  232. #define SERIAL_PORT_MONITOR Serial
  233. #define SERIAL_PORT_USBVIRTUAL SerialUSB
  234. #define SERIAL_PORT_HARDWARE_OPEN Serial1
  235. #define SERIAL_PORT_HARDWARE_OPEN1 Serial2
  236. #define SERIAL_PORT_HARDWARE_OPEN2 Serial3
  237. #define SERIAL_PORT_HARDWARE Serial
  238. #define SERIAL_PORT_HARDWARE1 Serial1
  239. #define SERIAL_PORT_HARDWARE2 Serial2
  240. #define SERIAL_PORT_HARDWARE3 Serial3
  241. #endif /* _VARIANT_ARDUINO_DUE_X_ */