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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #define _MSERIAL(X) Serial##X
  33. #define MSERIAL(X) _MSERIAL(INCREMENT(X))
  34. #if SERIAL_PORT == -1
  35. #define MYSERIAL0 Serial
  36. #elif WITHIN(SERIAL_PORT, 0, 3)
  37. #define MYSERIAL0 MSERIAL(SERIAL_PORT)
  38. #else
  39. #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
  40. #endif
  41. #ifdef SERIAL_PORT_2
  42. #if SERIAL_PORT_2 == -1
  43. #define MYSERIAL1 Serial
  44. #elif WITHIN(SERIAL_PORT_2, 0, 3)
  45. #define MYSERIAL0 MSERIAL(SERIAL_PORT_2)
  46. #else
  47. #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
  48. #endif
  49. #endif
  50. #ifdef DGUS_SERIAL_PORT
  51. #if DGUS_SERIAL_PORT == -1
  52. #define DGUS_SERIAL Serial
  53. #elif WITHIN(DGUS_SERIAL_PORT, 0, 3)
  54. #define MYSERIAL0 MSERIAL(DGUS_SERIAL_PORT)
  55. #else
  56. #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
  57. #endif
  58. #endif
  59. #endif // ADAFRUIT_GRAND_CENTRAL_M4
  60. typedef int8_t pin_t;
  61. #define SHARED_SERVOS HAS_SERVOS
  62. #define HAL_SERVO_LIB Servo
  63. //
  64. // Interrupts
  65. //
  66. #define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
  67. #define CRITICAL_SECTION_END() if (!primask) __enable_irq()
  68. #define ISRS_ENABLED() (!__get_PRIMASK())
  69. #define ENABLE_ISRS() __enable_irq()
  70. #define DISABLE_ISRS() __disable_irq()
  71. #define cli() __disable_irq() // Disable interrupts
  72. #define sei() __enable_irq() // Enable interrupts
  73. void HAL_clear_reset_source(); // clear reset reason
  74. uint8_t HAL_get_reset_source(); // get reset reason
  75. //
  76. // ADC
  77. //
  78. extern uint16_t HAL_adc_result; // Most recent ADC conversion
  79. #define HAL_ANALOG_SELECT(pin)
  80. void HAL_adc_init();
  81. //#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values.
  82. #define HAL_ADC_VREF 3.3
  83. #define HAL_ADC_RESOLUTION 10 // ... 12
  84. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  85. #define HAL_READ_ADC() HAL_adc_result
  86. #define HAL_ADC_READY() true
  87. void HAL_adc_start_conversion(const uint8_t adc_pin);
  88. //
  89. // Pin Map
  90. //
  91. #define GET_PIN_MAP_PIN(index) index
  92. #define GET_PIN_MAP_INDEX(pin) pin
  93. #define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
  94. //
  95. // Tone
  96. //
  97. void toneInit();
  98. void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
  99. void noTone(const pin_t _pin);
  100. // Enable hooks into idle and setup for HAL
  101. void HAL_init();
  102. /*
  103. #define HAL_IDLETASK 1
  104. void HAL_idletask();
  105. */
  106. //
  107. // Utility functions
  108. //
  109. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  110. #pragma GCC diagnostic push
  111. #pragma GCC diagnostic ignored "-Wunused-function"
  112. int freeMemory();
  113. #pragma GCC diagnostic pop
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117. char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
  118. #ifdef __cplusplus
  119. }
  120. #endif