I can't understand this shit with UART!

This commit is contained in:
Edward Emelianov
2023-09-15 23:43:35 +03:00
parent 94f87db5c5
commit a8296717e1
8 changed files with 28 additions and 23 deletions

View File

@@ -56,9 +56,20 @@ uint8_t noLED =
void sendbuf(){
IWDG->KR = IWDG_REFRESH;
if(blen == 0) return;
#ifdef EBUG
USB_send(" sendbuf()\n");
#endif
*bptr = 0;
if(USBcmd) USB_send(buff);
else for(int i = 0; (i < 9999) && (LINE_BUSY == usart_send(buff, blen)); ++i){IWDG->KR = IWDG_REFRESH;}
else for(int i = 0; (i < WAITFOR) && (LINE_BUSY == usart_send(buff, blen)); ++i){
#ifdef EBUG
USB_send(" line busy\n");
#endif
IWDG->KR = IWDG_REFRESH;
}
#ifdef EBUG
USB_send(" sendbuf() done\n");
#endif
bptr = buff;
blen = 0;
}
@@ -69,7 +80,7 @@ void addtobuf(const char *txt){
if(l > UARTBUFSZ){
sendbuf(); // send prevoius data in buffer
if(USBcmd) USB_send(txt);
else for(int i = 0; (i < 9999) && (LINE_BUSY == usart_send_blocking(txt, l)); ++i){IWDG->KR = IWDG_REFRESH;}
else for(int i = 0; (i < WAITFOR) && (LINE_BUSY == usart_send_blocking(txt, l)); ++i){IWDG->KR = IWDG_REFRESH;}
}else{
if(blen+l > UARTBUFSZ){
sendbuf();