still have unknown problems

This commit is contained in:
eddyem
2023-04-26 23:15:52 +03:00
parent b9cb9f6428
commit 3c7687bb0e
11 changed files with 108 additions and 78 deletions

View File

@@ -75,6 +75,7 @@ int EP_Init(uint8_t number, uint8_t type, uint16_t txsz, uint16_t rxsz, void (*f
// standard IRQ handler
void usb_lp_isr(){
static uint8_t oldusbon = 0; // to store flags while suspended
if(USB->ISTR & USB_ISTR_RESET){
usbON = 0;
// Reinit registers
@@ -111,6 +112,7 @@ void usb_lp_isr(){
if(endpoints[n].func) endpoints[n].func(n);
}
if(USB->ISTR & USB_ISTR_SUSP){ // suspend -> still no connection, may sleep
oldusbon = usbON;
usbON = 0;
USB->CNTR |= USB_CNTR_FSUSP | USB_CNTR_LP_MODE;
USB->ISTR = ~USB_ISTR_SUSP;
@@ -118,7 +120,7 @@ void usb_lp_isr(){
if(USB->ISTR & USB_ISTR_WKUP){ // wakeup
USB->CNTR &= ~(USB_CNTR_FSUSP | USB_CNTR_LP_MODE); // clear suspend flags
USB->ISTR = ~USB_ISTR_WKUP;
usbON = 1;
usbON = oldusbon;
}
}