samd/mphalport: Fix USB CDC tx handling to work reliably.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
f31c6b4840
commit
ede6b86a08
@ -80,17 +80,16 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
|
|||||||
if (tud_cdc_connected()) {
|
if (tud_cdc_connected()) {
|
||||||
for (size_t i = 0; i < len;) {
|
for (size_t i = 0; i < len;) {
|
||||||
uint32_t n = len - i;
|
uint32_t n = len - i;
|
||||||
uint32_t n2 = tud_cdc_write(str + i, n);
|
if (n > CFG_TUD_CDC_EP_BUFSIZE) {
|
||||||
if (n2 < n) {
|
n = CFG_TUD_CDC_EP_BUFSIZE;
|
||||||
while (!tud_cdc_write_flush()) {
|
|
||||||
__WFI();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
while (n > tud_cdc_write_available()) {
|
||||||
|
__WFI();
|
||||||
|
}
|
||||||
|
uint32_t n2 = tud_cdc_write(str + i, n);
|
||||||
|
tud_cdc_write_flush();
|
||||||
i += n2;
|
i += n2;
|
||||||
}
|
}
|
||||||
while (!tud_cdc_write_flush()) {
|
|
||||||
__WFI();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (len--) {
|
while (len--) {
|
||||||
while (!(USARTx->USART.INTFLAG.bit.DRE)) {
|
while (!(USARTx->USART.INTFLAG.bit.DRE)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user