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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. // --------------------------------------------------------------------------
  25. // Includes
  26. // --------------------------------------------------------------------------
  27. #define F_CPU 100000000
  28. #define SystemCoreClock F_CPU
  29. #include <iostream>
  30. #include <stdint.h>
  31. #include <stdarg.h>
  32. #undef min
  33. #undef max
  34. #include <algorithm>
  35. void _printf (const char *format, ...);
  36. void _putc(uint8_t c);
  37. uint8_t _getc();
  38. //extern "C" volatile uint32_t _millis;
  39. //arduino: Print.h
  40. #define DEC 10
  41. #define HEX 16
  42. #define OCT 8
  43. #define BIN 2
  44. //arduino: binary.h (weird defines)
  45. #define B01 1
  46. #define B10 2
  47. #include "hardware/Clock.h"
  48. #include "../shared/Marduino.h"
  49. #include "../shared/math_32bit.h"
  50. #include "../shared/HAL_SPI.h"
  51. #include "fastio.h"
  52. #include "watchdog.h"
  53. #include "HAL_timers.h"
  54. #include "serial.h"
  55. #define SHARED_SERVOS HAS_SERVOS
  56. extern HalSerial usb_serial;
  57. #define MYSERIAL0 usb_serial
  58. #define NUM_SERIAL 1
  59. #define ST7920_DELAY_1 DELAY_NS(600)
  60. #define ST7920_DELAY_2 DELAY_NS(750)
  61. #define ST7920_DELAY_3 DELAY_NS(750)
  62. //
  63. // Interrupts
  64. //
  65. #define CRITICAL_SECTION_START
  66. #define CRITICAL_SECTION_END
  67. #define ISRS_ENABLED()
  68. #define ENABLE_ISRS()
  69. #define DISABLE_ISRS()
  70. inline void HAL_init(void) { }
  71. // Utility functions
  72. int freeMemory(void);
  73. // SPI: Extended functions which take a channel number (hardware SPI only)
  74. /** Write single byte to specified SPI channel */
  75. void spiSend(uint32_t chan, byte b);
  76. /** Write buffer to specified SPI channel */
  77. void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
  78. /** Read single byte from specified SPI channel */
  79. uint8_t spiRec(uint32_t chan);
  80. // ADC
  81. #define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
  82. #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
  83. #define HAL_READ_ADC() HAL_adc_get_result()
  84. #define HAL_ADC_READY() true
  85. void HAL_adc_init(void);
  86. void HAL_adc_enable_channel(int pin);
  87. void HAL_adc_start_conversion(const uint8_t adc_pin);
  88. uint16_t HAL_adc_get_result(void);
  89. /* ---------------- Delay in cycles */
  90. FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
  91. Clock::delayCycles(x);
  92. }