MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _function_enable

Function _function_enable

components/legacy/usb/usbdevice/class/rndis.c:948–992  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

946 * @return RT_EOK on successful.
947 */
948static rt_err_t _function_enable(ufunction_t func)
949{
950 cdc_eps_t eps;
951
952 LOG_I("plugged in");
953
954 eps = (cdc_eps_t)&((rt_rndis_eth_t)func->user_data)->eps;
955 eps->ep_in->buffer = ((rt_rndis_eth_t)func->user_data)->tx_pool;
956 eps->ep_out->buffer = ((rt_rndis_eth_t)func->user_data)->rx_pool;
957 eps->ep_cmd->buffer = (rt_uint8_t*)((rt_rndis_eth_t)func->user_data)->cmd_pool;
958
959 eps->ep_out->request.buffer = eps->ep_out->buffer;
960 eps->ep_out->request.size = EP_MAXPACKET(eps->ep_out);
961 eps->ep_out->request.req_type = UIO_REQUEST_READ_BEST;
962 rt_usbd_io_request(func->device, eps->ep_out, &eps->ep_out->request);
963
964 ((rt_rndis_eth_t)func->user_data)->rx_flag = RT_FALSE;
965 ((rt_rndis_eth_t)func->user_data)->rx_frist = RT_TRUE;
966 // eth_device_ready(&(((rt_rndis_eth_t)func->user_data)->parent));
967
968#ifdef RNDIS_DELAY_LINK_UP
969 /* stop link up timer. */
970 rt_timer_stop(&((rt_rndis_eth_t)func->user_data)->timer);
971#endif /* RNDIS_DELAY_LINK_UP */
972
973 /* clean resp chain list. */
974 {
975 struct rt_rndis_response * response;
976 rt_base_t level = rt_hw_interrupt_disable();
977
978 while(!rt_list_isempty(&((rt_rndis_eth_t)func->user_data)->response_list))
979 {
980 response = (struct rt_rndis_response *)((rt_rndis_eth_t)func->user_data)->response_list.next;
981
982 rt_list_remove(&response->list);
983 rt_free((void *)response->buffer);
984 rt_free(response);
985 }
986
987 ((rt_rndis_eth_t)func->user_data)->need_notify = RT_TRUE;
988 rt_hw_interrupt_enable(level);
989 }
990
991 return RT_EOK;
992}
993
994/**
995 * This function will stop cdc class, it will be called on handle set configuration request.

Callers

nothing calls this directly

Calls 7

rt_usbd_io_requestFunction · 0.85
rt_timer_stopFunction · 0.85
rt_list_isemptyFunction · 0.85
rt_list_removeFunction · 0.85
rt_freeFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50

Tested by

no test coverage detected