Fix dcd_set_address bug when called more than once with different

addresses (e.g. after plugging the device into a different port).
This commit is contained in:
Tobias Ringström 2021-08-13 14:11:14 +02:00
parent 89e4586653
commit 0ec794376b
1 changed files with 1 additions and 1 deletions

View File

@ -519,7 +519,7 @@ void dcd_int_disable (uint8_t rhport)
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
{
USB_OTG_DeviceTypeDef * dev = DEVICE_BASE(rhport);
dev->DCFG |= (dev_addr << USB_OTG_DCFG_DAD_Pos) & USB_OTG_DCFG_DAD_Msk;
dev->DCFG = (dev->DCFG & ~USB_OTG_DCFG_DAD_Msk) | (dev_addr << USB_OTG_DCFG_DAD_Pos);
// Response with status after changing device address
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);