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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2019 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 <http://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 "timers.h"
  51. #include "serial.h"
  52. #define SHARED_SERVOS HAS_SERVOS
  53. extern HalSerial usb_serial;
  54. #define MYSERIAL0 usb_serial
  55. #define NUM_SERIAL 1
  56. #define ST7920_DELAY_1 DELAY_NS(600)
  57. #define ST7920_DELAY_2 DELAY_NS(750)
  58. #define ST7920_DELAY_3 DELAY_NS(750)
  59. //
  60. // Interrupts
  61. //
  62. #define CRITICAL_SECTION_START
  63. #define CRITICAL_SECTION_END
  64. #define ISRS_ENABLED()
  65. #define ENABLE_ISRS()
  66. #define DISABLE_ISRS()
  67. inline void HAL_init() {}
  68. // Utility functions
  69. #pragma GCC diagnostic push
  70. #pragma GCC diagnostic ignored "-Wunused-function"
  71. int freeMemory();
  72. #pragma GCC diagnostic pop
  73. // ADC
  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_ADC_RESOLUTION 10
  77. #define HAL_READ_ADC() HAL_adc_get_result()
  78. #define HAL_ADC_READY() true
  79. void HAL_adc_init();
  80. void HAL_adc_enable_channel(const uint8_t ch);
  81. void HAL_adc_start_conversion(const uint8_t ch);
  82. uint16_t HAL_adc_get_result();
  83. // Reset source
  84. inline void HAL_clear_reset_source(void) {}
  85. inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
  86. /* ---------------- Delay in cycles */
  87. FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
  88. Clock::delayCycles(x);
  89. }