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.

timers.cpp 2.0KB

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