fix bug in USB CDC

This commit is contained in:
eddyem 2019-07-12 22:33:13 +03:00
parent 9a010dfa13
commit 5f91b4eca7
4 changed files with 8 additions and 21 deletions

View File

@ -315,12 +315,9 @@ static uint16_t EP0_Handler(ep_t ep){
linecoding_handler((usb_LineCoding*)ep0databuf); linecoding_handler((usb_LineCoding*)ep0databuf);
} }
} }
// Close transaction
epstatus = CLEAR_DTOG_RX(epstatus);
epstatus = CLEAR_DTOG_TX(epstatus);
// wait for new data from host // wait for new data from host
epstatus = SET_VALID_RX(epstatus); epstatus = SET_VALID_RX(epstatus);
epstatus = SET_STALL_TX(epstatus); epstatus = SET_VALID_TX(epstatus);
} else if (ep.tx_flag){ // package transmitted } else if (ep.tx_flag){ // package transmitted
// now we can change address after enumeration // now we can change address after enumeration
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){

View File

@ -330,18 +330,14 @@ uint16_t EP0_Handler(ep_t ep){
} }
}else if (ep.rx_flag){ // got data over EP0 or host acknowlegement }else if (ep.rx_flag){ // got data over EP0 or host acknowlegement
if(ep.rx_cnt){ if(ep.rx_cnt){
//EP_WriteIRQ(0, (uint8_t *)0, 0);
if(setup_packet.bRequest == SET_LINE_CODING){ if(setup_packet.bRequest == SET_LINE_CODING){
WRITEDUMP("SET_LINE_CODING");
linecoding_handler((usb_LineCoding*)ep0databuf); linecoding_handler((usb_LineCoding*)ep0databuf);
} }
//EP_WriteIRQ(0, (uint8_t *)0, 0);
} }
// Close transaction
epstatus = CLEAR_DTOG_RX(epstatus);
epstatus = CLEAR_DTOG_TX(epstatus);
// wait for new data from host // wait for new data from host
epstatus = SET_VALID_RX(epstatus); epstatus = SET_VALID_RX(epstatus);
epstatus = SET_STALL_TX(epstatus); epstatus = SET_VALID_TX(epstatus);
} else if (ep.tx_flag){ // package transmitted } else if (ep.tx_flag){ // package transmitted
// now we can change address after enumeration // now we can change address after enumeration
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){

View File

@ -312,12 +312,9 @@ static uint16_t EP0_Handler(ep_t ep){
linecoding_handler((usb_LineCoding*)ep0databuf); linecoding_handler((usb_LineCoding*)ep0databuf);
} }
} }
// Close transaction
epstatus = CLEAR_DTOG_RX(epstatus);
epstatus = CLEAR_DTOG_TX(epstatus);
// wait for new data from host // wait for new data from host
epstatus = SET_VALID_RX(epstatus); epstatus = SET_VALID_RX(epstatus);
epstatus = SET_STALL_TX(epstatus); epstatus = SET_VALID_TX(epstatus);
} else if (ep.tx_flag){ // package transmitted } else if (ep.tx_flag){ // package transmitted
// now we can change address after enumeration // now we can change address after enumeration
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){

View File

@ -312,12 +312,9 @@ static uint16_t EP0_Handler(ep_t ep){
linecoding_handler((usb_LineCoding*)ep0databuf); linecoding_handler((usb_LineCoding*)ep0databuf);
} }
} }
// Close transaction
epstatus = CLEAR_DTOG_RX(epstatus);
epstatus = CLEAR_DTOG_TX(epstatus);
// wait for new data from host // wait for new data from host
epstatus = SET_VALID_RX(epstatus); epstatus = SET_VALID_RX(epstatus);
epstatus = SET_STALL_TX(epstatus); epstatus = SET_VALID_TX(epstatus);
} else if (ep.tx_flag){ // package transmitted } else if (ep.tx_flag){ // package transmitted
// now we can change address after enumeration // now we can change address after enumeration
if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){ if ((USB->DADDR & USB_DADDR_ADD) != USB_Dev.USB_Addr){