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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (c) 2020 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. * Copyright (c) 2017 Victor Perez
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #if defined(STM32GENERIC) && (defined(STM32F4) || defined(STM32F7))
  24. #include "HAL.h"
  25. //#include <Wire.h>
  26. // ------------------------
  27. // Public Variables
  28. // ------------------------
  29. uint16_t HAL_adc_result;
  30. // ------------------------
  31. // Public functions
  32. // ------------------------
  33. /* VGPV Done with defines
  34. // disable interrupts
  35. void cli() { noInterrupts(); }
  36. // enable interrupts
  37. void sei() { interrupts(); }
  38. */
  39. void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
  40. uint8_t HAL_get_reset_source() {
  41. if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
  42. if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
  43. if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
  44. if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
  45. return 0;
  46. }
  47. void _delay_ms(const int delay_ms) { delay(delay_ms); }
  48. extern "C" {
  49. extern unsigned int _ebss; // end of bss section
  50. }
  51. // return free memory between end of heap (or end bss) and whatever is current
  52. /*
  53. #include <wirish/syscalls.c>
  54. //extern caddr_t _sbrk(int incr);
  55. #ifndef CONFIG_HEAP_END
  56. extern char _lm_heap_end;
  57. #define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
  58. #endif
  59. extern "C" {
  60. static int freeMemory() {
  61. char top = 't';
  62. return &top - reinterpret_cast<char*>(sbrk(0));
  63. }
  64. int freeMemory() {
  65. int free_memory;
  66. int heap_end = (int)_sbrk(0);
  67. free_memory = ((int)&free_memory) - ((int)heap_end);
  68. return free_memory;
  69. }
  70. }
  71. */
  72. // ------------------------
  73. // ADC
  74. // ------------------------
  75. void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
  76. uint16_t HAL_adc_get_result() { return HAL_adc_result; }
  77. #endif // STM32GENERIC && (STM32F4 || STM32F7)