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

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