Modify the loop of usart_block_sendrecv.

This commit is contained in:
NIIBE Yutaka
2019-04-09 08:51:23 +09:00
parent 8c045a6b8d
commit 7f4eae6c56

View File

@@ -833,31 +833,30 @@ usart_block_sendrecv (uint8_t dev_no, const char *s_buf, uint16_t s_buflen,
asm volatile ("" : : "r" (data) : "memory");
}
/* Not ready? Then, poll again. */
if (!(smartcard_mode && (r & USART_SR_TC))
&& !(!smartcard_mode && (r & USART_SR_TXE)))
continue;
if (s_buflen == 0)
if ((smartcard_mode && (r & USART_SR_TC))
|| (!smartcard_mode && (r & USART_SR_TXE)))
{
if (smartcard_mode)
USARTx->CR1 &= ~USART_CR1_TCIE;
if (s_buflen == 0)
break;
else
USARTx->CR1 &= ~USART_CR1_TXEIE;
chopstx_intr_done (usartx_intr);
break;
}
else
{
chopstx_intr_done (usartx_intr);
/* Keep TCIE or TXEIE bit */
USARTx->DR = *p++;
s_buflen--;
{
/* Keep TCIE or TXEIE bit */
USARTx->DR = *p++;
s_buflen--;
}
}
chopstx_intr_done (usartx_intr);
}
if (smartcard_mode)
usart_config_recv_enable (USARTx, 1);
{
usart_config_recv_enable (USARTx, 1);
USARTx->CR1 &= ~USART_CR1_TCIE;
}
else
USARTx->CR1 &= ~USART_CR1_TXEIE;
chopstx_intr_done (usartx_intr);
}
p = (uint8_t *)r_buf;