From 552cc3ef33aee21eba3ea60ad07c461181eeaa58 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 28 Nov 2019 11:56:35 +0700 Subject: [PATCH] implement dcd_edpt_stall --- src/portable/microchip/samg/dcd_samg.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/portable/microchip/samg/dcd_samg.c b/src/portable/microchip/samg/dcd_samg.c index bf842eab..1d2e150d 100644 --- a/src/portable/microchip/samg/dcd_samg.c +++ b/src/portable/microchip/samg/dcd_samg.c @@ -215,7 +215,12 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr) { (void) rhport; - (void) ep_addr; + + uint8_t const epnum = tu_edpt_number(ep_addr); +// uint8_t const dir = tu_edpt_dir(ep_addr); + + // Set force stall bit + UDP->UDP_CSR[epnum] |= UDP_CSR_FORCESTALL_Msk; } // clear stall, data toggle is also reset to DATA0 @@ -302,6 +307,12 @@ void dcd_isr(uint8_t rhport) // Clear DATA Bank0 bit UDP->UDP_CSR[0] &= ~UDP_CSR_RX_DATA_BK0_Msk; } + + // Stall sent to host + if (UDP->UDP_CSR[epnum] & UDP_CSR_STALLSENT_Msk) + { + UDP->UDP_CSR[0] &= ~UDP_CSR_STALLSENT_Msk; + } } }