Exemplo n.º 1
0
/* called by usb_core_transfer_complete() */
void usb_serial_transfer_complete(int ep,int dir, int status, int length)
{
    (void)ep;
    (void)length;

    switch (dir) {
        case USB_DIR_OUT:
            logf("serial: %s", receive_buffer);
            /* Data received. TODO : Do something with it ? */

            /* Get the next bit */
            usb_drv_recv(ep_out, receive_buffer, sizeof receive_buffer);
            break;

        case USB_DIR_IN:
            /* Data sent out. Update circular buffer */
            if(status == 0)
            {
                /* TODO: Handle (length != buffer_transitlength) */

                buffer_start=(buffer_start+buffer_transitlength)%BUFFER_SIZE;
                buffer_transitlength = 0;
            }

            if(buffer_length>0)
                sendout();
            break;
    }
}
Exemplo n.º 2
0
void usb_serial_init_connection(void)
{
    /* prime rx endpoint */
    usb_drv_recv(ep_out, receive_buffer, sizeof receive_buffer);

    /* we come here too after a bus reset, so reset some data */
    buffer_transitlength = 0;
    if(buffer_length>0)
    {
        sendout();
    }
    active=true;
}
Exemplo n.º 3
0
void usb_storage_init_connection(void)
{
    logf("ums: set config");
    /* prime rx endpoint. We only need room for commands */
    state = WAITING_FOR_COMMAND;

#if (CONFIG_CPU == IMX31L || defined(CPU_TCC77X) || defined(CPU_TCC780X) || \
     defined(BOOTLOADER) || CONFIG_CPU == DM320) && !defined(CPU_PP502x)
    static unsigned char _cbw_buffer[MAX_CBW_SIZE]
        USB_DEVBSS_ATTR __attribute__((aligned(32)));
    cbw_buffer = (void *)_cbw_buffer;

    static unsigned char _transfer_buffer[ALLOCATE_BUFFER_SIZE]
        USB_DEVBSS_ATTR __attribute__((aligned(32)));
    tb.transfer_buffer = (void *)_transfer_buffer;
#ifdef USB_USE_RAMDISK
    static unsigned char _ramdisk_buffer[RAMDISK_SIZE*SECTOR_SIZE];
    ramdisk_buffer = _ramdisk_buffer;
#endif
#else
    /* TODO : check if bufsize is at least 32K ? */
    size_t bufsize;
    unsigned char * audio_buffer;

    audio_buffer = audio_get_buffer(false,&bufsize);
#if defined(UNCACHED_ADDR) && CONFIG_CPU != AS3525
    cbw_buffer = (void *)UNCACHED_ADDR((unsigned int)(audio_buffer+31) & 0xffffffe0);
#else
    cbw_buffer = (void *)((unsigned int)(audio_buffer+31) & 0xffffffe0);
#endif
    tb.transfer_buffer = cbw_buffer + MAX_CBW_SIZE;
    commit_discard_dcache();
#ifdef USB_USE_RAMDISK
    ramdisk_buffer = tb.transfer_buffer + ALLOCATE_BUFFER_SIZE;
#endif
#endif
    usb_drv_recv(ep_out, cbw_buffer, MAX_CBW_SIZE);

    int i;
    for(i=0;i<storage_num_drives();i++) {
        locked[i] = false;
        ejected[i] = !check_disk_present(IF_MD(i));
        queue_broadcast(SYS_USB_LUN_LOCKED, (i<<16)+0);
    }
}