mirror of
https://github.com/eddyem/stm32samples.git
synced 2025-12-06 10:45:11 +03:00
fixed some problems with USB
This commit is contained in:
parent
e5b3edeffa
commit
c449cb7108
@ -211,6 +211,7 @@ void usb_class_request(config_pack_t *req, uint8_t *data, uint16_t datalen){
|
||||
int USB_sendall(uint8_t ifno){
|
||||
while(lastdsz[ifno] > 0){
|
||||
if(!CDCready[ifno]) return FALSE;
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -220,12 +221,13 @@ int USB_send(uint8_t ifno, const uint8_t *buf, int len){
|
||||
if(!buf || !CDCready[ifno] || !len) return FALSE;
|
||||
DBG("USB_send");
|
||||
while(len){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
int a = RB_write((ringbuffer*)&rbout[ifno], buf, len);
|
||||
if(lastdsz[ifno] == 0) send_next(ifno); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(a > 0){
|
||||
len -= a;
|
||||
buf += a;
|
||||
} else if (a < 0) continue; // do nothing if buffer is in reading state
|
||||
if(lastdsz[ifno] == 0) send_next(ifno); // need to run manually - all data sent, so no IRQ on IN
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -234,9 +236,10 @@ int USB_putbyte(uint8_t ifno, uint8_t byte){
|
||||
if(!CDCready[ifno]) return FALSE;
|
||||
int l = 0;
|
||||
while((l = RB_write((ringbuffer*)&rbout[ifno], &byte, 1)) != 1){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
if(lastdsz[ifno] == 0) send_next(ifno); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(l < 0) continue;
|
||||
}
|
||||
if(lastdsz[ifno] == 0) send_next(ifno); // need to run manually - all data sent, so no IRQ on IN
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -183,6 +183,7 @@ void usb_class_request(config_pack_t *req, uint8_t *data, uint16_t datalen){
|
||||
int USB_sendall(){
|
||||
while(lastdsz > 0){
|
||||
if(!CDCready) return FALSE;
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -192,12 +193,13 @@ int USB_send(const uint8_t *buf, int len){
|
||||
if(!buf || !CDCready || !len) return FALSE;
|
||||
DBG("USB_send");
|
||||
while(len){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
int a = RB_write((ringbuffer*)&rbout, buf, len);
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(a > 0){
|
||||
len -= a;
|
||||
buf += a;
|
||||
} else if (a < 0) continue; // do nothing if buffer is in reading state
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -206,9 +208,10 @@ int USB_putbyte(uint8_t byte){
|
||||
if(!CDCready) return FALSE;
|
||||
int l = 0;
|
||||
while((l = RB_write((ringbuffer*)&rbout, &byte, 1)) != 1){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(l < 0) continue;
|
||||
}
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ int USB_send(uint8_t *buf, uint16_t size){
|
||||
if(!usbON || !size) return 0;
|
||||
uint16_t ctr = 0;
|
||||
while(size){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
uint16_t s = (size > USB_EP1BUFSZ) ? USB_EP1BUFSZ : size;
|
||||
tx_succesfull = 0;
|
||||
EP_Write(1, (uint8_t*)&buf[ctr], s);
|
||||
|
||||
@ -223,6 +223,7 @@ void usb_vendor_request(config_pack_t *req, uint8_t _U_ *data, uint16_t _U_ data
|
||||
int USB_sendall(){
|
||||
while(lastdsz > 0){
|
||||
if(!CDCready) return FALSE;
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -232,12 +233,13 @@ int USB_send(const uint8_t *buf, int len){
|
||||
if(!buf || !CDCready || !len) return FALSE;
|
||||
DBG("send");
|
||||
while(len){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
int a = RB_write((ringbuffer*)&rbout, buf, len);
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(a > 0){
|
||||
len -= a;
|
||||
buf += a;
|
||||
} else if (a < 0) continue; // do nothing if buffer is in reading state
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -246,9 +248,10 @@ int USB_putbyte(uint8_t byte){
|
||||
if(!CDCready) return FALSE;
|
||||
int l = 0;
|
||||
while((l = RB_write((ringbuffer*)&rbout, &byte, 1)) != 1){
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
if(l < 0) continue;
|
||||
}
|
||||
if(lastdsz == 0) send_next(); // need to run manually - all data sent, so no IRQ on IN
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user