Subversion Repositories freemyipod

Rev

Rev 889 | Rev 945 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 889 Rev 890
Line 32... Line 32...
32
void usb_ep0_start_tx(const struct usb_instance* data, const void* buf, int len, bool last, bool (*callback)(const struct usb_instance* data, int bytesleft))
32
void usb_ep0_start_tx(const struct usb_instance* data, const void* buf, int len, bool last, bool (*callback)(const struct usb_instance* data, int bytesleft))
33
{
33
{
34
    // Expect zero-length ACK if we are about to actually send data, otherwise expect SETUP.
34
    // Expect zero-length ACK if we are about to actually send data, otherwise expect SETUP.
35
    if (last) usb_ep0_start_rx(data, !!len, usb_ep0_rx_callback);
35
    if (last) usb_ep0_start_rx(data, !!len, usb_ep0_rx_callback);
36
 
36
 
-
 
37
    if (((uint32_t)buf) & (CACHEALIGN_SIZE - 1))
-
 
38
    {
-
 
39
        memcpy(data->buffer->raw, buf, len);
-
 
40
        buf = data->buffer->raw;
-
 
41
    }
-
 
42
 
37
    data->state->ep0_tx_callback = callback;
43
    data->state->ep0_tx_callback = callback;
38
    data->driver->ep0_start_tx(data, buf, len);
44
    data->driver->ep0_start_tx(data, buf, len);
39
}
45
}
40
 
46
 
41
bool usb_ep0_tx_callback(const struct usb_instance* data, int bytesleft)
47
bool usb_ep0_tx_callback(const struct usb_instance* data, int bytesleft)
42
{
48
{
43
    if (bytesleft || !data->state->ep0_tx_len) return false;
49
    if (bytesleft || !data->state->ep0_tx_len) return false;
44
    int len = MIN(64, data->state->ep0_tx_len);
50
    int len = MIN(64, data->state->ep0_tx_len);
45
    data->state->ep0_tx_ptr += 64;
51
    data->state->ep0_tx_ptr += 64;
46
    data->state->ep0_tx_len -= len;
52
    data->state->ep0_tx_len -= len;
47
    usb_ep0_start_tx(data, data->state->ep0_tx_ptr, len, !!data->state->ep0_tx_len, usb_ep0_tx_callback);
53
    usb_ep0_start_tx(data, data->state->ep0_tx_ptr, len, !data->state->ep0_tx_len, usb_ep0_tx_callback);
48
    return true;
54
    return true;
49
}
55
}
50
 
56
 
51
void usb_unconfigure_ep(const struct usb_instance* data, union usb_endpoint_number ep)
57
void usb_unconfigure_ep(const struct usb_instance* data, union usb_endpoint_number ep)
52
{
58
{