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.

33 lines
732 B

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. #include "zirq_dispatcher.hpp"
  2. using namespace iflytop;
  3. using namespace std;
  4. extern "C" {
  5. /**
  6. * @brief HAL_TIM_PeriodElapsedCallbackе
  7. *
  8. * @param htim
  9. */
  10. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
  11. #ifdef IFLTYOP_ZTICKET_TIMER
  12. if (htim->Instance == IFLTYOP_ZTICKET_TIMER) {
  13. HAL_IncTick();
  14. return;
  15. }
  16. #endif
  17. ZIRQDispatcher::instance()._callOnTimIrq(htim);
  18. }
  19. }
  20. ZIRQDispatcher &ZIRQDispatcher::instance() {
  21. static ZIRQDispatcher instance;
  22. return instance;
  23. }
  24. void ZIRQDispatcher::regTimIrqListener(ontimirq_t listener) { m_ontimirqs.push_back(listener); }
  25. void ZIRQDispatcher::_callOnTimIrq(zchip_tim_t *tim) {
  26. for (auto &listener : m_ontimirqs) {
  27. listener(tim);
  28. }
  29. }