mirror of
https://github.com/zsa/qmk_firmware.git
synced 2026-05-04 14:55:29 +00:00
Ensure device address latch bit is not set at the same time as the new address, as per datasheet.
Minor documentation fixes. Fix broken USB host mode due to the USB frame counter not being updated during the early enumeration steps, causing USB_Host_DelayMS() to spinloop forever.
This commit is contained in:
@@ -221,7 +221,8 @@
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
|
||||
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
|
||||
{
|
||||
UDADDR = ((1 << ADDEN) | (Address & 0x7F));
|
||||
UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F));
|
||||
UDADDR |= (1 << ADDEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -194,19 +194,21 @@ void USB_Host_ProcessNextHostState(void)
|
||||
|
||||
uint8_t USB_Host_WaitMS(uint8_t MS)
|
||||
{
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
uint8_t ErrorCode = HOST_WAITERROR_Successful;
|
||||
uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
|
||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||
uint8_t ErrorCode = HOST_WAITERROR_Successful;
|
||||
|
||||
USB_Host_ResumeBus();
|
||||
|
||||
bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
|
||||
|
||||
USB_INT_Disable(USB_INT_HSOFI);
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
|
||||
while (MS)
|
||||
{
|
||||
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
|
||||
|
||||
if (CurrentFrameNumber != PreviousFrameNumber)
|
||||
if (USB_INT_HasOccurred(USB_INT_HSOFI))
|
||||
{
|
||||
PreviousFrameNumber = CurrentFrameNumber;
|
||||
USB_INT_Clear(USB_INT_HSOFI);
|
||||
MS--;
|
||||
}
|
||||
|
||||
@@ -234,6 +236,9 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
|
||||
}
|
||||
}
|
||||
|
||||
if (HSOFIEnabled)
|
||||
USB_INT_Enable(USB_INT_HSOFI);
|
||||
|
||||
if (BusSuspended)
|
||||
USB_Host_SuspendBus();
|
||||
|
||||
|
||||
@@ -34,14 +34,17 @@
|
||||
void USB_INT_DisableAllInterrupts(void)
|
||||
{
|
||||
#if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
|
||||
USBCON &= ~((1 << VBUSTE) | (1 << IDTE));
|
||||
USBCON &= ~((1 << OTGPADE) | (1 << VBUSTE) | (1 << IDTE));
|
||||
#elif defined(USB_SERIES_4_AVR)
|
||||
USBCON &= ~(1 << VBUSTE);
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
OTGIEN = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
UHIEN = 0;
|
||||
OTGIEN = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
@@ -55,9 +58,12 @@ void USB_INT_ClearAllInterrupts(void)
|
||||
USBINT = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
OTGINT = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
UHINT = 0;
|
||||
OTGINT = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
|
||||
Reference in New Issue
Block a user