*** EFM32 branch ***
Fix the bug in USART write, which is introduced by changing SPI write format git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1884 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
10ec208306
commit
3f0b614ad3
|
@ -505,7 +505,7 @@ static rt_size_t rt_usart_read (
|
|||
while (!(usart_device->STATUS & rx_flag));
|
||||
*((rt_uint32_t *)0x00) = usart_device->RXDATA;
|
||||
}
|
||||
|
||||
/* Read data */
|
||||
while (((rt_uint32_t)ptr - (rt_uint32_t)rx_buf) < size)
|
||||
{
|
||||
/* dummy write */
|
||||
|
@ -575,9 +575,7 @@ static rt_size_t rt_usart_write (
|
|||
rt_err_t err_code;
|
||||
rt_size_t write_size = 0;
|
||||
struct efm32_usart_device_t* usart = (struct efm32_usart_device_t*)(dev->user_data);
|
||||
rt_uint8_t inst_len = *((rt_uint8_t *)buffer);
|
||||
rt_uint8_t *inst_ptr = (rt_uint8_t *)(buffer + 1);
|
||||
rt_uint8_t *tx_buf = *((rt_uint8_t **)(buffer + inst_len + 1));
|
||||
rt_uint8_t *tx_buf;
|
||||
rt_uint32_t tx_flag, b8_flag;
|
||||
|
||||
#if defined(UART_PRESENT)
|
||||
|
@ -608,15 +606,11 @@ static rt_size_t rt_usart_write (
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (dev->flag & RT_DEVICE_FLAG_STREAM)
|
||||
{
|
||||
if (*(tx_buf + size - 1) == '\n')
|
||||
{
|
||||
*(tx_buf + size - 1) = '\r';
|
||||
*(tx_buf + size++) = '\n';
|
||||
*(tx_buf + size) = 0;
|
||||
}
|
||||
}
|
||||
if (usart->state & USART_STATE_SYNC)
|
||||
{ /* SPI write */
|
||||
rt_uint8_t inst_len = *((rt_uint8_t *)buffer);
|
||||
rt_uint8_t *inst_ptr = (rt_uint8_t *)(buffer + 1);
|
||||
tx_buf = *((rt_uint8_t **)(buffer + inst_len + 1));
|
||||
|
||||
/* Write instructions */
|
||||
if (inst_len)
|
||||
|
@ -674,8 +668,22 @@ static rt_size_t rt_usart_write (
|
|||
usart->usart_device->CTRL |= b8_flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tx_buf = (rt_uint8_t *)buffer;
|
||||
}
|
||||
|
||||
/* Write data */
|
||||
if (dev->flag & RT_DEVICE_FLAG_STREAM)
|
||||
{
|
||||
if (*(tx_buf + size - 1) == '\n')
|
||||
{
|
||||
*(tx_buf + size - 1) = '\r';
|
||||
*(tx_buf + size++) = '\n';
|
||||
*(tx_buf + size) = 0;
|
||||
}
|
||||
}
|
||||
if ((dev->flag & RT_DEVICE_FLAG_DMA_TX) && (size > 2))
|
||||
{ /* DMA mode Tx */
|
||||
struct efm32_usart_dma_mode_t *dma_tx;
|
||||
|
|
Loading…
Reference in New Issue