mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 02:35:23 +03:00
fixed bug when sending data larger than buffer size
This commit is contained in:
parent
c7f6718d2e
commit
f994799353
@ -165,7 +165,16 @@ int USB_sendall(){
|
||||
int USB_send(const uint8_t *buf, int len){
|
||||
if(!buf || !CDCready || !len) return FALSE;
|
||||
while(len){
|
||||
int a = RB_write((ringbuffer*)&rbout, buf, len);
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
int l = RB_datalen((ringbuffer*)&rbout);
|
||||
if(l < 0) continue;
|
||||
int portion = rbout.length - 1 - l;
|
||||
if(portion < 1){
|
||||
if(lastdsz == 0) send_next();
|
||||
continue;
|
||||
}
|
||||
if(portion > len) portion = len;
|
||||
int a = RB_write((ringbuffer*)&rbout, buf, portion);
|
||||
if(a > 0){
|
||||
len -= a;
|
||||
buf += a;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user