Skip to content

Commit 3b026b4

Browse files
committed
drivers: usb: udc: rpi_pico: Improve transfer abortion detection
Incorporate the method of Pico-SDK's to improve the detection of transfer abortion. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent 798e7ec commit 3b026b4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/usb/udc/udc_rpi_pico.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ static void write_ep_ctrl_reg(const struct device *dev, const uint8_t ep,
162162

163163
static void rpi_pico_ep_cancel(const struct device *dev, const uint8_t ep)
164164
{
165-
bool abort_handshake_supported = rp2040_chip_version() >= 2;
165+
#ifdef CONFIG_SOC_SERIES_RP2040
166+
const bool abort_handshake_supported = rp2040_chip_version() >= 2;
167+
#else
168+
const bool abort_handshake_supported = true;
169+
#endif
166170
const struct rpi_pico_config *config = dev->config;
167171
usb_hw_t *base = config->base;
168172
mm_reg_t abort_done_reg = (mm_reg_t)&base->abort_done;
@@ -177,8 +181,10 @@ static void rpi_pico_ep_cancel(const struct device *dev, const uint8_t ep)
177181
}
178182

179183
if (abort_handshake_supported) {
184+
rpi_pico_bit_clr(abort_done_reg, ep_mask);
180185
rpi_pico_bit_set(abort_reg, ep_mask);
181186
while ((sys_read32(abort_done_reg) & ep_mask) != ep_mask) {
187+
rpi_pico_bit_set(abort_reg, ep_mask);
182188
}
183189
}
184190

@@ -187,6 +193,7 @@ static void rpi_pico_ep_cancel(const struct device *dev, const uint8_t ep)
187193

188194
if (abort_handshake_supported) {
189195
rpi_pico_bit_clr(abort_reg, ep_mask);
196+
rpi_pico_bit_clr(abort_done_reg, ep_mask);
190197
}
191198

192199
LOG_INF("Canceled ep 0x%02x transaction", ep);

0 commit comments

Comments
 (0)