summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/rt_drv_pwm.h54
-rw-r--r--components/drivers/include/rtdevice.h4
2 files changed, 58 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h
new file mode 100644
index 0000000000..ffd08edabb
--- /dev/null
+++ b/components/drivers/include/drivers/rt_drv_pwm.h
@@ -0,0 +1,54 @@
+/*
+ * File : rt_drv_pwm.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2018, RT-Thread Development Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2018-05-07 aozima the first version
+ */
+
+#ifndef __DRV_PWM_H_INCLUDE__
+#define __DRV_PWM_H_INCLUDE__
+
+#define PWM_CMD_ENABLE (128 + 0)
+#define PWM_CMD_DISABLE (128 + 1)
+#define PWM_CMD_SET (128 + 2)
+#define PWM_CMD_GET (128 + 3)
+
+struct rt_pwm_configuration
+{
+ rt_uint32_t channel; /* 0-n */
+ rt_uint32_t period; /* unit:ns 1ns~4.29s:1Ghz~0.23hz */
+ rt_uint32_t pulse; /* unit:ns (pulse<=period) */
+};
+
+struct rt_device_pwm;
+struct rt_pwm_ops
+{
+ rt_err_t (*control)(struct rt_device_pwm *device, int cmd, void *arg);
+};
+
+struct rt_device_pwm
+{
+ struct rt_device parent;
+ const struct rt_pwm_ops *ops;
+};
+
+extern rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, const struct rt_pwm_ops *ops, const void *user_data);
+
+#endif /* __DRV_PWM_H_INCLUDE__ */
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index f7aadd8305..e3c826fe53 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -112,6 +112,10 @@ extern "C" {
#include "drivers/cputime.h"
#endif
+#ifdef RT_USING_PWM
+#include "drivers/rt_drv_pwm.h"
+#endif
+
#ifdef __cplusplus
}
#endif