|
|
|
|
|
|
|
|
// any new devices detected while enumerating would |
|
|
// any new devices detected while enumerating would |
|
|
// go onto a waiting list |
|
|
// go onto a waiting list |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0100, 0, 8); // 6=GET_DESCRIPTOR |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0100, 0, 8); // 6=GET_DESCRIPTOR |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
return dev; |
|
|
return dev; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 0: // read 8 bytes of device desc, set max packet, and send set address |
|
|
case 0: // read 8 bytes of device desc, set max packet, and send set address |
|
|
pipe_set_maxlen(dev->control_pipe, enumbuf[7]); |
|
|
pipe_set_maxlen(dev->control_pipe, enumbuf[7]); |
|
|
mk_setup(enumsetup, 0, 5, assign_addr(), 0, 0); // 5=SET_ADDRESS |
|
|
mk_setup(enumsetup, 0, 5, assign_addr(), 0, 0); // 5=SET_ADDRESS |
|
|
new_Control_Transfer(dev, &enumsetup, NULL, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, NULL, NULL); |
|
|
dev->enum_state = 1; |
|
|
dev->enum_state = 1; |
|
|
return; |
|
|
return; |
|
|
case 1: // request all 18 bytes of device descriptor |
|
|
case 1: // request all 18 bytes of device descriptor |
|
|
pipe_set_addr(dev->control_pipe, enumsetup.wValue); |
|
|
pipe_set_addr(dev->control_pipe, enumsetup.wValue); |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0100, 0, 18); // 6=GET_DESCRIPTOR |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0100, 0, 18); // 6=GET_DESCRIPTOR |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
dev->enum_state = 2; |
|
|
dev->enum_state = 2; |
|
|
return; |
|
|
return; |
|
|
case 2: // parse 18 device desc bytes |
|
|
case 2: // parse 18 device desc bytes |
|
|
|
|
|
|
|
|
case 3: // request Language ID |
|
|
case 3: // request Language ID |
|
|
len = sizeof(enumbuf) - 4; |
|
|
len = sizeof(enumbuf) - 4; |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300, 0, len); // 6=GET_DESCRIPTOR |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300, 0, len); // 6=GET_DESCRIPTOR |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
dev->enum_state = 4; |
|
|
dev->enum_state = 4; |
|
|
return; |
|
|
return; |
|
|
case 4: // parse Language ID |
|
|
case 4: // parse Language ID |
|
|
|
|
|
|
|
|
case 5: // request Manufacturer string |
|
|
case 5: // request Manufacturer string |
|
|
len = sizeof(enumbuf) - 4; |
|
|
len = sizeof(enumbuf) - 4; |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[0], dev->LanguageID, len); |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[0], dev->LanguageID, len); |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
dev->enum_state = 6; |
|
|
dev->enum_state = 6; |
|
|
return; |
|
|
return; |
|
|
case 6: // parse Manufacturer string |
|
|
case 6: // parse Manufacturer string |
|
|
|
|
|
|
|
|
case 7: // request Product string |
|
|
case 7: // request Product string |
|
|
len = sizeof(enumbuf) - 4; |
|
|
len = sizeof(enumbuf) - 4; |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[1], dev->LanguageID, len); |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[1], dev->LanguageID, len); |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
dev->enum_state = 8; |
|
|
dev->enum_state = 8; |
|
|
return; |
|
|
return; |
|
|
case 8: // parse Product string |
|
|
case 8: // parse Product string |
|
|
|
|
|
|
|
|
case 9: // request Serial Number string |
|
|
case 9: // request Serial Number string |
|
|
len = sizeof(enumbuf) - 4; |
|
|
len = sizeof(enumbuf) - 4; |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[2], dev->LanguageID, len); |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0300 | enumbuf[2], dev->LanguageID, len); |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf + 4, NULL); |
|
|
dev->enum_state = 10; |
|
|
dev->enum_state = 10; |
|
|
return; |
|
|
return; |
|
|
case 10: // parse Serial Number string |
|
|
case 10: // parse Serial Number string |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
case 11: // request first 9 bytes of config desc |
|
|
case 11: // request first 9 bytes of config desc |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0200, 0, 9); // 6=GET_DESCRIPTOR |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0200, 0, 9); // 6=GET_DESCRIPTOR |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
dev->enum_state = 12; |
|
|
dev->enum_state = 12; |
|
|
return; |
|
|
return; |
|
|
case 12: // read 9 bytes, request all of config desc |
|
|
case 12: // read 9 bytes, request all of config desc |
|
|
|
|
|
|
|
|
// TODO: how to handle device with too much config data |
|
|
// TODO: how to handle device with too much config data |
|
|
} |
|
|
} |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0200, 0, len); // 6=GET_DESCRIPTOR |
|
|
mk_setup(enumsetup, 0x80, 6, 0x0200, 0, len); // 6=GET_DESCRIPTOR |
|
|
new_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, enumbuf, NULL); |
|
|
dev->enum_state = 13; |
|
|
dev->enum_state = 13; |
|
|
return; |
|
|
return; |
|
|
case 13: // read all config desc, send set config |
|
|
case 13: // read all config desc, send set config |
|
|
|
|
|
|
|
|
dev->bMaxPower = enumbuf[8]; |
|
|
dev->bMaxPower = enumbuf[8]; |
|
|
// TODO: actually do something with interface descriptor? |
|
|
// TODO: actually do something with interface descriptor? |
|
|
mk_setup(enumsetup, 0, 9, enumbuf[5], 0, 0); // 9=SET_CONFIGURATION |
|
|
mk_setup(enumsetup, 0, 9, enumbuf[5], 0, 0); // 9=SET_CONFIGURATION |
|
|
new_Control_Transfer(dev, &enumsetup, NULL, NULL); |
|
|
|
|
|
|
|
|
queue_Control_Transfer(dev, &enumsetup, NULL, NULL); |
|
|
dev->enum_state = 14; |
|
|
dev->enum_state = 14; |
|
|
return; |
|
|
return; |
|
|
case 14: // device is now configured |
|
|
case 14: // device is now configured |