My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2019 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 <http://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. #include "timers.h"
  29. #ifdef ADAFRUIT_GRAND_CENTRAL_M4
  30. #include "MarlinSerial_AGCM4.h"
  31. // Serial ports
  32. // MYSERIAL0 required before MarlinSerial includes!
  33. #if SERIAL_PORT == -1
  34. #define MYSERIAL0 Serial
  35. #elif SERIAL_PORT == 0
  36. #define MYSERIAL0 Serial1
  37. #elif SERIAL_PORT == 1
  38. #define MYSERIAL0 Serial2
  39. #elif SERIAL_PORT == 2
  40. #define MYSERIAL0 Serial3
  41. #elif SERIAL_PORT == 3
  42. #define MYSERIAL0 Serial4
  43. #else
  44. #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
  45. #endif
  46. #ifdef SERIAL_PORT_2
  47. #if SERIAL_PORT_2 == SERIAL_PORT
  48. #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
  49. #elif SERIAL_PORT_2 == -1
  50. #define MYSERIAL1 Serial
  51. #elif SERIAL_PORT_2 == 0
  52. #define MYSERIAL1 Serial1
  53. #elif SERIAL_PORT_2 == 1
  54. #define MYSERIAL1 Serial2
  55. #elif SERIAL_PORT_2 == 2
  56. #define MYSERIAL1 Serial3
  57. #elif SERIAL_PORT_2 == 3
  58. #define MYSERIAL1 Serial4
  59. #else
  60. #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
  61. #endif
  62. #define NUM_SERIAL 2
  63. #else
  64. #define NUM_SERIAL 1
  65. #endif
  66. #ifdef DGUS_SERIAL_PORT
  67. #if DGUS_SERIAL_PORT == SERIAL_PORT
  68. #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
  69. #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
  70. #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
  71. #elif DGUS_SERIAL_PORT == -1
  72. #define DGUS_SERIAL Serial
  73. #elif DGUS_SERIAL_PORT == 0
  74. #define DGUS_SERIAL Serial1
  75. #elif DGUS_SERIAL_PORT == 1
  76. #define DGUS_SERIAL Serial2
  77. #elif DGUS_SERIAL_PORT == 2
  78. #define DGUS_SERIAL Serial3
  79. #elif DGUS_SERIAL_PORT == 2
  80. #define DGUS_SERIAL Serial4
  81. #else
  82. #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
  83. #endif
  84. #endif
  85. #endif // ADAFRUIT_GRAND_CENTRAL_M4
  86. typedef int8_t pin_t;
  87. #define SHARED_SERVOS HAS_SERVOS
  88. #define HAL_SERVO_LIB Servo
  89. //
  90. // Interrupts
  91. //
  92. #define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
  93. #define CRITICAL_SECTION_END if (!primask) __enable_irq()
  94. #define ISRS_ENABLED() (!__get_PRIMASK())
  95. #define ENABLE_ISRS() __enable_irq()
  96. #define DISABLE_ISRS() __disable_irq()
  97. #define cli() __disable_irq() // Disable interrupts
  98. #define sei() __enable_irq() // Enable interrupts
  99. void HAL_clear_reset_source(); // clear reset reason
  100. uint8_t HAL_get_reset_source(); // get reset reason
  101. //
  102. // EEPROM
  103. //
  104. void eeprom_write_byte(uint8_t *pos, unsigned char value);
  105. uint8_t eeprom_read_byte(uint8_t *pos);
  106. //
  107. // ADC
  108. //
  109. extern uint16_t HAL_adc_result; // result of last ADC conversion
  110. #define HAL_ANALOG_SELECT(pin)
  111. void HAL_adc_init();
  112. #define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL
  113. #define HAL_ADC_RESOLUTION 12
  114. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  115. #define HAL_READ_ADC() HAL_adc_result
  116. #define HAL_ADC_READY() true
  117. void HAL_adc_start_conversion(const uint8_t adc_pin);
  118. inline uint16_t HAL_adc_get_result() { return HAL_adc_result; }
  119. //
  120. // Pin Map
  121. //
  122. #define GET_PIN_MAP_PIN(index) index
  123. #define GET_PIN_MAP_INDEX(pin) pin
  124. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
  125. //
  126. // Tone
  127. //
  128. void toneInit();
  129. void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
  130. void noTone(const pin_t _pin);
  131. // Enable hooks into idle and setup for HAL
  132. void HAL_init();
  133. /*
  134. #define HAL_IDLETASK 1
  135. void HAL_idletask();
  136. */
  137. //
  138. // Utility functions
  139. //
  140. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  141. #pragma GCC diagnostic push
  142. #pragma GCC diagnostic ignored "-Wunused-function"
  143. int freeMemory();
  144. #pragma GCC diagnostic pop
  145. #ifdef __cplusplus
  146. extern "C" {
  147. #endif
  148. char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
  149. #ifdef __cplusplus
  150. }
  151. #endif