Fix SOF timer bug

This commit is contained in:
ergo720 2018-05-31 12:59:10 +02:00
parent 828822c695
commit ea164dd769
2 changed files with 14 additions and 8 deletions

View File

@ -139,7 +139,7 @@ void OHCI::OHCI_FrameBoundaryWorker()
} }
// Do SOF stuff here // Do SOF stuff here
OHCI_SOF(); OHCI_SOF(false);
// Writeback HCCA // Writeback HCCA
if (OHCI_WriteHCCA(m_Registers.HcHCCA, &hcca)) { if (OHCI_WriteHCCA(m_Registers.HcHCCA, &hcca)) {
@ -243,7 +243,7 @@ void OHCI::OHCI_BusStart()
DbgPrintf("Ohci: Operational mode event\n"); DbgPrintf("Ohci: Operational mode event\n");
// SOF event // SOF event
OHCI_SOF(); OHCI_SOF(true);
} }
void OHCI::OHCI_BusStop() void OHCI::OHCI_BusStop()
@ -255,10 +255,16 @@ void OHCI::OHCI_BusStop()
m_pEOFtimer = nullptr; m_pEOFtimer = nullptr;
} }
void OHCI::OHCI_SOF() void OHCI::OHCI_SOF(bool bCreate)
{ {
m_SOFtime = GetTime_NS(m_pEOFtimer); // set current SOF time // set current SOF time
Timer_Start(m_pEOFtimer, m_SOFtime + m_UsbFrameTime); // make timer expire at SOF + 1 virtual ms from now m_SOFtime = GetTime_NS(m_pEOFtimer);
// make timer expire at SOF + 1 virtual ms from now
if (bCreate) {
Timer_Start(m_pEOFtimer, m_UsbFrameTime);
}
OHCI_SetInterrupt(OHCI_INTR_SF); OHCI_SetInterrupt(OHCI_INTR_SF);
} }

View File

@ -236,7 +236,7 @@ class OHCI
// stop sending SOF tokens across the usb bus // stop sending SOF tokens across the usb bus
void OHCI_BusStop(); void OHCI_BusStop();
// generate a SOF event, and start a timer for EOF // generate a SOF event, and start a timer for EOF
void OHCI_SOF(); void OHCI_SOF(bool bCreate);
// change interrupt status // change interrupt status
void OHCI_UpdateInterrupt(); void OHCI_UpdateInterrupt();
// fire an interrupt // fire an interrupt
@ -259,9 +259,9 @@ class OHCI
// if not set ConnectStatusChange flag; if flag is enabled return 1 // if not set ConnectStatusChange flag; if flag is enabled return 1
int OHCI_PortSetIfConnected(int i, uint32_t Value); int OHCI_PortSetIfConnected(int i, uint32_t Value);
// read the HCCA structure in memory // read the HCCA structure in memory
bool OHCI_ReadHCCA(uint32_t Paddr, OHCI_HCCA* Hcca); bool OHCI_ReadHCCA(xbaddr Paddr, OHCI_HCCA* Hcca);
// write the HCCA structure in memory // write the HCCA structure in memory
bool OHCI_WriteHCCA(uint32_t Paddr, OHCI_HCCA* Hcca); bool OHCI_WriteHCCA(xbaddr Paddr, OHCI_HCCA* Hcca);
// register a port with the HC // register a port with the HC
void USB_RegisterPort(USBPort* Port, int Index, int SpeedMask); void USB_RegisterPort(USBPort* Port, int Index, int SpeedMask);