Cypress Semiconductor AN6077 Manual do Utilizador Página 80

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 88
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 79
// Renumerate if necessary. Do this by checking the renum
bit. If it
// is already set, there is no need to renumerate. The renum
bit will
// already be set if this firmware was loaded from an
eeprom.
if(!(USBCS & bmRENUM))
{
EZUSB_Discon(TRUE); // renumerate
}
#endif
// unconditionally re-connect. If we loaded from eeprom we
are
// disconnected and need to connect. If we just renumerated
this
// is not necessary but doesn't hurt anything
USBCS &=~bmDISCON;
CKCON = (CKCON&(~bmSTRETCH)) |
FW_STRETCH_VALUE; // Set stretch
// clear the Sleep flag.
Sleep = FALSE;
// Task Dispatcher
while(TRUE) // Main Loop
{
// Poll User Device
TD_Poll();
// Check for pending SETUP
if(GotSUD)
{
SetupCommand(); // Implement setup command
GotSUD = FALSE; // Clear SETUP flag
}
// check for and handle suspend.
// NOTE: Idle mode stops the processor clock. There are
only two
// ways out of idle mode, the WAKEUP pin, and detection
of the USB
// resume state on the USB bus. The timers will stop and
the
// processor will not wake up on any other interrupts.
if (Sleep)
{
if(TD_Suspend())
{
Sleep = FALSE; // Clear the "go to sleep" flag. Do
it here to prevent any race condition between wakeup and the
next sleep.
do
{
EZUSB_Susp(); // Place processor in idle
mode.
}
while(!Rwuen && EZUSB_EXTWAKEUP());
// above. Must continue to go back into suspend if the
host has disabled remote wakeup
// *and* the wakeup was caused by the external
wakeup pin.
// 8051 activity will resume here due to USB bus or
Wakeup# pin activity.
EZUSB_Resume(); // If source is the Wakeup# pin,
signal the host to Resume.
TD_Resume();
}
}
}
}
BOOL HighSpeedCapable()
{
// this function determines if the chip is high-speed capable.
// FX2 and FX2LP are high-speed capable. FX1 is not - it
does
// not have a high-speed transceiver.
if (GPCR2 & bmFULLSPEEDONLY)
return FALSE;
else
return TRUE;
}
// Device request parser
void SetupCommand(void)
{
void *dscr_ptr;
switch(SETUPDAT[1])
{
case SC_GET_DESCRIPTOR: // *** Get
Descriptor
if(DR_GetDescriptor())
switch(SETUPDAT[3])
{
case GD_DEVICE: // Device
SUDPTRH = MSB(pDeviceDscr);
SUDPTRL = LSB(pDeviceDscr);
break;
70
Vista de página 79
1 2 ... 75 76 77 78 79 80 81 82 83 84 85 86 87 88

Comentários a estes Manuais

Sem comentários