Merge pull request 'FIX usart_tx cannot write values len>1' (#2) from NiclasThobaben/avr-fw-modules:fixes/usart into master

Reviewed-on: #2
master
Harald Wolff 2020-12-20 14:50:51 +01:00
commit ccdbe3ec0b
1 changed files with 10 additions and 5 deletions

View File

@ -79,16 +79,21 @@ int usart_write (uint8_t _usart,int ch){
};
int usart_tx (uint8_t usart,char *b,int size){
int n,r;
int n,r, tries;
tries = 10;
for (n=0;n<size;n++){
for (r=0;r<10;r++){
if (usart_write( usart, *(b++)) >= 0){
return ESUCCESS;
for (r=0;r<tries;r++){
if (usart_write( usart, *b) >= 0){
b++;
break;
};
if(r == tries - 1) {
return -EFAIL;
}
wait_ms(1);
};
};
return -EFAIL;
return ESUCCESS;
};