My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

HAL.h 4.5KB

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