/* Vcom Tx Thread */
static void vcom_tx_thread_entry(void* parameter)
{
    struct vcom_tx_msg msg;

    while (1)
    {
        if (rt_mq_recv(&vcom_tx_thread_mq, (void*)&msg,
                        sizeof(struct vcom_tx_msg), RT_WAITING_FOREVER) == RT_EOK)
        {
            struct ufunction *func;
            struct vcom *data;

            func = (struct ufunction*)msg.serial->parent.user_data;
            data = (struct vcom*)func->user_data;
            if (!data->connected)
            {
                continue;
            }
                    
            rt_completion_init(&data->wait);

            data->ep_in->request.buffer = (void*)msg.buf;
            data->ep_in->request.size = msg.size;
            data->ep_in->request.req_type = UIO_REQUEST_WRITE;
            rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request);
            
            if (rt_completion_wait(&data->wait, TX_TIMEOUT) != RT_EOK)
            {
                rt_kprintf("vcom tx timeout\n");
            }      
        }
    }
}
Esempio n. 2
0
rt_inline int _serial_int_tx(struct rt_serial_device *serial, const rt_uint8_t *data, int length)
{
    int size;
    struct rt_serial_tx_fifo *tx;

    RT_ASSERT(serial != RT_NULL);

    size = length;
    tx = (struct rt_serial_tx_fifo*) serial->serial_tx;
    RT_ASSERT(tx != RT_NULL);

    while (length)
    {
        if (serial->ops->putc(serial, *(char*)data) == -1)
        {
            rt_completion_wait(&(tx->completion), RT_WAITING_FOREVER);
            continue;
        }

        data ++;
        length --;
    }

    return size - length;
}
int res_check(int argc, char** argv)
{
    struct rt_completion done;
    rt_completion_init(&done);

    rt_kprintf("Resource checking program!\n");
    startup_checking(&done);
    rt_completion_wait(&done, RT_WAITING_FOREVER);
    rt_kprintf("\nChecking resource files done!!\n");
    
    return 0;
}
/**
 * This function will handle cdc_set_line_coding request.
 *
 * @param device the usb device object.
 * @param setup the setup request.
 *
 * @return RT_EOK on successful.
 */
static rt_err_t _cdc_set_line_coding(udevice_t device, ureq_t setup)
{
    struct ucdc_line_coding data;   
    rt_err_t ret;

    RT_ASSERT(device != RT_NULL);
    RT_ASSERT(setup != RT_NULL);

    rt_completion_init(&device->dcd->completion);
 
    dcd_ep_read(device->dcd, 0, (void*)&data, setup->length);

    ret = rt_completion_wait(&device->dcd->completion, 100);
    if(ret != RT_EOK)
    {
        rt_kprintf("_cdc_set_line_coding timeout\n");
    }
     
    return RT_EOK;
}