summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authortangweikang <[email protected]>2019-08-13 20:14:45 +0800
committertangweikang <[email protected]>2019-08-13 20:33:23 +0800
commit473505053feebb4eb1e2e870d5e042776556d24c (patch)
treead463825234c1bd5c8400912769f45a88e62f186 /components/drivers/include
parent3b252d5b9721bb7cc649dad832507937efc1e96c (diff)
[components][drivers] add capture driven framework
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/rt_capture.h61
-rw-r--r--components/drivers/include/rtdevice.h4
2 files changed, 65 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/rt_capture.h b/components/drivers/include/drivers/rt_capture.h
new file mode 100644
index 0000000000..efc2ae4db1
--- /dev/null
+++ b/components/drivers/include/drivers/rt_capture.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2019-08-13 balanceTWK first version.
+ */
+
+#ifndef __RT_CAPTURE_H__
+#define __RT_CAPTURE_H__
+
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* capture control command */
+#define CAPTURE_CMD_CLEAR_BUF (128 + 0) /* clear capture buf */
+#define CAPTURE_CMD_SET_WATERMARK (128 + 1) /* Set the callback threshold */
+
+struct capture_data_struct
+{
+ rt_bool_t is_high;
+ rt_uint32_t pulsewidth_us;
+};
+
+struct rt_capture_device
+{
+ struct rt_device parent;
+
+ const struct rt_capture_ops *ops;
+ struct rt_ringbuffer *ringbuff;
+ rt_size_t watermark;
+};
+
+/**
+ * capture operators
+ */
+struct rt_capture_ops
+{
+ rt_err_t (*init)(struct rt_capture_device *capture);
+ rt_err_t (*open)(struct rt_capture_device *capture);
+ rt_err_t (*close)(struct rt_capture_device *capture);
+ rt_err_t (*get_pulsewidth)(struct rt_capture_device *capture, rt_uint32_t *pulsewidth_us);
+};
+
+void rt_hw_capture_isr(struct rt_capture_device *capture, rt_bool_t level);
+
+rt_err_t rt_hw_capture_register(struct rt_capture_device *capture,
+ const char *name,
+ rt_uint32_t flag,
+ void *data);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __RT_CAPTURE_H__ */
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index 0c009e9580..3ba7f72357 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -130,6 +130,10 @@ extern "C" {
#include "drivers/encoder.h"
#endif
+#ifdef RT_USING_CAPTURE
+#include "drivers/rt_capture.h"
+#endif
+
#ifdef __cplusplus
}
#endif