/** * This function will run cdc class, it will be called on handle set configuration request. * * @param device the usb device object. * * @return RT_EOK on successful. */ static rt_err_t _class_run(udevice_t device) { RT_ASSERT(device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc class run\n")); dcd_ep_read(device->dcd, ep_out, ep_out->buffer, ep_out->ep_desc->wMaxPacketSize); return RT_EOK; }
/** * This function will run cdc class, it will be called on handle set configuration request. * * @param device the usb device object. * * @return RT_EOK on successful. */ static rt_err_t _class_run(udevice_t device, uclass_t cls) { cdc_eps_t eps; RT_ASSERT(device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc class run\n")); eps = (cdc_eps_t)cls->eps; eps->ep_in->buffer=tx_pool; eps->ep_out->buffer=rx_pool; dcd_ep_read(device->dcd, eps->ep_out, eps->ep_out->buffer, eps->ep_out->ep_desc->wMaxPacketSize); return RT_EOK; }
/** * This function will handle cdc bulk out endpoint request. * * @param device the usb device object. * @param size request size. * * @return RT_EOK. */ static rt_err_t _ep_out_handler(udevice_t device, rt_size_t size) { rt_uint32_t level; RT_ASSERT(device != RT_NULL); /* receive data from USB VCOM */ level = rt_hw_interrupt_disable(); rt_ringbuffer_put(&rx_ringbuffer, ep_out->buffer, size); rt_hw_interrupt_enable(level); /* notify receive data */ rt_hw_serial_isr(&vcom_serial); dcd_ep_read(device->dcd, ep_out, ep_out->buffer, ep_out->ep_desc->wMaxPacketSize); return RT_EOK; }
/** * 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; }