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.

HAL.h 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  5. * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
  6. * Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * HAL for Teensy 3.2 (MK20DX256)
  25. */
  26. #define CPU_32_BIT
  27. #include "../shared/Marduino.h"
  28. #include "../shared/math_32bit.h"
  29. #include "../shared/HAL_SPI.h"
  30. #include "fastio.h"
  31. #include "watchdog.h"
  32. #include <stdint.h>
  33. #define ST7920_DELAY_1 DELAY_NS(600)
  34. #define ST7920_DELAY_2 DELAY_NS(750)
  35. #define ST7920_DELAY_3 DELAY_NS(750)
  36. //#undef MOTHERBOARD
  37. //#define MOTHERBOARD BOARD_TEENSY31_32
  38. #define IS_32BIT_TEENSY 1
  39. #define IS_TEENSY_31_32 1
  40. #ifndef IS_TEENSY31
  41. #define IS_TEENSY32 1
  42. #endif
  43. #include "../../core/serial_hook.h"
  44. typedef Serial0Type<decltype(Serial)> DefaultSerial;
  45. extern DefaultSerial MSerial;
  46. typedef ForwardSerial0Type<decltype(SerialUSB)> USBSerialType;
  47. extern USBSerialType USBSerial;
  48. #define _MSERIAL(X) MSerial##X
  49. #define MSERIAL(X) _MSERIAL(X)
  50. #define MSerial0 MSerial
  51. #if SERIAL_PORT == -1
  52. #define MYSERIAL0 USBSerial
  53. #elif WITHIN(SERIAL_PORT, 0, 3)
  54. #define MYSERIAL0 MSERIAL(SERIAL_PORT)
  55. #endif
  56. #define HAL_SERVO_LIB libServo
  57. typedef int8_t pin_t;
  58. #ifndef analogInputToDigitalPin
  59. #define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
  60. #endif
  61. #define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
  62. #define CRITICAL_SECTION_END() if (!primask) __enable_irq()
  63. #define ISRS_ENABLED() (!__get_PRIMASK())
  64. #define ENABLE_ISRS() __enable_irq()
  65. #define DISABLE_ISRS() __disable_irq()
  66. inline void HAL_init() {}
  67. // Clear the reset reason
  68. void HAL_clear_reset_source();
  69. // Get the reason for the reset
  70. uint8_t HAL_get_reset_source();
  71. inline void HAL_reboot() {} // reboot the board or restart the bootloader
  72. FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
  73. #if GCC_VERSION <= 50000
  74. #pragma GCC diagnostic push
  75. #pragma GCC diagnostic ignored "-Wunused-function"
  76. #endif
  77. extern "C" int freeMemory();
  78. #if GCC_VERSION <= 50000
  79. #pragma GCC diagnostic pop
  80. #endif
  81. // ADC
  82. void HAL_adc_init();
  83. #define HAL_ADC_VREF 3.3
  84. #define HAL_ADC_RESOLUTION 10
  85. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  86. #define HAL_READ_ADC() HAL_adc_get_result()
  87. #define HAL_ADC_READY() true
  88. #define HAL_ANALOG_SELECT(pin)
  89. void HAL_adc_start_conversion(const uint8_t adc_pin);
  90. uint16_t HAL_adc_get_result();
  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)