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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifdef TARGET_LPC1768
  23. #include "../../inc/MarlinConfig.h"
  24. #include "../shared/Delay.h"
  25. #include "../../../gcode/parser.h"
  26. #if ENABLED(USE_WATCHDOG)
  27. #include "watchdog.h"
  28. #endif
  29. uint32_t HAL_adc_reading = 0;
  30. // U8glib required functions
  31. extern "C" void u8g_xMicroDelay(uint16_t val) {
  32. DELAY_US(val);
  33. }
  34. extern "C" void u8g_MicroDelay() {
  35. u8g_xMicroDelay(1);
  36. }
  37. extern "C" void u8g_10MicroDelay() {
  38. u8g_xMicroDelay(10);
  39. }
  40. extern "C" void u8g_Delay(uint16_t val) {
  41. delay(val);
  42. }
  43. //************************//
  44. // return free heap space
  45. int freeMemory() {
  46. char stack_end;
  47. void *heap_start = malloc(sizeof(uint32_t));
  48. if (heap_start == 0) return 0;
  49. uint32_t result = (uint32_t)&stack_end - (uint32_t)heap_start;
  50. free(heap_start);
  51. return result;
  52. }
  53. // scan command line for code
  54. // return index into pin map array if found and the pin is valid.
  55. // return dval if not found or not a valid pin.
  56. int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
  57. const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
  58. const int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? ((port << 5) | pin) : -2;
  59. return ind > -1 ? ind : dval;
  60. }
  61. void flashFirmware(const int16_t) { NVIC_SystemReset(); }
  62. void HAL_clear_reset_source(void) {
  63. TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
  64. }
  65. uint8_t HAL_get_reset_source(void) {
  66. #if ENABLED(USE_WATCHDOG)
  67. if (watchdog_timed_out()) return RST_WATCHDOG;
  68. #endif
  69. return RST_POWER_ON;
  70. }
  71. #endif // TARGET_LPC1768