rename the private field in device to user_data.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1133 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
7a80d831c9
commit
5a4d618832
|
@ -329,7 +329,7 @@ void rt_hw_serial_init(void)
|
||||||
serial->parent.read = rt_serial_read;
|
serial->parent.read = rt_serial_read;
|
||||||
serial->parent.write = rt_serial_write;
|
serial->parent.write = rt_serial_write;
|
||||||
serial->parent.control = rt_serial_control;
|
serial->parent.control = rt_serial_control;
|
||||||
serial->parent.private = RT_NULL;
|
serial->parent.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&serial->parent,
|
rt_device_register(&serial->parent,
|
||||||
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
@ -352,7 +352,7 @@ void rt_hw_serial_init(void)
|
||||||
serial->parent.read = rt_serial_read;
|
serial->parent.read = rt_serial_read;
|
||||||
serial->parent.write = rt_serial_write;
|
serial->parent.write = rt_serial_write;
|
||||||
serial->parent.control = rt_serial_control;
|
serial->parent.control = rt_serial_control;
|
||||||
serial->parent.private = RT_NULL;
|
serial->parent.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&serial->parent,
|
rt_device_register(&serial->parent,
|
||||||
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
|
@ -377,7 +377,7 @@ void rt_hw_serial_init(void)
|
||||||
lpc_serial->parent.read = rt_serial_read;
|
lpc_serial->parent.read = rt_serial_read;
|
||||||
lpc_serial->parent.write = rt_serial_write;
|
lpc_serial->parent.write = rt_serial_write;
|
||||||
lpc_serial->parent.control = rt_serial_control;
|
lpc_serial->parent.control = rt_serial_control;
|
||||||
lpc_serial->parent.private = RT_NULL;
|
lpc_serial->parent.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&lpc_serial->parent,
|
rt_device_register(&lpc_serial->parent,
|
||||||
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
|
@ -340,7 +340,7 @@ void rt_hw_serial_init(void)
|
||||||
lpc_serial->parent.read = rt_serial_read;
|
lpc_serial->parent.read = rt_serial_read;
|
||||||
lpc_serial->parent.write = rt_serial_write;
|
lpc_serial->parent.write = rt_serial_write;
|
||||||
lpc_serial->parent.control = rt_serial_control;
|
lpc_serial->parent.control = rt_serial_control;
|
||||||
lpc_serial->parent.private = RT_NULL;
|
lpc_serial->parent.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&lpc_serial->parent,
|
rt_device_register(&lpc_serial->parent,
|
||||||
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
"uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
@ -377,7 +377,7 @@ void rt_hw_serial_init(void)
|
||||||
lpc_serial->parent.read = rt_serial_read;
|
lpc_serial->parent.read = rt_serial_read;
|
||||||
lpc_serial->parent.write = rt_serial_write;
|
lpc_serial->parent.write = rt_serial_write;
|
||||||
lpc_serial->parent.control = rt_serial_control;
|
lpc_serial->parent.control = rt_serial_control;
|
||||||
lpc_serial->parent.private = RT_NULL;
|
lpc_serial->parent.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&lpc_serial->parent,
|
rt_device_register(&lpc_serial->parent,
|
||||||
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
"uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
|
@ -165,7 +165,7 @@ void rt_hw_rtc_init(void)
|
||||||
rtc.control = rtc_control;
|
rtc.control = rtc_control;
|
||||||
|
|
||||||
/* no private */
|
/* no private */
|
||||||
rtc.private = RT_NULL;
|
rtc.user_data = RT_NULL;
|
||||||
|
|
||||||
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
|
rt_device_register(&rtc, "rtc", RT_DEVICE_FLAG_RDWR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*/
|
*/
|
||||||
static rt_err_t rt_serial_init (rt_device_t dev)
|
static rt_err_t rt_serial_init (rt_device_t dev)
|
||||||
{
|
{
|
||||||
struct serial_device* uart = (struct serial_device*) dev->private;
|
struct serial_device* uart = (struct serial_device*) dev->user_data;
|
||||||
|
|
||||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
uart = (struct serial_device*)dev->private;
|
uart = (struct serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
|
||||||
|
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
ptr = (rt_uint8_t*)buffer;
|
ptr = (rt_uint8_t*)buffer;
|
||||||
uart = (struct serial_device*)dev->private;
|
uart = (struct serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +246,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
device->read = rt_serial_read;
|
device->read = rt_serial_read;
|
||||||
device->write = rt_serial_write;
|
device->write = rt_serial_write;
|
||||||
device->control = rt_serial_control;
|
device->control = rt_serial_control;
|
||||||
device->private = serial;
|
device->user_data = serial;
|
||||||
|
|
||||||
/* register a character device */
|
/* register a character device */
|
||||||
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
||||||
|
@ -255,7 +255,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
/* ISR for serial interrupt */
|
/* ISR for serial interrupt */
|
||||||
void rt_hw_serial_isr(rt_device_t device)
|
void rt_hw_serial_isr(rt_device_t device)
|
||||||
{
|
{
|
||||||
struct serial_device* uart = (struct serial_device*) device->private;
|
struct serial_device* uart = (struct serial_device*) device->user_data;
|
||||||
|
|
||||||
/* interrupt mode receive */
|
/* interrupt mode receive */
|
||||||
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
|
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
/* RT-Thread Device Interface */
|
/* RT-Thread Device Interface */
|
||||||
static rt_err_t rt_serial_init (rt_device_t dev)
|
static rt_err_t rt_serial_init (rt_device_t dev)
|
||||||
{
|
{
|
||||||
struct serial_device* uart = (struct serial_device*) dev->private;
|
struct serial_device* uart = (struct serial_device*) dev->user_data;
|
||||||
|
|
||||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
uart = (struct serial_device*)dev->private;
|
uart = (struct serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +133,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
|
||||||
|
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
ptr = (rt_uint8_t*)buffer;
|
ptr = (rt_uint8_t*)buffer;
|
||||||
uart = (struct serial_device*)dev->private;
|
uart = (struct serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +225,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
device->read = rt_serial_read;
|
device->read = rt_serial_read;
|
||||||
device->write = rt_serial_write;
|
device->write = rt_serial_write;
|
||||||
device->control = rt_serial_control;
|
device->control = rt_serial_control;
|
||||||
device->private = serial;
|
device->user_data = serial;
|
||||||
|
|
||||||
/* register a character device */
|
/* register a character device */
|
||||||
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
||||||
|
@ -235,7 +235,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
void rt_hw_serial_isr(rt_device_t device)
|
void rt_hw_serial_isr(rt_device_t device)
|
||||||
{
|
{
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
struct serial_device* uart = (struct serial_device*) device->private;
|
struct serial_device* uart = (struct serial_device*) device->user_data;
|
||||||
|
|
||||||
/* interrupt mode receive */
|
/* interrupt mode receive */
|
||||||
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
|
RT_ASSERT(device->flag & RT_DEVICE_FLAG_INT_RX);
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void rt_serial_enable_dma(DMA_Channel_TypeDef* dma_channel,
|
||||||
/* RT-Thread Device Interface */
|
/* RT-Thread Device Interface */
|
||||||
static rt_err_t rt_serial_init (rt_device_t dev)
|
static rt_err_t rt_serial_init (rt_device_t dev)
|
||||||
{
|
{
|
||||||
struct stm32_serial_device* uart = (struct stm32_serial_device*) dev->private;
|
struct stm32_serial_device* uart = (struct stm32_serial_device*) dev->user_data;
|
||||||
|
|
||||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
uart = (struct stm32_serial_device*)dev->private;
|
uart = (struct stm32_serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +161,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
|
||||||
|
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
ptr = (rt_uint8_t*)buffer;
|
ptr = (rt_uint8_t*)buffer;
|
||||||
uart = (struct stm32_serial_device*)dev->private;
|
uart = (struct stm32_serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
||||||
{
|
{
|
||||||
|
@ -259,7 +259,7 @@ static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||||
|
|
||||||
RT_ASSERT(dev != RT_NULL);
|
RT_ASSERT(dev != RT_NULL);
|
||||||
|
|
||||||
uart = (struct stm32_serial_device*)dev->private;
|
uart = (struct stm32_serial_device*)dev->user_data;
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case RT_DEVICE_CTRL_SUSPEND:
|
case RT_DEVICE_CTRL_SUSPEND:
|
||||||
|
@ -301,7 +301,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
device->read = rt_serial_read;
|
device->read = rt_serial_read;
|
||||||
device->write = rt_serial_write;
|
device->write = rt_serial_write;
|
||||||
device->control = rt_serial_control;
|
device->control = rt_serial_control;
|
||||||
device->private = serial;
|
device->user_data = serial;
|
||||||
|
|
||||||
/* register a character device */
|
/* register a character device */
|
||||||
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
||||||
|
@ -310,7 +310,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
/* ISR for serial interrupt */
|
/* ISR for serial interrupt */
|
||||||
void rt_hw_serial_isr(rt_device_t device)
|
void rt_hw_serial_isr(rt_device_t device)
|
||||||
{
|
{
|
||||||
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
|
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->user_data;
|
||||||
|
|
||||||
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
|
@ -374,7 +374,7 @@ void rt_hw_serial_dma_tx_isr(rt_device_t device)
|
||||||
{
|
{
|
||||||
rt_uint32_t level;
|
rt_uint32_t level;
|
||||||
struct stm32_serial_data_node* data_node;
|
struct stm32_serial_data_node* data_node;
|
||||||
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->private;
|
struct stm32_serial_device* uart = (struct stm32_serial_device*) device->user_data;
|
||||||
|
|
||||||
/* DMA mode receive */
|
/* DMA mode receive */
|
||||||
RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_TX);
|
RT_ASSERT(device->flag & RT_DEVICE_FLAG_DMA_TX);
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct avr32_serial_device uart =
|
||||||
/* RT-Thread Device Interface */
|
/* RT-Thread Device Interface */
|
||||||
static rt_err_t rt_serial_init (rt_device_t dev)
|
static rt_err_t rt_serial_init (rt_device_t dev)
|
||||||
{
|
{
|
||||||
struct avr32_serial_device* uart = (struct avr32_serial_device*) dev->private;
|
struct avr32_serial_device* uart = (struct avr32_serial_device*) dev->user_data;
|
||||||
|
|
||||||
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
if (!(dev->flag & RT_DEVICE_FLAG_ACTIVATED))
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
|
||||||
|
|
||||||
ptr = buffer;
|
ptr = buffer;
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
uart = (struct avr32_serial_device*)dev->private;
|
uart = (struct avr32_serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
|
||||||
{
|
{
|
||||||
|
@ -135,7 +135,7 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
|
||||||
|
|
||||||
err_code = RT_EOK;
|
err_code = RT_EOK;
|
||||||
ptr = (rt_uint8_t*)buffer;
|
ptr = (rt_uint8_t*)buffer;
|
||||||
uart = (struct avr32_serial_device*)dev->private;
|
uart = (struct avr32_serial_device*)dev->user_data;
|
||||||
|
|
||||||
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +179,7 @@ static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
|
||||||
|
|
||||||
RT_ASSERT(dev != RT_NULL);
|
RT_ASSERT(dev != RT_NULL);
|
||||||
|
|
||||||
uart = (struct avr32_serial_device*)dev->private;
|
uart = (struct avr32_serial_device*)dev->user_data;
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case RT_DEVICE_CTRL_SUSPEND:
|
case RT_DEVICE_CTRL_SUSPEND:
|
||||||
|
@ -219,7 +219,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
device->read = rt_serial_read;
|
device->read = rt_serial_read;
|
||||||
device->write = rt_serial_write;
|
device->write = rt_serial_write;
|
||||||
device->control = rt_serial_control;
|
device->control = rt_serial_control;
|
||||||
device->private = serial;
|
device->user_data = serial;
|
||||||
|
|
||||||
/* register a character device */
|
/* register a character device */
|
||||||
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
|
||||||
|
@ -228,7 +228,7 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name, rt_uint32_t
|
||||||
/* ISR for serial interrupt */
|
/* ISR for serial interrupt */
|
||||||
void rt_hw_serial_isr(void)
|
void rt_hw_serial_isr(void)
|
||||||
{
|
{
|
||||||
struct avr32_serial_device* uart = (struct avr32_serial_device*) _rt_usart_device.private;
|
struct avr32_serial_device* uart = (struct avr32_serial_device*) _rt_usart_device.user_data;
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
|
|
||||||
if (usart_test_hit(uart->uart_device))
|
if (usart_test_hit(uart->uart_device))
|
||||||
|
|
Loading…
Reference in New Issue