Skip to content

Commit 48b1e73

Browse files
authored
Merge pull request #2592 from HiFiPhile/fsdev_close
FSDEV: Implement dcd_edpt_close_all()
2 parents 6144da9 + 049ceda commit 48b1e73

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,9 @@ static const tusb_desc_endpoint_t ep0IN_desc = {
459459

460460
static void dcd_handle_bus_reset(void)
461461
{
462-
//__IO uint16_t * const epreg = &(EPREG(0));
463462
USB->DADDR = 0u; // disable USB peripheral by clearing the EF flag
464463

465464
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-
469465
// Clear EP allocation status
470466
ep_alloc_status[i].ep_num = 0xFF;
471467
ep_alloc_status[i].ep_type = 0xFF;
@@ -624,7 +620,6 @@ static void dcd_ep_ctr_rx_handler(uint32_t wIstr)
624620
uint16_t remaining = xfer->total_len - xfer->queued_len;
625621
uint16_t cnt = tu_min16(remaining, xfer->max_packet_size);
626622
pcd_set_ep_rx_cnt(USB, EPindex, cnt);
627-
pcd_set_ep_rx_cnt(USB, EPindex, remaining);
628623
}
629624
pcd_set_ep_rx_status(USB, EPindex, USB_EP_RX_VALID);
630625
}
@@ -869,7 +864,19 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const *p_endpoint_desc)
869864
void dcd_edpt_close_all(uint8_t rhport)
870865
{
871866
(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;
873880
}
874881

875882
/**

0 commit comments

Comments
 (0)