summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
author陈豪 | Jacob Chen <[email protected]>2015-03-29 18:35:44 +0800
committer陈豪 | Jacob Chen <[email protected]>2015-03-29 18:35:44 +0800
commit9a4dacaad743801c9be2dbae49251c4e1b8f99a9 (patch)
tree34def3bef5c5fc4a9b7594eba5a2729f8c86aab0 /components/drivers/include
parentdaac5388afe5a18d51e9839719de8423b62b00c1 (diff)
parent5af7abd8c2e8b8a39c0bf096bdf9b5cb08f266fa (diff)
Merge pull request #3 from RT-Thread/master
111
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/pin.h79
-rw-r--r--components/drivers/include/drivers/serial.h5
-rw-r--r--components/drivers/include/rtdevice.h4
3 files changed, 83 insertions, 5 deletions
diff --git a/components/drivers/include/drivers/pin.h b/components/drivers/include/drivers/pin.h
new file mode 100644
index 0000000000..704114cf99
--- /dev/null
+++ b/components/drivers/include/drivers/pin.h
@@ -0,0 +1,79 @@
+/*
+ * File : pin.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2015, 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
+ * 2015-01-20 Bernard the first version
+ */
+
+#ifndef PIN_H__
+#define PIN_H__
+
+#include <rtthread.h>
+#include <rtdevice.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* pin device and operations for RT-Thread */
+struct rt_device_pin
+{
+ struct rt_device parent;
+ const struct rt_pin_ops *ops;
+};
+
+#define PIN_LOW 0x00
+#define PIN_HIGH 0x01
+
+#define PIN_MODE_OUTPUT 0x00
+#define PIN_MODE_INPUT 0x01
+#define PIN_MODE_INPUT_PULLUP 0x02
+
+struct rt_device_pin_mode
+{
+ rt_uint16_t pin;
+ rt_uint16_t mode;
+};
+struct rt_device_pin_status
+{
+ rt_uint16_t pin;
+ rt_uint16_t status;
+};
+
+struct rt_pin_ops
+{
+ void (*pin_mode)(struct rt_device *device, rt_base_t pin, rt_base_t mode);
+ void (*pin_write)(struct rt_device *device, rt_base_t pin, rt_base_t value);
+ int (*pin_read)(struct rt_device *device, rt_base_t pin);
+
+ /* TODO: add GPIO interrupt */
+};
+
+int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void *user_data);
+
+void rt_pin_mode(rt_base_t pin, rt_base_t mode);
+void rt_pin_write(rt_base_t pin, rt_base_t value);
+int rt_pin_read(rt_base_t pin);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/drivers/serial.h b/components/drivers/include/drivers/serial.h
index bf2a25ae1e..3b0a009072 100644
--- a/components/drivers/include/drivers/serial.h
+++ b/components/drivers/include/drivers/serial.h
@@ -65,11 +65,6 @@
#define RT_SERIAL_RB_BUFSZ 64
#endif
-#define RT_DEVICE_CTRL_CONFIG 0x03 /* configure device */
-#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable receive irq */
-#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */
-#define RT_DEVICE_CTRL_GET_INT 0x12
-
#define RT_SERIAL_EVENT_RX_IND 0x01 /* Rx indication */
#define RT_SERIAL_EVENT_TX_DONE 0x02 /* Tx complete */
#define RT_SERIAL_EVENT_RX_DMADONE 0x03 /* Rx DMA transfer done */
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index dc9761032e..bb01da2d12 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -358,5 +358,9 @@ rt_inline void rt_work_init(struct rt_work* work, void (*work_func)(struct rt_wo
#include "drivers/watchdog.h"
#endif
+#ifdef RT_USING_PIN
+#include "drivers/pin.h"
+#endif
+
#endif /* __RT_DEVICE_H__ */