summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/drivers/serial.h73
-rw-r--r--components/drivers/include/drivers/usb_common.h4
-rw-r--r--components/drivers/include/drivers/usb_device.h6
-rw-r--r--components/drivers/include/rtdevice.h34
4 files changed, 94 insertions, 23 deletions
diff --git a/components/drivers/include/drivers/serial.h b/components/drivers/include/drivers/serial.h
index 41132ed916..bf2a25ae1e 100644
--- a/components/drivers/include/drivers/serial.h
+++ b/components/drivers/include/drivers/serial.h
@@ -30,9 +30,15 @@
#include <rtthread.h>
+#define BAUD_RATE_2400 2400
#define BAUD_RATE_4800 4800
#define BAUD_RATE_9600 9600
+#define BAUD_RATE_38400 38400
+#define BAUD_RATE_57600 57600
#define BAUD_RATE_115200 115200
+#define BAUD_RATE_230400 230400
+#define BAUD_RATE_460800 460800
+#define BAUD_RATE_921600 921600
#define DATA_BITS_5 5
#define DATA_BITS_6 6
@@ -64,6 +70,15 @@
#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 */
+#define RT_SERIAL_EVENT_TX_DMADONE 0x04 /* Tx DMA transfer done */
+#define RT_SERIAL_EVENT_RX_TIMEOUT 0x05 /* Rx timeout */
+
+#define RT_SERIAL_DMA_RX 0x01
+#define RT_SERIAL_DMA_TX 0x02
+
#define RT_SERIAL_RX_INT 0x01
#define RT_SERIAL_TX_INT 0x02
@@ -83,24 +98,51 @@
PARITY_NONE, /* No parity */ \
BIT_ORDER_LSB, /* LSB first sent */ \
NRZ_NORMAL, /* Normal mode */ \
+ RT_SERIAL_RB_BUFSZ, /* Buffer size */ \
0 \
}
-struct serial_ringbuffer
-{
- rt_uint8_t buffer[RT_SERIAL_RB_BUFSZ];
- rt_uint16_t put_index, get_index;
-};
-
struct serial_configure
{
rt_uint32_t baud_rate;
+
rt_uint32_t data_bits :4;
rt_uint32_t stop_bits :2;
rt_uint32_t parity :2;
rt_uint32_t bit_order :1;
rt_uint32_t invert :1;
- rt_uint32_t reserved :20;
+ rt_uint32_t bufsz :16;
+ rt_uint32_t reserved :4;
+};
+
+/*
+ * Serial FIFO mode
+ */
+struct rt_serial_rx_fifo
+{
+ /* software fifo */
+ rt_uint8_t *buffer;
+
+ rt_uint16_t put_index, get_index;
+};
+
+struct rt_serial_tx_fifo
+{
+ struct rt_completion completion;
+};
+
+/*
+ * Serial DMA mode
+ */
+struct rt_serial_rx_dma
+{
+ rt_bool_t activated;
+};
+
+struct rt_serial_tx_dma
+{
+ rt_bool_t activated;
+ struct rt_data_queue data_queue;
};
struct rt_serial_device
@@ -110,14 +152,8 @@ struct rt_serial_device
const struct rt_uart_ops *ops;
struct serial_configure config;
- /* rx structure */
- struct serial_ringbuffer *int_rx;
- /* tx structure */
- struct serial_ringbuffer *int_tx;
-
- struct rt_data_queue tx_dq; /* tx dataqueue */
-
- volatile rt_bool_t dma_flag; /* dma transfer flag */
+ void *serial_rx;
+ void *serial_tx;
};
typedef struct rt_serial_device rt_serial_t;
@@ -132,14 +168,15 @@ struct rt_uart_ops
int (*putc)(struct rt_serial_device *serial, char c);
int (*getc)(struct rt_serial_device *serial);
- rt_size_t (*dma_transmit)(struct rt_serial_device *serial, const char *buf, rt_size_t size);
+ rt_size_t (*dma_transmit)(struct rt_serial_device *serial, const rt_uint8_t *buf, rt_size_t size, int direction);
};
-void rt_hw_serial_isr(struct rt_serial_device *serial);
-void rt_hw_serial_dma_tx_isr(struct rt_serial_device *serial);
+void rt_hw_serial_isr(struct rt_serial_device *serial, int event);
+
rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
const char *name,
rt_uint32_t flag,
void *data);
#endif
+
diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h
index cd6f0432f3..1e9cf3dc9f 100644
--- a/components/drivers/include/drivers/usb_common.h
+++ b/components/drivers/include/drivers/usb_common.h
@@ -373,7 +373,7 @@ struct uhid_descriptor
};
typedef struct uhid_descriptor* uhid_desc_t;
-struct ureqest
+struct urequest
{
rt_uint8_t request_type;
rt_uint8_t request;
@@ -381,7 +381,7 @@ struct ureqest
rt_uint16_t index;
rt_uint16_t length;
};
-typedef struct ureqest* ureq_t;
+typedef struct urequest* ureq_t;
#ifndef MIN
#define MIN(a, b) (a < b ? a : b)
diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h
index 722251c82a..b104da6ab9 100644
--- a/components/drivers/include/drivers/usb_device.h
+++ b/components/drivers/include/drivers/usb_device.h
@@ -76,7 +76,7 @@ typedef enum
/* request to read full count */
UIO_REQUEST_READ_FULL,
/* request to read any count */
- UIO_REQUEST_READ_BEST,
+ UIO_REQUEST_READ_MOST,
/* request to write full count */
UIO_REQUEST_WRITE,
}UIO_REQUEST_TYPE;
@@ -239,7 +239,7 @@ struct udev_msg
union
{
struct ep_msg ep_msg;
- struct ureqest setup;
+ struct urequest setup;
} content;
};
typedef struct udev_msg* udev_msg_t;
@@ -292,7 +292,7 @@ rt_err_t rt_usbd_ep_set_stall(udevice_t device, uep_t ep);
rt_err_t rt_usbd_ep_clear_stall(udevice_t device, uep_t ep);
rt_err_t rt_usbd_ep0_set_stall(udevice_t device);
rt_err_t rt_usbd_ep0_clear_stall(udevice_t device);
-rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct ureqest* setup);
+rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest* setup);
rt_err_t rt_usbd_ep0_in_handler(udcd_t dcd);
rt_err_t rt_usbd_ep0_out_handler(udcd_t dcd, rt_size_t size);
rt_err_t rt_usbd_ep_in_handler(udcd_t dcd, rt_uint8_t address);
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index dac85eb716..dc9761032e 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -20,6 +20,7 @@
* Change Logs:
* Date Author Notes
* 2012-01-08 bernard first version.
+ * 2014-07-12 bernard Add workqueue implementation.
*/
#ifndef __RT_DEVICE_H__
@@ -143,6 +144,21 @@ struct rt_data_queue
void (*evt_notify)(struct rt_data_queue *queue, rt_uint32_t event);
};
+/* workqueue implementation */
+struct rt_workqueue
+{
+ rt_list_t work_list;
+ rt_thread_t work_thread;
+};
+
+struct rt_work
+{
+ rt_list_t list;
+
+ void (*work_func)(struct rt_work* work, void* work_data);
+ void *work_data;
+};
+
/**
* Completion
*/
@@ -274,6 +290,24 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
rt_size_t *size);
void rt_data_queue_reset(struct rt_data_queue *queue);
+#ifdef RT_USING_HEAP
+/**
+ * WorkQueue for DeviceDriver
+ */
+struct rt_workqueue *rt_workqueue_create(const char* name, rt_uint16_t stack_size, rt_uint8_t priority);
+rt_err_t rt_workqueue_destroy(struct rt_workqueue* queue);
+rt_err_t rt_workqueue_dowork(struct rt_workqueue* queue, struct rt_work* work);
+rt_err_t rt_workqueue_cancel_work(struct rt_workqueue* queue, struct rt_work* work);
+
+rt_inline void rt_work_init(struct rt_work* work, void (*work_func)(struct rt_work* work, void* work_data),
+ void* work_data)
+{
+ rt_list_init(&(work->list));
+ work->work_func = work_func;
+ work->work_data = work_data;
+}
+#endif
+
#ifdef RT_USING_RTC
#include "drivers/rtc.h"
#ifdef RT_USING_ALARM