You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a translator, so please understand. Thank you sir.
change the getc() code location
The code below is only applied to uart1, so it seems like it should be applied to other codes as well.
/* uart1_getc */ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
if (UART1_RxHead==UART1_RxTail) {
returnUART_NO_DATA; /* no data available */
}
/* calculate / store buffer index */tmptail= (UART1_RxTail+1) &UART_RX1_BUFFER_MASK;
UART1_RxTail=tmptail;
}
/* uart0_getc */ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
if (UART_RxHead==UART_RxTail) {
returnUART_NO_DATA; /* no data available */
}
}
/* calculate / store buffer index */tmptail= (UART_RxTail+1) &UART_RX0_BUFFER_MASK;
UART_RxTail=tmptail; // <- This is not atomic when LARGE_BUFFER.
I think it would be better to do something like below. It was also applied to peek.
/* uart1_getc */#ifdefUSART1_LARGE_BUFFERATOMIC_BLOCK(ATOMIC_RESTORESTATE)
#endif
{
if (UART1_RxHead==UART1_RxTail) {
returnUART_NO_DATA; /* no data available */
}
/* calculate / store buffer index */tmptail= (UART1_RxTail+1) &UART_RX1_BUFFER_MASK;
UART1_RxTail=tmptail;
}
putc atomic
When LARGE_BUFFER, UART1_TxHead is uint16_t. So the code below is not atomic.
UART1_TxHead=tmphead;
I think it would be good to change it atomically as follows.
I am using a translator, so please understand. Thank you sir.
change the getc() code location
The code below is only applied to uart1, so it seems like it should be applied to other codes as well.
I think it would be better to do something like below. It was also applied to peek.
putc atomic
When
LARGE_BUFFER
,UART1_TxHead
isuint16_t
. So the code below is not atomic.I think it would be good to change it atomically as follows.
There are a lot of duplicates, so I think it would be better to do something like this:
If you agree with this, I'll put in a pull request.
The text was updated successfully, but these errors were encountered: