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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #define CPU_32_BIT
  24. #define F_CPU 100000000
  25. #define SystemCoreClock F_CPU
  26. #include <iostream>
  27. #include <stdint.h>
  28. #include <stdarg.h>
  29. #undef min
  30. #undef max
  31. #include <algorithm>
  32. void _printf (const char *format, ...);
  33. void _putc(uint8_t c);
  34. uint8_t _getc();
  35. //extern "C" volatile uint32_t _millis;
  36. //arduino: Print.h
  37. #define DEC 10
  38. #define HEX 16
  39. #define OCT 8
  40. #define BIN 2
  41. //arduino: binary.h (weird defines)
  42. #define B01 1
  43. #define B10 2
  44. #include "hardware/Clock.h"
  45. #include "../shared/Marduino.h"
  46. #include "../shared/math_32bit.h"
  47. #include "../shared/HAL_SPI.h"
  48. #include "fastio.h"
  49. #include "watchdog.h"
  50. #include "serial.h"
  51. #define SHARED_SERVOS HAS_SERVOS
  52. extern HalSerial usb_serial;
  53. #define MYSERIAL0 usb_serial
  54. #define ST7920_DELAY_1 DELAY_NS(600)
  55. #define ST7920_DELAY_2 DELAY_NS(750)
  56. #define ST7920_DELAY_3 DELAY_NS(750)
  57. //
  58. // Interrupts
  59. //
  60. #define CRITICAL_SECTION_START()
  61. #define CRITICAL_SECTION_END()
  62. #define ISRS_ENABLED()
  63. #define ENABLE_ISRS()
  64. #define DISABLE_ISRS()
  65. inline void HAL_init() {}
  66. // Utility functions
  67. #pragma GCC diagnostic push
  68. #pragma GCC diagnostic ignored "-Wunused-function"
  69. int freeMemory();
  70. #pragma GCC diagnostic pop
  71. // ADC
  72. #define HAL_ADC_VREF 5.0
  73. #define HAL_ADC_RESOLUTION 10
  74. #define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
  75. #define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
  76. #define HAL_READ_ADC() HAL_adc_get_result()
  77. #define HAL_ADC_READY() true
  78. void HAL_adc_init();
  79. void HAL_adc_enable_channel(const uint8_t ch);
  80. void HAL_adc_start_conversion(const uint8_t ch);
  81. uint16_t HAL_adc_get_result();
  82. // Reset source
  83. inline void HAL_clear_reset_source(void) {}
  84. inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
  85. /* ---------------- Delay in cycles */
  86. FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
  87. Clock::delayCycles(x);
  88. }
  89. // Add strcmp_P if missing
  90. #ifndef strcmp_P
  91. #define strcmp_P(a, b) strcmp((a), (b))
  92. #endif