summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2026-06-24 21:36:03 +0200
committerHiFiPhile <[email protected]>2026-06-24 21:36:03 +0200
commit1c267bf61d6f844906bb55aef1c314342ef210d6 (patch)
treef23be77486b621d582838d26911de1f89a601813
parent87a98641e4e9315577ec8f83827474e243983a55 (diff)
apply review suggestions
Signed-off-by: HiFiPhile <[email protected]>
-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;