
Cypress Semiconductor Corporation
SL811HS and SL811HST: Application Notes
©2001 Cypress Semiconductor Corporation. All rights reserved. The information
and specifications contained in this document are subject to change without
notice.
Date: 07/26/01
Revision: 1.21
Page: 27
Program Sample 11: Speed Detect Function
int speed_detect()int speed_detect()
{{
full_speed = 0xffff; full_speed = 0xffff;
int i =0; int i =0;
SL11HMemTest(); // Memory test SL11HMemTest(); // Memory test
SL11Write(IntEna, 0x63); // USBA/B, Insert/Remove,USBRest/Resume. SL11Write(IntEna, 0x63); // USBA/B, Insert/Remove,USBRest/Resume.
SL11Write(cSOFcnt, 0xae); SL11Write(cSOFcnt, 0xae); // Set SOF high counter, no change D+/D// Set SOF high counter, no change D+/D--
SL11Write(CtrlReg, 0x48); // Setup Normal Operation SL11Write(CtrlReg, 0x48); // Setup Normal Operation
SL11Write(CtrlReg, i); // Disable USB transfer operation and SOF SL11Write(CtrlReg, i); // Disable USB transfer operation and SOF
#ifdef SL811H #ifdef SL811H
SL11Write(cSOFcnt, 0xae); // Set SOF high counter, n SL11Write(cSOFcnt, 0xae); // Set SOF high counter, no change D+/Do change D+/D--
SL11Write(CtrlReg, 0x48); // Clear SL811H mode and setup normal operation SL11Write(CtrlReg, 0x48); // Clear SL811H mode and setup normal operation
Delayms(10,0); Delayms(10,0); // Delay for HW stablize // Delay for HW stablize
SL11Write(CtrlReg, 0); SL11Write(CtrlReg, 0); // Disable USB transfer operation and SOF // Disable USB transfer operation and SOF
Delayms(10,0); Delayms(10,0);
i = i = SL11Read(IntStatus);SL11Read(IntStatus); // Read Interrupt Status // Read Interrupt Status
if(i & 0x40) if(i & 0x40)
{{
SL11Write(IntStatus,0x40); SL11Write(IntStatus,0x40);
printf("No device or No Power printf("No device or No Power\\n");n");
}}
if(!(SL11Read(IntStatus)&0x40))if(!(SL11Read(IntStatus)&0x40))
{{
if ((i & 0x80) == 0) // Checking full or low speed if ((i & 0x80) == 0) // Checking full or low speed
{ {
printf("Low Speed is detected %x printf("Low Speed is detected %x\\n", i);n", i);
// Set up Master and low Speed direct and SOF cnt high=0x2e // Set up Master and low Speed direct and SOF cnt high=0x2e
SL11Write(cSOFcnt,0xee); SL11Write(cSOFcnt,0xee);
// SOF Counter Low = 0xe0; 1ms interval // SOF Counter Low = 0xe0; 1ms interval
SL11Write(cDATASe SL11Write(cDATASet,0xe0); t,0xe0);
// Setup 6MHz and EOP enable // Setup 6MHz and EOP enable
SL11Write(CtrlReg,0x21); SL11Write(CtrlReg,0x21);
full_speed = 0; full_speed = 0;
} }
else else
{ {
printf("Full Speed is detected %x printf("Full Speed is detected %x\\n", i);n", i);
// Set up Master and low // Set up Master and low Speed direct and SOF cnt high=0x2e Speed direct and SOF cnt high=0x2e
SL11Write(cSOFcnt,0xae); SL11Write(cSOFcnt,0xae);
// SOF Counter Low = 0xe0; 1ms interval // SOF Counter Low = 0xe0; 1ms interval
SL11Write(cDATASet,0xe0); SL11Write(cDATASet,0xe0);
// Setup 48MHz and SOF enable // Setup 48MHz and SOF enable
SL11Write(CtrlReg,0x05); SL11Write(CtrlReg,0x05);
} }
} }
else else
{ {
SL11Write(IntStatus,0xff); SL11Write(IntStatus,0xff);
} }
SL11Write(EP0Status, 0x50); // Setup SOF Token SL11Write(EP0Status, 0x50); // Setup SOF Token
SL11Write(EP0Counter, 0); SL11Write(EP0Counter, 0);
SL11Write(EP0Control, 0x01); // start generate SOF or EOP SL11Write(EP0Control, 0x01); // start generate SOF or EOP
Delayms(25,0); // Hu Delayms(25,0); // Hub required approx. 24.1mSb required approx. 24.1mS
#endif#endif
return 0; return 0;
}}
Kommentare zu diesen Handbüchern