Signed-off-by: visitor83 <wolflouiswang@gmail.com>

format the s3c24x0 serial.c and mini2440 rtconfig.py
This commit is contained in:
visitor83 2013-06-18 12:51:55 +08:00
parent 7f4235802f
commit c986754c49
4 changed files with 219 additions and 207 deletions

View File

@ -26,7 +26,7 @@
/**
* This function initializes serial
*/
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->user_data;
@ -92,7 +92,7 @@ static rt_err_t rt_serial_close(rt_device_t dev)
return RT_EOK;
}
static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_size_t size)
{
rt_uint8_t* ptr;
rt_err_t err_code;
@ -102,6 +102,12 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
err_code = RT_EOK;
uart = (struct serial_device*)dev->user_data;
if (ptr == RT_NULL)
{
err_code = -RT_ENOMEM;
rt_set_errno(err_code);
return -RT_ENOMEM;
}
if (dev->flag & RT_DEVICE_FLAG_INT_RX)
{
rt_base_t level;
@ -150,7 +156,7 @@ static rt_size_t rt_serial_read (rt_device_t dev, rt_off_t pos, void* buffer, rt
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
}
static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void* buffer, rt_size_t size)
{
rt_uint8_t* ptr;
rt_err_t err_code;
@ -160,6 +166,12 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
ptr = (rt_uint8_t*)buffer;
uart = (struct serial_device*)dev->user_data;
if (ptr == RT_NULL)
{
err_code = -RT_ENOMEM;
rt_set_errno(err_code);
return -RT_ENOMEM;
}
if (dev->flag & RT_DEVICE_FLAG_INT_TX)
{
/* interrupt mode Tx */
@ -200,17 +212,17 @@ static rt_size_t rt_serial_write (rt_device_t dev, rt_off_t pos, const void* buf
while (!(uart->uart_device->ustat & USTAT_TXB_EMPTY));
uart->uart_device->utxh = (*ptr & 0xFF);
++ptr; --size;
++ptr;
--size;
}
}
/* set error code */
rt_set_errno(err_code);
return (rt_uint32_t)ptr - (rt_uint32_t)buffer;
}
static rt_err_t rt_serial_control (rt_device_t dev, rt_uint8_t cmd, void *args)
static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args)
{
RT_ASSERT(dev != RT_NULL);