1
0
mirror of https://github.com/gdsports/USBHost_t36 synced 2024-11-21 08:35:03 -05:00

Rename transfer functions from "new" to "queue"

This commit is contained in:
PaulStoffregen 2017-02-12 18:00:48 -08:00
parent de69cf9af2
commit 1b300c9051
4 changed files with 16 additions and 18 deletions

View File

@ -140,9 +140,9 @@ public:
protected:
static Pipe_t * new_Pipe(Device_t *dev, uint32_t type, uint32_t endpoint,
uint32_t direction, uint32_t max_packet_len);
static bool new_Control_Transfer(Device_t *dev, setup_t *setup,
static bool queue_Control_Transfer(Device_t *dev, setup_t *setup,
void *buf, USBDriver *driver);
static bool new_Data_Transfer(Pipe_t *pipe, void *buffer,
static bool queue_Data_Transfer(Pipe_t *pipe, void *buffer,
uint32_t len, USBDriver *driver);
static Device_t * new_Device(uint32_t speed, uint32_t hub_addr, uint32_t hub_port);
static void enumeration(const Transfer_t *transfer);

View File

@ -414,7 +414,7 @@ static void init_qTD(volatile Transfer_t *t, void *buf, uint32_t len,
// Create a Control Transfer and queue it
//
bool USBHost::new_Control_Transfer(Device_t *dev, setup_t *setup, void *buf, USBDriver *driver)
bool USBHost::queue_Control_Transfer(Device_t *dev, setup_t *setup, void *buf, USBDriver *driver)
{
Transfer_t *transfer, *data, *status;
uint32_t status_direction;
@ -460,7 +460,7 @@ bool USBHost::new_Control_Transfer(Device_t *dev, setup_t *setup, void *buf, USB
// Create a Bulk or Interrupt Transfer and queue it
//
bool USBHost::new_Data_Transfer(Pipe_t *pipe, void *buffer, uint32_t len, USBDriver *driver)
bool USBHost::queue_Data_Transfer(Pipe_t *pipe, void *buffer, uint32_t len, USBDriver *driver)
{
Serial.println("new_Data_Transfer");
//Transfer_t *transfer = allocate_Transfer();

View File

@ -82,7 +82,7 @@ Device_t * USBHost::new_Device(uint32_t speed, uint32_t hub_addr, uint32_t hub_p
// any new devices detected while enumerating would
// go onto a waiting list
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;
}
@ -109,13 +109,13 @@ void USBHost::enumeration(const Transfer_t *transfer)
case 0: // read 8 bytes of device desc, set max packet, and send set address
pipe_set_maxlen(dev->control_pipe, enumbuf[7]);
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;
return;
case 1: // request all 18 bytes of device descriptor
pipe_set_addr(dev->control_pipe, enumsetup.wValue);
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;
return;
case 2: // parse 18 device desc bytes
@ -136,7 +136,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
case 3: // request Language ID
len = sizeof(enumbuf) - 4;
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;
return;
case 4: // parse Language ID
@ -153,7 +153,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
case 5: // request Manufacturer string
len = sizeof(enumbuf) - 4;
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;
return;
case 6: // parse Manufacturer string
@ -165,7 +165,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
case 7: // request Product string
len = sizeof(enumbuf) - 4;
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;
return;
case 8: // parse Product string
@ -176,7 +176,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
case 9: // request Serial Number string
len = sizeof(enumbuf) - 4;
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;
return;
case 10: // parse Serial Number string
@ -185,7 +185,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
break;
case 11: // request first 9 bytes of config desc
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;
return;
case 12: // read 9 bytes, request all of config desc
@ -196,7 +196,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
// TODO: how to handle device with too much config data
}
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;
return;
case 13: // read all config desc, send set config
@ -208,7 +208,7 @@ void USBHost::enumeration(const Transfer_t *transfer)
dev->bMaxPower = enumbuf[8];
// TODO: actually do something with interface descriptor?
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;
return;
case 14: // device is now configured

View File

@ -75,18 +75,16 @@ bool USBHub::claim(Device_t *dev, int type, const uint8_t *descriptors)
changebits = 0;
state = 0;
// TODO: need a way to do control transfers with our own setup data.
mk_setup(setup, 0xA0, 6, 0x2900, 0, sizeof(hub_desc));
new_Control_Transfer(dev, &setup, hub_desc, this);
queue_Control_Transfer(dev, &setup, hub_desc, this);
return true;
}
void USBHub::poweron(uint32_t port)
{
// TODO: need a way to do control transfers with our own setup data.
mk_setup(setup, 0x23, 3, 8, port, 0);
new_Control_Transfer(device, &setup, NULL, this);
queue_Control_Transfer(device, &setup, NULL, this);
}
bool USBHub::control(const Transfer_t *transfer)