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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  5. * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #pragma once
  22. #define CPU_32_BIT
  23. #include "../shared/Marduino.h"
  24. #include "../shared/math_32bit.h"
  25. #include "../shared/HAL_SPI.h"
  26. #include "fastio.h"
  27. #include "watchdog.h"
  28. #ifdef ADAFRUIT_GRAND_CENTRAL_M4
  29. #include "MarlinSerial_AGCM4.h"
  30. // Serial ports
  31. // MYSERIAL0 required before MarlinSerial includes!
  32. #if SERIAL_PORT == -1
  33. #define MYSERIAL0 Serial
  34. #elif SERIAL_PORT == 0
  35. #define MYSERIAL0 Serial1
  36. #elif SERIAL_PORT == 1
  37. #define MYSERIAL0 Serial2
  38. #elif SERIAL_PORT == 2
  39. #define MYSERIAL0 Serial3
  40. #elif SERIAL_PORT == 3
  41. #define MYSERIAL0 Serial4
  42. #else
  43. #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
  44. #endif
  45. #ifdef SERIAL_PORT_2
  46. #if SERIAL_PORT_2 == SERIAL_PORT
  47. #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
  48. #elif SERIAL_PORT_2 == -1
  49. #define MYSERIAL1 Serial
  50. #elif SERIAL_PORT_2 == 0
  51. #define MYSERIAL1 Serial1
  52. #elif SERIAL_PORT_2 == 1
  53. #define MYSERIAL1 Serial2
  54. #elif SERIAL_PORT_2 == 2
  55. #define MYSERIAL1 Serial3
  56. #elif SERIAL_PORT_2 == 3
  57. #define MYSERIAL1 Serial4
  58. #else
  59. #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
  60. #endif
  61. #define NUM_SERIAL 2
  62. #else
  63. #define NUM_SERIAL 1
  64. #endif
  65. #ifdef DGUS_SERIAL_PORT
  66. #if DGUS_SERIAL_PORT == SERIAL_PORT
  67. #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
  68. #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
  69. #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
  70. #elif DGUS_SERIAL_PORT == -1
  71. #define DGUS_SERIAL Serial
  72. #elif DGUS_SERIAL_PORT == 0
  73. #define DGUS_SERIAL Serial1
  74. #elif DGUS_SERIAL_PORT == 1
  75. #define DGUS_SERIAL Serial2
  76. #elif DGUS_SERIAL_PORT == 2
  77. #define DGUS_SERIAL Serial3
  78. #elif DGUS_SERIAL_PORT == 2
  79. #define DGUS_SERIAL Serial4
  80. #else
  81. #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
  82. #endif
  83. #endif
  84. #endif // ADAFRUIT_GRAND_CENTRAL_M4
  85. typedef int8_t pin_t;
  86. #define SHARED_SERVOS HAS_SERVOS
  87. #define HAL_SERVO_LIB Servo
  88. //
  89. // Interrupts
  90. //
  91. #define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
  92. #define CRITICAL_SECTION_END() if (!primask) __enable_irq()
  93. #define ISRS_ENABLED() (!__get_PRIMASK())
  94. #define ENABLE_ISRS() __enable_irq()
  95. #define DISABLE_ISRS() __disable_irq()
  96. #define cli() __disable_irq() // Disable interrupts
  97. #define sei() __enable_irq() // Enable interrupts
  98. void HAL_clear_reset_source(); // clear reset reason
  99. uint8_t HAL_get_reset_source(); // get reset reason
  100. //
  101. // ADC
  102. //
  103. extern uint16_t HAL_adc_result; // Most recent ADC conversion
  104. #define HAL_ANALOG_SELECT(pin)
  105. void HAL_adc_init();
  106. //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values.
  107. #define HAL_ADC_VREF 3.3
  108. #define HAL_ADC_RESOLUTION 10 // ... 12
  109. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  110. #define HAL_READ_ADC() HAL_adc_result
  111. #define HAL_ADC_READY() true
  112. void HAL_adc_start_conversion(const uint8_t adc_pin);
  113. //
  114. // Pin Map
  115. //
  116. #define GET_PIN_MAP_PIN(index) index
  117. #define GET_PIN_MAP_INDEX(pin) pin
  118. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
  119. //
  120. // Tone
  121. //
  122. void toneInit();
  123. void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
  124. void noTone(const pin_t _pin);
  125. // Enable hooks into idle and setup for HAL
  126. void HAL_init();
  127. /*
  128. #define HAL_IDLETASK 1
  129. void HAL_idletask();
  130. */
  131. //
  132. // Utility functions
  133. //
  134. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  135. #pragma GCC diagnostic push
  136. #pragma GCC diagnostic ignored "-Wunused-function"
  137. int freeMemory();
  138. #pragma GCC diagnostic pop
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142. char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
  143. #ifdef __cplusplus
  144. }
  145. #endif