My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

HAL.cpp 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. DefaultSerial1 MSerial0(false);
  30. USBSerialType USBSerial(false, SerialUSB);
  31. uint16_t HAL_adc_result;
  32. static const uint8_t pin2sc1a[] = {
  33. 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13
  34. 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9)
  35. 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33
  36. 0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13)
  37. 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.
  38. };
  39. /*
  40. // disable interrupts
  41. void cli() { noInterrupts(); }
  42. // enable interrupts
  43. void sei() { interrupts(); }
  44. */
  45. void HAL_adc_init() {
  46. analog_init();
  47. while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
  48. NVIC_ENABLE_IRQ(IRQ_FTM1);
  49. }
  50. void HAL_clear_reset_source() { }
  51. uint8_t HAL_get_reset_source() {
  52. switch (RCM_SRS0) {
  53. case 128: return RST_POWER_ON; break;
  54. case 64: return RST_EXTERNAL; break;
  55. case 32: return RST_WATCHDOG; break;
  56. // case 8: return RST_LOSS_OF_LOCK; break;
  57. // case 4: return RST_LOSS_OF_CLOCK; break;
  58. // case 2: return RST_LOW_VOLTAGE; break;
  59. }
  60. return 0;
  61. }
  62. extern "C" {
  63. extern char __bss_end;
  64. extern char __heap_start;
  65. extern void* __brkval;
  66. int freeMemory() {
  67. int free_memory;
  68. if ((int)__brkval == 0)
  69. free_memory = ((int)&free_memory) - ((int)&__bss_end);
  70. else
  71. free_memory = ((int)&free_memory) - ((int)__brkval);
  72. return free_memory;
  73. }
  74. }
  75. void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; }
  76. uint16_t HAL_adc_get_result() { return ADC0_RA; }
  77. #endif // __MK20DX256__