@@ -459,13 +459,9 @@ static const tusb_desc_endpoint_t ep0IN_desc = {
459
459
460
460
static void dcd_handle_bus_reset (void )
461
461
{
462
- //__IO uint16_t * const epreg = &(EPREG(0));
463
462
USB -> DADDR = 0u ; // disable USB peripheral by clearing the EF flag
464
463
465
464
for (uint32_t i = 0 ; i < STFSDEV_EP_COUNT ; i ++ ) {
466
- // Clear all EPREG (or maybe this is automatic? I'm not sure)
467
- pcd_set_endpoint (USB , i , 0u );
468
-
469
465
// Clear EP allocation status
470
466
ep_alloc_status [i ].ep_num = 0xFF ;
471
467
ep_alloc_status [i ].ep_type = 0xFF ;
@@ -624,7 +620,6 @@ static void dcd_ep_ctr_rx_handler(uint32_t wIstr)
624
620
uint16_t remaining = xfer -> total_len - xfer -> queued_len ;
625
621
uint16_t cnt = tu_min16 (remaining , xfer -> max_packet_size );
626
622
pcd_set_ep_rx_cnt (USB , EPindex , cnt );
627
- pcd_set_ep_rx_cnt (USB , EPindex , remaining );
628
623
}
629
624
pcd_set_ep_rx_status (USB , EPindex , USB_EP_RX_VALID );
630
625
}
@@ -869,7 +864,19 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *p_endpoint_desc)
869
864
void dcd_edpt_close_all (uint8_t rhport )
870
865
{
871
866
(void )rhport ;
872
- // TODO implement dcd_edpt_close_all()
867
+
868
+ for (uint32_t i = 1 ; i < STFSDEV_EP_COUNT ; i ++ ) {
869
+ // Reset endpoint
870
+ pcd_set_endpoint (USB , i , 0 );
871
+ // Clear EP allocation status
872
+ ep_alloc_status [i ].ep_num = 0xFF ;
873
+ ep_alloc_status [i ].ep_type = 0xFF ;
874
+ ep_alloc_status [i ].allocated [0 ] = false;
875
+ ep_alloc_status [i ].allocated [1 ] = false;
876
+ }
877
+
878
+ // Reset PMA allocation
879
+ ep_buf_ptr = DCD_STM32_BTABLE_BASE + 8 * MAX_EP_COUNT + 2 * CFG_TUD_ENDPOINT0_SIZE ;
873
880
}
874
881
875
882
/**
0 commit comments