| 1046 | } |
| 1047 | |
| 1048 | static void sim_usbdev_work(void *arg) |
| 1049 | { |
| 1050 | struct sim_usbdev_s *priv = (struct sim_usbdev_s *)arg; |
| 1051 | struct sim_ep_s *privep; |
| 1052 | struct host_usb_ctrlreq_s *ctrlreq; |
| 1053 | uint8_t *recv_data; |
| 1054 | uint16_t data_len; |
| 1055 | uint8_t epcnt; |
| 1056 | |
| 1057 | /* Loop ep0 */ |
| 1058 | |
| 1059 | ctrlreq = host_usbdev_ep0read(); |
| 1060 | if (ctrlreq) |
| 1061 | { |
| 1062 | sim_usbdev_ep0read(ctrlreq); |
| 1063 | host_usbdev_epread_end(0); |
| 1064 | } |
| 1065 | |
| 1066 | /* Loop other eps */ |
| 1067 | |
| 1068 | for (epcnt = 1; epcnt < SIM_USB_EPNUM; epcnt++) |
| 1069 | { |
| 1070 | privep = &priv->eps[epcnt]; |
| 1071 | if (privep->epstate == SIM_EPSTATE_IDLE && |
| 1072 | !USB_ISEPIN(privep->ep.eplog)) |
| 1073 | { |
| 1074 | recv_data = host_usbdev_epread(epcnt, &data_len); |
| 1075 | if (recv_data) |
| 1076 | { |
| 1077 | sim_usbdev_epread(privep->ep.eplog, recv_data, data_len); |
| 1078 | host_usbdev_epread_end(epcnt); |
| 1079 | } |
| 1080 | } |
| 1081 | } |
| 1082 | |
| 1083 | work_queue_next_wq(g_work_queue, &priv->work, sim_usbdev_work, priv, |
| 1084 | SIM_USB_PERIOD); |
| 1085 | } |
| 1086 | |
| 1087 | /**************************************************************************** |
| 1088 | * Public Functions |
nothing calls this directly
no test coverage detected