pulse_joiner.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdint.h>
  2. #include <stdbool.h>
  3. #include <stddef.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct PulseJoiner PulseJoiner;
  8. /**
  9. * @brief Alloc PulseJoiner
  10. *
  11. * @return PulseJoiner*
  12. */
  13. PulseJoiner* pulse_joiner_alloc();
  14. /**
  15. * @brief Free PulseJoiner
  16. *
  17. * @param pulse_joiner
  18. */
  19. void pulse_joiner_free(PulseJoiner* pulse_joiner);
  20. /**
  21. * @brief Push timer pulse. First negative pulse is ommited.
  22. *
  23. * @param polarity pulse polarity: true = high2low, false = low2high
  24. * @param period overall period time in timer clicks
  25. * @param pulse pulse time in timer clicks
  26. *
  27. * @return true - next pulse can and must be popped immediatly
  28. */
  29. bool pulse_joiner_push_pulse(PulseJoiner* pulse_joiner, bool polarity, size_t period, size_t pulse);
  30. /**
  31. * @brief Get the next timer pulse. Call only if push_pulse returns true.
  32. *
  33. * @param period overall period time in timer clicks
  34. * @param pulse pulse time in timer clicks
  35. */
  36. void pulse_joiner_pop_pulse(PulseJoiner* pulse_joiner, size_t* period, size_t* pulse);
  37. #ifdef __cplusplus
  38. }
  39. #endif