2012-01-08 22:14:54 +08:00
|
|
|
#ifndef __RT_DEVICE_H__
|
|
|
|
#define __RT_DEVICE_H__
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
2012-02-07 11:55:01 +08:00
|
|
|
#define RT_DEVICE(device) ((rt_device_t)device)
|
|
|
|
|
2012-04-23 14:02:28 +08:00
|
|
|
/* 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);
|
|
|
|
|
2012-01-08 22:14:54 +08:00
|
|
|
#ifdef RT_USING_SPI
|
|
|
|
#include "drivers/spi.h"
|
|
|
|
#endif
|
|
|
|
|
2012-05-30 21:44:13 +08:00
|
|
|
#ifdef RT_USING_MTD_NOR
|
|
|
|
#include "drivers/mtd_nor.h"
|
2012-01-08 22:14:54 +08:00
|
|
|
#endif
|
|
|
|
|
2012-04-03 00:34:15 +08:00
|
|
|
#ifdef RT_USING_MTD_NAND
|
|
|
|
#include "drivers/mtd_nand.h"
|
|
|
|
#endif
|
|
|
|
|
2012-01-08 22:14:54 +08:00
|
|
|
#ifdef RT_USING_USB_DEVICE
|
|
|
|
#include "drivers/usb_device.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_USB_HOST
|
|
|
|
#include "drivers/usb_host.h"
|
|
|
|
#endif
|
|
|
|
|
2012-06-01 14:52:34 +08:00
|
|
|
#ifdef RT_USING_SERIAL
|
|
|
|
#include "drivers/serial.h"
|
|
|
|
#endif
|
|
|
|
|
2012-01-08 22:14:54 +08:00
|
|
|
#endif
|