summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2019-09-11 09:43:57 -0400
committerNathan Conrad <[email protected]>2019-09-11 09:43:57 -0400
commit4cf2b307593837b9a71dca3ab5b4a3e17aa9ef1b (patch)
treec5d90725e23d797ec80f6c54e04fe2df0848a14b
parent9cc355d302e5046295bfd4c1d94f182b92710d64 (diff)
Fix bug where the EPREGs were not being initialized as expected.
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c11
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h5
2 files changed, 8 insertions, 8 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index 1681d6412..b8353b7ca 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -216,10 +216,11 @@ void dcd_init (uint8_t rhport)
USB->ISTR &= ~(USB_ISTR_ALL_EVENTS); // Clear pending interrupts
- // Clear all EPREG
- for(uint16_t i=0; i<8; i++)
+ // Reset endpoints to disabled
+ for(uint i=0; i<STFSDEV_EP_COUNT; i++)
{
- EPREG(0) = 0u;
+ // This doesn't clear all bits since some bits are "toggle", but does set the type to DISABLED.
+ PCD_GET_ENDPOINT(USB,i) = 0u;
}
// Initialize the BTABLE for EP0 at this point (though setting up the EP0R is unneeded)
@@ -327,9 +328,9 @@ static void dcd_handle_bus_reset(void)
USB->DADDR = 0u; // disable USB peripheral by clearing the EF flag
// Clear all EPREG (or maybe this is automatic? I'm not sure)
- for(uint16_t i=0; i<8; i++)
+ for(uint i=0; i<STFSDEV_EP_COUNT; i++)
{
- EPREG(0) = 0u;
+ PCD_GET_ENDPOINT(USB,i) = 0u;
}
ep_buf_ptr = DCD_STM32_BTABLE_BASE + 8*MAX_EP_COUNT; // 8 bytes per endpoint (two TX and two RX words, each)
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
index 4f46e81c4..586d94abf 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
@@ -271,9 +271,6 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
#define PCD_CLEAR_EP_KIND(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
(USB_EP_CTR_RX|USB_EP_CTR_TX|((((uint32_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)))) & USB_EPKIND_MASK)))))
-
-#define EPREG(n) (((__IO uint16_t*)USB_BASE)[n*2])
-
// This checks if the device has "LPM"
#if defined(USB_ISTR_L1REQ)
#define USB_ISTR_L1REQ_FORCED (USB_ISTR_L1REQ)
@@ -284,5 +281,7 @@ static __IO uint16_t * const pma = (__IO uint16_t*)USB_PMAADDR;
#define USB_ISTR_ALL_EVENTS (USB_ISTR_PMAOVR | USB_ISTR_ERR | USB_ISTR_WKUP | USB_ISTR_SUSP | \
USB_ISTR_RESET | USB_ISTR_SOF | USB_ISTR_ESOF | USB_ISTR_L1REQ_FORCED )
+// Number of endpoints in hardware
+#define STFSDEV_EP_COUNT (8)
#endif /* PORTABLE_ST_STM32F0_DCD_STM32F0_FSDEV_PVT_ST_H_ */