commit
166531168d
|
@ -218,7 +218,9 @@ static const struct rt_uart_ops _k60_ops =
|
|||
|
||||
void UART5_RX_TX_IRQHandler(void)
|
||||
{
|
||||
rt_interrupt_enter();
|
||||
rt_hw_serial_isr((struct rt_serial_device*)&_k60_serial);
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -222,6 +222,10 @@ static rt_size_t rt_serial_read(struct rt_device *dev,
|
|||
struct rt_serial_device *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
ptr = (rt_uint8_t *)buffer;
|
||||
|
@ -253,8 +257,8 @@ static rt_size_t rt_serial_read(struct rt_device *dev,
|
|||
}
|
||||
|
||||
read_nbytes = (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
||||
/* set error code */
|
||||
if (read_nbytes == 0)
|
||||
/* set error code if and only if in thread context */
|
||||
if (read_nbytes == 0 && !rt_interrupt_get_nest())
|
||||
{
|
||||
rt_set_errno(-RT_EEMPTY);
|
||||
}
|
||||
|
@ -272,6 +276,10 @@ static rt_size_t rt_serial_write(struct rt_device *dev,
|
|||
struct rt_serial_device *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
serial = (struct rt_serial_device *)dev;
|
||||
|
||||
ptr = (rt_uint8_t*)buffer;
|
||||
|
@ -341,7 +349,8 @@ static rt_size_t rt_serial_write(struct rt_device *dev,
|
|||
}
|
||||
|
||||
write_nbytes = (rt_uint32_t)ptr - (rt_uint32_t)buffer;
|
||||
if (write_nbytes == 0)
|
||||
/* set error code if and only if in thread context */
|
||||
if (write_nbytes == 0 && !rt_interrupt_get_nest())
|
||||
{
|
||||
rt_set_errno(-RT_EFULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue