diff options
| author | wuyangyong <[email protected]> | 2012-06-14 12:18:52 +0000 |
|---|---|---|
| committer | wuyangyong <[email protected]> | 2012-06-14 12:18:52 +0000 |
| commit | 9e3c72a6351388c3cc332753e42f8f95aaa9785d (patch) | |
| tree | 8a056db9b590c4cd34fdf90b45b336f5f56c0809 /components/drivers/include | |
| parent | 72bce28791da8f15acdc734a35bd4a40a5d96721 (diff) | |
fixed a eclipse compiling warning.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2163 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/drivers/include')
| -rw-r--r-- | components/drivers/include/drivers/i2c-bit-ops.h | 84 | ||||
| -rw-r--r-- | components/drivers/include/drivers/i2c.h | 174 | ||||
| -rw-r--r-- | components/drivers/include/drivers/i2c_dev.h | 56 | ||||
| -rw-r--r-- | components/drivers/include/rtdevice.h | 167 |
4 files changed, 255 insertions, 226 deletions
diff --git a/components/drivers/include/drivers/i2c-bit-ops.h b/components/drivers/include/drivers/i2c-bit-ops.h index 8b9253d9ff..bf9bd810a5 100644 --- a/components/drivers/include/drivers/i2c-bit-ops.h +++ b/components/drivers/include/drivers/i2c-bit-ops.h @@ -1,41 +1,43 @@ -/* - * File : i2c-bit-ops.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2012-04-25 weety first version - */ - -#ifndef __I2C_BIT_OPS_H__ -#define __I2C_BIT_OPS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct rt_i2c_bit_ops { - void *data; /* private data for lowlevel routines */ - void (*set_sda) (void *data, rt_int32_t state); - void (*set_scl) (void *data, rt_int32_t state); - rt_int32_t (*get_sda) (void *data); - rt_int32_t (*get_scl) (void *data); - - void (*udelay) (rt_uint32_t us); - - rt_uint32_t delay_us; /* scl and sda line delay */ - rt_uint32_t timeout; /* in tick */ -}; - -rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus, const char *bus_name); - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file +/*
+ * File : i2c-bit-ops.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2012-04-25 weety first version
+ */
+
+#ifndef __I2C_BIT_OPS_H__
+#define __I2C_BIT_OPS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct rt_i2c_bit_ops
+{
+ void *data; /* private data for lowlevel routines */
+ void (*set_sda) (void *data, rt_int32_t state);
+ void (*set_scl) (void *data, rt_int32_t state);
+ rt_int32_t (*get_sda) (void *data);
+ rt_int32_t (*get_scl) (void *data);
+
+ void (*udelay) (rt_uint32_t us);
+
+ rt_uint32_t delay_us; /* scl and sda line delay */
+ rt_uint32_t timeout; /* in tick */
+};
+
+rt_err_t rt_i2c_bit_add_bus(struct rt_i2c_bus_device *bus,
+ const char *bus_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/drivers/i2c.h b/components/drivers/include/drivers/i2c.h index 69b43e95b4..e966e24558 100644 --- a/components/drivers/include/drivers/i2c.h +++ b/components/drivers/include/drivers/i2c.h @@ -1,79 +1,95 @@ -/* - * File : i2c.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2012-04-25 weety first version - */ - -#ifndef __I2C_H__ -#define __I2C_H__ - -#include <rtthread.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define RT_I2C_WR 0x0000 -#define RT_I2C_RD (1u << 0) -#define RT_I2C_ADDR_10BIT (1u << 2) /* this is a ten bit chip address */ -#define RT_I2C_NO_START (1u << 4) -#define RT_I2C_IGNORE_NACK (1u << 5) -#define RT_I2C_NO_READ_ACK (1u << 6) /* when I2C reading, we do not ACK */ - -struct rt_i2c_msg { - rt_uint16_t addr; - rt_uint16_t flags; - rt_uint16_t len; - rt_uint8_t *buf; -}; - -struct rt_i2c_bus_device; - -struct rt_i2c_bus_device_ops { - rt_size_t (*master_xfer) (struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); - rt_size_t (*slave_xfer) (struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); - rt_err_t (*i2c_bus_control) (struct rt_i2c_bus_device *bus, rt_uint32_t, rt_uint32_t); -}; - -/*for i2c bus driver*/ -struct rt_i2c_bus_device { - struct rt_device parent; - const struct rt_i2c_bus_device_ops *ops; - rt_uint16_t flags; - rt_uint16_t addr; - struct rt_mutex lock; - rt_uint32_t timeout; - rt_uint32_t retries; - void *priv; -}; - -#ifdef RT_I2C_DEBUG -#define i2c_dbg(fmt, ...) rt_kprintf(fmt, ##__VA_ARGS__) -#else -#define i2c_dbg(fmt, ...) -#endif - -rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus, const char *bus_name); -struct rt_i2c_bus_device* rt_i2c_bus_device_find(const char *bus_name); -rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num); -rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus, rt_uint16_t addr, - rt_uint16_t flags, const rt_uint8_t *buf, - rt_uint32_t count); -rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus, rt_uint16_t addr, - rt_uint16_t flags, rt_uint8_t *buf, - rt_uint32_t count); -rt_err_t rt_i2c_core_init(void); - -#ifdef __cplusplus -} -#endif - -#endif +/*
+ * File : i2c.h
+ * This file is part of RT-Thread RTOS
+ * COPYRIGHT (C) 2006, RT-Thread Development Team
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rt-thread.org/license/LICENSE
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2012-04-25 weety first version
+ */
+
+#ifndef __I2C_H__
+#define __I2C_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RT_I2C_WR 0x0000
+#define RT_I2C_RD (1u << 0)
+#define RT_I2C_ADDR_10BIT (1u << 2) /* this is a ten bit chip address */
+#define RT_I2C_NO_START (1u << 4)
+#define RT_I2C_IGNORE_NACK (1u << 5)
+#define RT_I2C_NO_READ_ACK (1u << 6) /* when I2C reading, we do not ACK */
+
+struct rt_i2c_msg
+{
+ rt_uint16_t addr;
+ rt_uint16_t flags;
+ rt_uint16_t len;
+ rt_uint8_t *buf;
+};
+
+struct rt_i2c_bus_device;
+
+struct rt_i2c_bus_device_ops
+{
+ rt_size_t (*master_xfer) (struct rt_i2c_bus_device *bus,
+ struct rt_i2c_msg msgs[],
+ rt_uint32_t num);
+ rt_size_t (*slave_xfer) (struct rt_i2c_bus_device *bus,
+ struct rt_i2c_msg msgs[],
+ rt_uint32_t num);
+ rt_err_t (*i2c_bus_control) (struct rt_i2c_bus_device *bus,
+ rt_uint32_t,
+ rt_uint32_t);
+};
+
+/*for i2c bus driver*/
+struct rt_i2c_bus_device
+{
+ struct rt_device parent;
+ const struct rt_i2c_bus_device_ops *ops;
+ rt_uint16_t flags;
+ rt_uint16_t addr;
+ struct rt_mutex lock;
+ rt_uint32_t timeout;
+ rt_uint32_t retries;
+ void *priv;
+};
+
+#ifdef RT_I2C_DEBUG
+#define i2c_dbg(fmt, ...) rt_kprintf(fmt, ##__VA_ARGS__)
+#else
+#define i2c_dbg(fmt, ...)
+#endif
+
+rt_err_t rt_i2c_bus_device_register(struct rt_i2c_bus_device *bus,
+ const char *bus_name);
+struct rt_i2c_bus_device* rt_i2c_bus_device_find(const char *bus_name);
+rt_size_t rt_i2c_transfer(struct rt_i2c_bus_device *bus,
+ struct rt_i2c_msg msgs[],
+ rt_uint32_t num);
+rt_size_t rt_i2c_master_send(struct rt_i2c_bus_device *bus,
+ rt_uint16_t addr,
+ rt_uint16_t flags,
+ const rt_uint8_t *buf,
+ rt_uint32_t count);
+rt_size_t rt_i2c_master_recv(struct rt_i2c_bus_device *bus,
+ rt_uint16_t addr,
+ rt_uint16_t flags,
+ rt_uint8_t *buf,
+ rt_uint32_t count);
+rt_err_t rt_i2c_core_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/drivers/i2c_dev.h b/components/drivers/include/drivers/i2c_dev.h index b173e99333..8a2c2bef21 100644 --- a/components/drivers/include/drivers/i2c_dev.h +++ b/components/drivers/include/drivers/i2c_dev.h @@ -1,27 +1,29 @@ -#ifndef __I2C_DEV_H__ -#define __I2C_DEV_H__ - -#include <rtthread.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define RT_I2C_DEV_CTRL_10BIT 0x20 -#define RT_I2C_DEV_CTRL_ADDR 0x21 -#define RT_I2C_DEV_CTRL_TIMEOUT 0x22 -#define RT_I2C_DEV_CTRL_RW 0x23 - -struct rt_i2c_priv_data { - struct rt_i2c_msg *msgs; - rt_size_t number; -}; - -rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device* bus, const char* name); - - -#ifdef __cplusplus -} -#endif - -#endif
\ No newline at end of file +#ifndef __I2C_DEV_H__
+#define __I2C_DEV_H__
+
+#include <rtthread.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define RT_I2C_DEV_CTRL_10BIT 0x20
+#define RT_I2C_DEV_CTRL_ADDR 0x21
+#define RT_I2C_DEV_CTRL_TIMEOUT 0x22
+#define RT_I2C_DEV_CTRL_RW 0x23
+
+struct rt_i2c_priv_data
+{
+ struct rt_i2c_msg *msgs;
+ rt_size_t number;
+};
+
+rt_err_t rt_i2c_bus_device_device_init(struct rt_i2c_bus_device* bus,
+ const char* name);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h index 77dbddd9ae..e1fcc2f9a2 100644 --- a/components/drivers/include/rtdevice.h +++ b/components/drivers/include/rtdevice.h @@ -1,79 +1,88 @@ -#ifndef __RT_DEVICE_H__ -#define __RT_DEVICE_H__ - -#include <rtthread.h> - -#define RT_DEVICE(device) ((rt_device_t)device) - -/* completion flag */ -struct rt_completion -{ - rt_uint32_t flag; - - /* suspended list */ - rt_list_t suspended_list; -}; - -/* ring buffer */ -struct rt_ringbuffer -{ - rt_uint16_t read_index, write_index; - rt_uint8_t *buffer_ptr; - rt_uint16_t buffer_size; -}; - -/** - * Completion - */ -void rt_completion_init(struct rt_completion* completion); -rt_err_t rt_completion_wait(struct rt_completion* completion, rt_int32_t timeout); -void rt_completion_done(struct rt_completion* completion); - -/** - * DataLink for DeviceDriver - */ - -/** - * RingBuffer for DeviceDriver - */ -void rt_ringbuffer_init(struct rt_ringbuffer* rb, rt_uint8_t *pool, rt_uint16_t size); -rt_size_t rt_ringbuffer_put(struct rt_ringbuffer* rb, const rt_uint8_t *ptr, rt_uint16_t length); -rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer* rb, const rt_uint8_t ch); -rt_size_t rt_ringbuffer_get(struct rt_ringbuffer* rb, rt_uint8_t *ptr, rt_uint16_t length); -rt_size_t rt_ringbuffer_available_size(struct rt_ringbuffer* rb); -rt_size_t rt_ringbuffer_emptry_size(struct rt_ringbuffer* rb); - -#ifdef RT_USING_SPI -#include "drivers/spi.h" -#endif - -#ifdef RT_USING_MTD_NOR -#include "drivers/mtd_nor.h" -#endif - -#ifdef RT_USING_MTD_NAND -#include "drivers/mtd_nand.h" -#endif - -#ifdef RT_USING_USB_DEVICE -#include "drivers/usb_device.h" -#endif - -#ifdef RT_USING_USB_HOST -#include "drivers/usb_host.h" -#endif - -#ifdef RT_USING_SERIAL -#include "drivers/serial.h" -#endif - -#ifdef RT_USING_I2C -#include "drivers/i2c.h" -#include "drivers/i2c_dev.h" -#endif - -#ifdef RT_USING_I2C_BITOPS -#include "drivers/i2c-bit-ops.h" -#endif - -#endif +#ifndef __RT_DEVICE_H__
+#define __RT_DEVICE_H__
+
+#include <rtthread.h>
+
+#define RT_DEVICE(device) ((rt_device_t)device)
+
+/* completion flag */
+struct rt_completion
+{
+ rt_uint32_t flag;
+
+ /* suspended list */
+ rt_list_t suspended_list;
+};
+
+/* ring buffer */
+struct rt_ringbuffer
+{
+ rt_uint16_t read_index, write_index;
+ rt_uint8_t *buffer_ptr;
+ rt_uint16_t buffer_size;
+};
+
+/**
+ * Completion
+ */
+void rt_completion_init(struct rt_completion* completion);
+rt_err_t rt_completion_wait(struct rt_completion* completion,
+ rt_int32_t timeout);
+void rt_completion_done(struct rt_completion* completion);
+
+/**
+ * DataLink for DeviceDriver
+ */
+
+/**
+ * RingBuffer for DeviceDriver
+ */
+void rt_ringbuffer_init(struct rt_ringbuffer* rb,
+ rt_uint8_t *pool,
+ rt_uint16_t size);
+rt_size_t rt_ringbuffer_put(struct rt_ringbuffer* rb,
+ const rt_uint8_t *ptr,
+ rt_uint16_t length);
+rt_size_t rt_ringbuffer_putchar(struct rt_ringbuffer* rb,
+ const rt_uint8_t ch);
+rt_size_t rt_ringbuffer_get(struct rt_ringbuffer* rb,
+ rt_uint8_t *ptr,
+ rt_uint16_t length);
+rt_size_t rt_ringbuffer_available_size(struct rt_ringbuffer* rb);
+rt_size_t rt_ringbuffer_emptry_size(struct rt_ringbuffer* rb);
+
+#ifdef RT_USING_SPI
+#include "drivers/spi.h"
+#endif /* RT_USING_SPI */
+
+#ifdef RT_USING_MTD_NOR
+#include "drivers/mtd_nor.h"
+#endif /* RT_USING_MTD_NOR */
+
+#ifdef RT_USING_MTD_NAND
+#include "drivers/mtd_nand.h"
+#endif /* RT_USING_MTD_NAND */
+
+#ifdef RT_USING_USB_DEVICE
+#include "drivers/usb_device.h"
+#endif /* RT_USING_USB_DEVICE */
+
+#ifdef RT_USING_USB_HOST
+#include "drivers/usb_host.h"
+#endif /* RT_USING_USB_HOST */
+
+#ifdef RT_USING_SERIAL
+#include "drivers/serial.h"
+#endif /* RT_USING_SERIAL */
+
+#ifdef RT_USING_I2C
+#include "drivers/i2c.h"
+#include "drivers/i2c_dev.h"
+
+#ifdef RT_USING_I2C_BITOPS
+#include "drivers/i2c-bit-ops.h"
+#endif /* RT_USING_I2C_BITOPS */
+
+#endif /* RT_USING_I2C */
+
+#endif /* __RT_DEVICE_H__ */
|
