rt_inputcapture.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-08-13 balanceTWK first version.
  9. */
  10. #ifndef __RT_INPUT_CAPTURE_H__
  11. #define __RT_INPUT_CAPTURE_H__
  12. #include <rtthread.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* capture control command */
  17. #define INPUTCAPTURE_CMD_CLEAR_BUF (128 + 0) /* clear capture buf */
  18. #define INPUTCAPTURE_CMD_SET_WATERMARK (128 + 1) /* Set the callback threshold */
  19. struct rt_inputcapture_data
  20. {
  21. rt_uint32_t pulsewidth_us;
  22. rt_bool_t is_high;
  23. };
  24. struct rt_inputcapture_device
  25. {
  26. struct rt_device parent;
  27. const struct rt_inputcapture_ops *ops;
  28. struct rt_ringbuffer *ringbuff;
  29. rt_size_t watermark;
  30. };
  31. /**
  32. * capture operators
  33. */
  34. struct rt_inputcapture_ops
  35. {
  36. rt_err_t (*init)(struct rt_inputcapture_device *inputcapture);
  37. rt_err_t (*open)(struct rt_inputcapture_device *inputcapture);
  38. rt_err_t (*close)(struct rt_inputcapture_device *inputcapture);
  39. rt_err_t (*get_pulsewidth)(struct rt_inputcapture_device *inputcapture, rt_uint32_t *pulsewidth_us);
  40. };
  41. void rt_hw_inputcapture_isr(struct rt_inputcapture_device *inputcapture, rt_bool_t level);
  42. rt_err_t rt_device_inputcapture_register(struct rt_inputcapture_device *inputcapture,
  43. const char *name,
  44. void *data);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* __RT_INPUT_CAPTURE_H__ */