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 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * Marlin 3D Printer Firmware
  3. *
  4. * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #if defined(STM32GENERIC) && defined(STM32F4)
  24. // --------------------------------------------------------------------------
  25. // Includes
  26. // --------------------------------------------------------------------------
  27. #include "HAL.h"
  28. //#include <Wire.h>
  29. // --------------------------------------------------------------------------
  30. // Externals
  31. // --------------------------------------------------------------------------
  32. // --------------------------------------------------------------------------
  33. // Local defines
  34. // --------------------------------------------------------------------------
  35. // --------------------------------------------------------------------------
  36. // Types
  37. // --------------------------------------------------------------------------
  38. // --------------------------------------------------------------------------
  39. // Variables
  40. // --------------------------------------------------------------------------
  41. // --------------------------------------------------------------------------
  42. // Public Variables
  43. // --------------------------------------------------------------------------
  44. uint16_t HAL_adc_result;
  45. // --------------------------------------------------------------------------
  46. // Private Variables
  47. // --------------------------------------------------------------------------
  48. // --------------------------------------------------------------------------
  49. // Function prototypes
  50. // --------------------------------------------------------------------------
  51. // --------------------------------------------------------------------------
  52. // Private functions
  53. // --------------------------------------------------------------------------
  54. // --------------------------------------------------------------------------
  55. // Public functions
  56. // --------------------------------------------------------------------------
  57. /* VGPV Done with defines
  58. // disable interrupts
  59. void cli(void) { noInterrupts(); }
  60. // enable interrupts
  61. void sei(void) { interrupts(); }
  62. */
  63. void HAL_clear_reset_source(void) { __HAL_RCC_CLEAR_RESET_FLAGS(); }
  64. uint8_t HAL_get_reset_source(void) {
  65. if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
  66. if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET) return RST_SOFTWARE;
  67. if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET) return RST_EXTERNAL;
  68. if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET) return RST_POWER_ON;
  69. return 0;
  70. }
  71. void _delay_ms(const int delay_ms) { delay(delay_ms); }
  72. extern "C" {
  73. extern unsigned int _ebss; // end of bss section
  74. }
  75. // return free memory between end of heap (or end bss) and whatever is current
  76. /*
  77. #include "wirish/syscalls.c"
  78. //extern caddr_t _sbrk(int incr);
  79. #ifndef CONFIG_HEAP_END
  80. extern char _lm_heap_end;
  81. #define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
  82. #endif
  83. extern "C" {
  84. static int freeMemory() {
  85. char top = 't';
  86. return &top - reinterpret_cast<char*>(sbrk(0));
  87. }
  88. int freeMemory() {
  89. int free_memory;
  90. int heap_end = (int)_sbrk(0);
  91. free_memory = ((int)&free_memory) - ((int)heap_end);
  92. return free_memory;
  93. }
  94. }
  95. */
  96. // --------------------------------------------------------------------------
  97. // ADC
  98. // --------------------------------------------------------------------------
  99. void HAL_adc_start_conversion(const uint8_t adc_pin) {
  100. HAL_adc_result = analogRead(adc_pin);
  101. }
  102. uint16_t HAL_adc_get_result(void) {
  103. return HAL_adc_result;
  104. }
  105. #endif // // STM32GENERIC && STM32F4