fix bug in simulator/drivers/serial.c which deadlock may happen if multi-uart both output use printf
This commit is contained in:
parent
1c522be515
commit
81751d99cc
@ -151,6 +151,7 @@ static rt_size_t rt_serial_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_
|
|||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
int level;
|
||||||
#if _DEBUG_SERIAL==1
|
#if _DEBUG_SERIAL==1
|
||||||
printf("in rt_serial_write()\n");
|
printf("in rt_serial_write()\n");
|
||||||
#endif
|
#endif
|
||||||
@ -162,8 +163,10 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buff
|
|||||||
fwrite(buffer, size, 1, fp);
|
fwrite(buffer, size, 1, fp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
level = rt_hw_interrupt_disable();
|
||||||
printf("%s", (char *)buffer);
|
printf("%s", (char *)buffer);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
rt_hw_interrupt_enable(level);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user