summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/portable/st/typec/typec_stm32.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/portable/st/typec/typec_stm32.c b/src/portable/st/typec/typec_stm32.c
index 5fa53fe42..7db816396 100644
--- a/src/portable/st/typec/typec_stm32.c
+++ b/src/portable/st/typec/typec_stm32.c
@@ -173,9 +173,6 @@ TU_ATTR_ALWAYS_INLINE static inline void dma_start(uint8_t rhport, bool is_rx, v
}
// High priority
dma_ch->CCR = DMA_CCR_PRIO | DMA_CCR_EN;
- if (is_rx) {
- } else {
- }
#endif
}
@@ -299,6 +296,10 @@ void tcd_disconnect(uint8_t rhport) {
return;
}
+ // Mask UCPD interrupts/DMA early to avoid the ISR touching DMA/pointers while we tear down.
+ UCPD1->IMR &= ~(UCPD_IMR_TYPECEVT1IE | UCPD_IMR_TYPECEVT2IE | IMR_ATTACHED);
+ UCPD1->CFG1 &= ~(UCPD_CFG1_RXDMAEN | UCPD_CFG1_TXDMAEN);
+
_cc_enabled[rhport] = false;
if (dma_enabled(rhport, true)) {
@@ -315,9 +316,6 @@ void tcd_disconnect(uint8_t rhport) {
_tx_pending_bytes = 0;
_tx_xferring_bytes = 0;
- UCPD1->CFG1 &= ~(UCPD_CFG1_RXDMAEN | UCPD_CFG1_TXDMAEN);
- UCPD1->IMR &= ~(UCPD_IMR_TYPECEVT1IE | UCPD_IMR_TYPECEVT2IE | IMR_ATTACHED);
-
uint32_t cr = UCPD1->CR;
cr &= ~(UCPD_CR_PHYRXEN | UCPD_CR_PHYCCSEL | UCPD_CR_CCENABLE);
UCPD1->CR = cr;