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_timers.cpp 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. *
  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 __PLAT_LINUX__
  23. #include "hardware/Timer.h"
  24. #include "../../inc/MarlinConfig.h"
  25. #include "HAL_timers.h"
  26. /**
  27. * Use POSIX signals to attempt to emulate Interrupts
  28. * This has many limitations and is not fit for the purpose
  29. */
  30. HAL_STEP_TIMER_ISR();
  31. HAL_TEMP_TIMER_ISR();
  32. Timer timers[2];
  33. void HAL_timer_init(void) {
  34. timers[0].init(0, STEPPER_TIMER_RATE, TIMER0_IRQHandler);
  35. timers[1].init(1, TEMP_TIMER_RATE, TIMER1_IRQHandler);
  36. }
  37. void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
  38. timers[timer_num].start(frequency);
  39. }
  40. void HAL_timer_enable_interrupt(const uint8_t timer_num) {
  41. timers[timer_num].enable();
  42. }
  43. void HAL_timer_disable_interrupt(const uint8_t timer_num) {
  44. timers[timer_num].disable();
  45. }
  46. bool HAL_timer_interrupt_enabled(const uint8_t timer_num) {
  47. return timers[timer_num].enabled();
  48. }
  49. void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t compare) {
  50. timers[timer_num].setCompare(compare);
  51. }
  52. hal_timer_t HAL_timer_get_compare(const uint8_t timer_num) {
  53. return timers[timer_num].getCompare();
  54. }
  55. hal_timer_t HAL_timer_get_count(const uint8_t timer_num) {
  56. return timers[timer_num].getCount();
  57. }
  58. #endif // __PLAT_LINUX__