My Marlin configs for Fabrikator Mini and CTC i3 Pro B
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

HAL.cpp 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  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. /**
  23. * HAL for Teensy 3.2 (MK20DX256)
  24. */
  25. #ifdef __MK20DX256__
  26. #include "HAL.h"
  27. #include "../shared/Delay.h"
  28. #include <Wire.h>
  29. uint16_t HAL_adc_result;
  30. static const uint8_t pin2sc1a[] = {
  31. 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13
  32. 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9)
  33. 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33
  34. 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13)
  35. 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0.
  36. };
  37. /*
  38. // disable interrupts
  39. void cli() { noInterrupts(); }
  40. // enable interrupts
  41. void sei() { interrupts(); }
  42. */
  43. void HAL_adc_init() {
  44. analog_init();
  45. while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
  46. NVIC_ENABLE_IRQ(IRQ_FTM1);
  47. }
  48. void HAL_clear_reset_source() { }
  49. uint8_t HAL_get_reset_source() {
  50. switch (RCM_SRS0) {
  51. case 128: return RST_POWER_ON; break;
  52. case 64: return RST_EXTERNAL; break;
  53. case 32: return RST_WATCHDOG; break;
  54. // case 8: return RST_LOSS_OF_LOCK; break;
  55. // case 4: return RST_LOSS_OF_CLOCK; break;
  56. // case 2: return RST_LOW_VOLTAGE; break;
  57. }
  58. return 0;
  59. }
  60. extern "C" {
  61. extern char __bss_end;
  62. extern char __heap_start;
  63. extern void* __brkval;
  64. int freeMemory() {
  65. int free_memory;
  66. if ((int)__brkval == 0)
  67. free_memory = ((int)&free_memory) - ((int)&__bss_end);
  68. else
  69. free_memory = ((int)&free_memory) - ((int)__brkval);
  70. return free_memory;
  71. }
  72. }
  73. void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; }
  74. uint16_t HAL_adc_get_result() { return ADC0_RA; }
  75. #endif // __MK20DX256__