add LIDAR chronometer (pre-alpha)

This commit is contained in:
eddyem
2019-06-27 21:12:42 +03:00
parent a4c08dc741
commit 3a5ef823db
38 changed files with 34574 additions and 1 deletions

Binary file not shown.

View File

@@ -144,7 +144,7 @@ void USB_send(char *buf){
* @param buf (i) - buffer for received data
* @param bufsize - its size
* @return amount of received bytes
*/
*
int USB_receive(char *buf, int bufsize){
if(!bufsize || !idatalen) return 0;
USB->CNTR = 0;
@@ -163,6 +163,36 @@ int USB_receive(char *buf, int bufsize){
}
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM;
return sz;
}*/
int USB_receive(char *buf, int bufsize){
if(bufsize<1 || !idatalen) return 0;
IWDG->KR = IWDG_REFRESH;
int stlen = 0;
for(int i = 0; i < idatalen; ++i){
if(incoming_data[i] == '\n'){
stlen = i+1;
incoming_data[i] = 0;
break;
}
}
if(stlen == 0) return 0;
USB->CNTR = 0;
int sz = (stlen > bufsize) ? bufsize : stlen, rest = idatalen - sz;
memcpy(buf, incoming_data, sz);
if(rest > 0){
memmove(incoming_data, &incoming_data[sz], rest);
idatalen = rest;
}else idatalen = 0;
if(ovfl){
EP23_Handler(endpoints[2]);
uint16_t epstatus = USB->EPnR[2];
epstatus = CLEAR_DTOG_RX(epstatus);
epstatus = SET_VALID_RX(epstatus);
USB->EPnR[2] = epstatus;
}
USB->CNTR = USB_CNTR_RESETM | USB_CNTR_CTRM;
return sz;
}
/**