Skip to content

Commit 0d3a651

Browse files
author
Sebastien Bourdeauducq
committedNov 14, 2011
USB: try enumerating full speed devices
1 parent b5cbe7a commit 0d3a651

File tree

1 file changed

+14
-31
lines changed

1 file changed

+14
-31
lines changed
 

‎softusb-input/main.c

+14-31
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ enum {
3939
enum {
4040
PORT_STATE_DISCONNECTED = 0,
4141
PORT_STATE_BUS_RESET,
42-
PORT_STATE_WARMUP,
4342
PORT_STATE_SET_ADDRESS,
4443
PORT_STATE_GET_DEVICE_DESCRIPTOR,
4544
PORT_STATE_GET_CONFIGURATION_DESCRIPTOR,
@@ -442,6 +441,10 @@ static void port_service(struct port_status *p, char name)
442441
* transmission takes place.
443442
*/
444443
check_discon(p, name);
444+
if(p->full_speed)
445+
wio8(SIE_TX_LOW_SPEED, 0);
446+
else
447+
wio8(SIE_TX_LOW_SPEED, 1);
445448
switch(p->state) {
446449
case PORT_STATE_DISCONNECTED: {
447450
char linestat;
@@ -452,11 +455,12 @@ static void port_service(struct port_status *p, char name)
452455
if(linestat == 0x01) {
453456
print_string(connect_fs); print_char(name); print_char('\n');
454457
p->full_speed = 1;
455-
p->state = PORT_STATE_UNSUPPORTED;
456458
}
457459
if(linestat == 0x02) {
458460
print_string(connect_ls); print_char(name); print_char('\n');
459461
p->full_speed = 0;
462+
}
463+
if((linestat == 0x01)||(linestat == 0x02)) {
460464
if(name == 'A')
461465
wio8(SIE_TX_BUSRESET, rio8(SIE_TX_BUSRESET) | 0x01);
462466
else
@@ -472,12 +476,6 @@ static void port_service(struct port_status *p, char name)
472476
wio8(SIE_TX_BUSRESET, rio8(SIE_TX_BUSRESET) & 0x02);
473477
else
474478
wio8(SIE_TX_BUSRESET, rio8(SIE_TX_BUSRESET) & 0x01);
475-
p->state = PORT_STATE_WARMUP;
476-
}
477-
break;
478-
case PORT_STATE_WARMUP:
479-
if(frame_nr == ((p->unreset_frame + 250) & 0x7ff)) {
480-
p->retry_count = 0;
481479
p->state = PORT_STATE_SET_ADDRESS;
482480
}
483481
break;
@@ -503,7 +501,7 @@ static void port_service(struct port_status *p, char name)
503501
case PORT_STATE_GET_DEVICE_DESCRIPTOR: {
504502
struct setup_packet packet;
505503
unsigned char device_descriptor[18];
506-
504+
507505
packet.bmRequestType = 0x80;
508506
packet.bRequest = 0x06;
509507
packet.wValue[0] = 0x00;
@@ -598,51 +596,36 @@ static void port_service(struct port_status *p, char name)
598596
case PORT_STATE_UNSUPPORTED:
599597
break;
600598
}
599+
while(rio8(SIE_TX_BUSY));
601600
}
602601

603602
static const char banner[] PROGMEM = "softusb-input v"VERSION"\n";
604603

605604
int main()
606605
{
607-
unsigned char mask;
608606
unsigned char i;
607+
unsigned char mask;
609608

610609
print_string(banner);
611610

612-
/* we only support low speed operation */
613-
wio8(SIE_TX_LOW_SPEED, 1);
614-
wio8(SIE_LOW_SPEED, 3);
615-
616611
wio8(TIMER0, 0);
617612
while(1) {
618613
/* wait for the next frame */
619614
while((rio8(TIMER1) < 0xbb) || (rio8(TIMER0) < 0x70));
620615
wio8(TIMER0, 0);
621616

622-
/* send keepalive */
623-
mask = 0;
624-
if(port_a.state == PORT_STATE_WARMUP)
625-
mask |= 0x01;
626-
if(port_b.state == PORT_STATE_WARMUP)
627-
mask |= 0x02;
628-
wio8(SIE_SEL_TX, mask);
629-
wio8(SIE_GENERATE_EOP, 1);
630-
while(rio8(SIE_TX_BUSY));
631-
632617
/*
633-
* wait extra time to allow the USB cable
634-
* capacitance to discharge (otherwise some disconnects
635-
* aren't properly detected)
618+
* set RX speed bits
636619
*/
637-
for(i=0;i<128;i++)
638-
asm("nop");
620+
mask = 0;
621+
if(!port_a.full_speed) mask |= 0x01;
622+
if(!port_b.full_speed) mask |= 0x02;
623+
wio8(SIE_LOW_SPEED, mask);
639624

640625
wio8(SIE_SEL_RX, 0);
641626
wio8(SIE_SEL_TX, 0x01);
642627
port_service(&port_a, 'A');
643628

644-
while(rio8(SIE_TX_BUSY));
645-
646629
wio8(SIE_SEL_RX, 1);
647630
wio8(SIE_SEL_TX, 0x02);
648631
port_service(&port_b, 'B');

0 commit comments

Comments
 (0)