Lines Matching full:ep
72 static uint8_t usbip_ep_is_valid(uint8_t ep) in usbip_ep_is_valid() argument
74 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usbip_ep_is_valid()
76 /* Check if ep is valid */ in usbip_ep_is_valid()
77 if ((USB_EP_DIR_IS_OUT(ep)) && in usbip_ep_is_valid()
80 } else if ((USB_EP_DIR_IS_IN(ep)) && in usbip_ep_is_valid()
88 static uint8_t usbip_ep_is_enabled(uint8_t ep) in usbip_ep_is_enabled() argument
90 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usbip_ep_is_enabled()
92 LOG_DBG("ep %x", ep); in usbip_ep_is_enabled()
94 /* Check if ep enabled */ in usbip_ep_is_enabled()
95 if ((USB_EP_DIR_IS_OUT(ep)) && in usbip_ep_is_enabled()
98 } else if ((USB_EP_DIR_IS_IN(ep)) && in usbip_ep_is_enabled()
159 LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps, in usb_dc_ep_check_cap()
190 uint8_t ep = cfg->ep_addr; in usb_dc_ep_configure() local
191 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_configure()
197 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_configure()
198 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_configure()
202 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_configure()
211 int usb_dc_ep_set_stall(const uint8_t ep) in usb_dc_ep_set_stall() argument
213 LOG_DBG("ep %x", ep); in usb_dc_ep_set_stall()
215 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_set_stall()
216 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_set_stall()
226 int usb_dc_ep_clear_stall(const uint8_t ep) in usb_dc_ep_clear_stall() argument
228 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_clear_stall()
230 LOG_DBG("ep %x", ep); in usb_dc_ep_clear_stall()
232 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_clear_stall()
233 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_clear_stall()
245 int usb_dc_ep_halt(const uint8_t ep) in usb_dc_ep_halt() argument
247 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_halt()
249 LOG_DBG("ep %x", ep); in usb_dc_ep_halt()
251 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_halt()
252 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_halt()
258 usb_dc_ep_set_stall(ep); in usb_dc_ep_halt()
264 int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled) in usb_dc_ep_is_stalled() argument
266 LOG_DBG("ep %x", ep); in usb_dc_ep_is_stalled()
268 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_is_stalled()
269 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_is_stalled()
280 int usb_dc_ep_enable(const uint8_t ep) in usb_dc_ep_enable() argument
282 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_enable()
284 LOG_DBG("ep %x", ep); in usb_dc_ep_enable()
286 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_enable()
287 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_enable()
291 /* Enable Ep */ in usb_dc_ep_enable()
292 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_enable()
301 int usb_dc_ep_disable(const uint8_t ep) in usb_dc_ep_disable() argument
303 LOG_DBG("ep %x", ep); in usb_dc_ep_disable()
305 if (!usbip_ep_is_valid(ep)) { in usb_dc_ep_disable()
306 LOG_ERR("Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_disable()
313 int usb_dc_ep_flush(const uint8_t ep) in usb_dc_ep_flush() argument
315 LOG_DBG("ep %x", ep); in usb_dc_ep_flush()
317 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_flush()
318 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_flush()
322 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_flush()
323 /* RX FIFO is global and cannot be flushed per EP */ in usb_dc_ep_flush()
330 int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data, in usb_dc_ep_write() argument
333 LOG_DBG("ep %x len %u", ep, data_len); in usb_dc_ep_write()
335 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_write()
336 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_write()
340 /* Check if IN ep */ in usb_dc_ep_write()
341 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_IN) { in usb_dc_ep_write()
345 /* Check if ep enabled */ in usb_dc_ep_write()
346 if (!usbip_ep_is_enabled(ep)) { in usb_dc_ep_write()
347 LOG_WRN("ep %x disabled", ep); in usb_dc_ep_write()
351 if (USB_EP_GET_IDX(ep) == 0) { in usb_dc_ep_write()
352 if (!usbip_send_common(ep, data_len)) { in usb_dc_ep_write()
356 if (usbip_send(ep, data, data_len) != data_len) { in usb_dc_ep_write()
360 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_write()
378 int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len, in usb_dc_ep_read_wait() argument
381 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_read_wait()
384 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_read_wait()
385 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_read_wait()
389 /* Check if OUT ep */ in usb_dc_ep_read_wait()
390 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_OUT) { in usb_dc_ep_read_wait()
401 /* Check if ep enabled */ in usb_dc_ep_read_wait()
402 if (!usbip_ep_is_enabled(ep)) { in usb_dc_ep_read_wait()
414 LOG_DBG("ep 0x%02x, to_copy %u", ep, to_copy); in usb_dc_ep_read_wait()
424 int usb_dc_ep_read_continue(uint8_t ep) in usb_dc_ep_read_continue() argument
426 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_read_continue()
428 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_read_continue()
429 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_read_continue()
433 /* Check if OUT ep */ in usb_dc_ep_read_continue()
434 if (USB_EP_GET_DIR(ep) != USB_EP_DIR_OUT) { in usb_dc_ep_read_continue()
447 int usb_dc_ep_read(const uint8_t ep, uint8_t *const data, in usb_dc_ep_read() argument
450 LOG_DBG("ep %x max_data_len %u", ep, max_data_len); in usb_dc_ep_read()
452 if (usb_dc_ep_read_wait(ep, data, max_data_len, read_bytes) != 0) { in usb_dc_ep_read()
463 if (usb_dc_ep_read_continue(ep) != 0) { in usb_dc_ep_read()
470 int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb) in usb_dc_ep_set_callback() argument
472 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_set_callback()
474 LOG_DBG("ep %x callback %p", ep, cb); in usb_dc_ep_set_callback()
476 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_set_callback()
477 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_set_callback()
481 if (USB_EP_DIR_IS_IN(ep)) { in usb_dc_ep_set_callback()
495 int usb_dc_ep_mps(const uint8_t ep) in usb_dc_ep_mps() argument
497 uint8_t ep_idx = USB_EP_GET_IDX(ep); in usb_dc_ep_mps()
499 LOG_DBG("ep %x", ep); in usb_dc_ep_mps()
501 if (!usbip_ctrl.attached || !usbip_ep_is_valid(ep)) { in usb_dc_ep_mps()
502 LOG_ERR("Not attached / Invalid endpoint: EP 0x%x", ep); in usb_dc_ep_mps()
506 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_mps()
515 uint8_t ep_idx = USB_EP_GET_IDX(ntohl(hdr->common.ep)); in handle_usb_control()
531 LOG_DBG("SETUP event ep 0x%02x %u", ep_idx, ep_ctrl->data_len); in handle_usb_control()
549 LOG_DBG("DATA OUT event ep 0x%02x %u", in handle_usb_control()
559 uint8_t ep_idx = ntohl(hdr->common.ep); in handle_usb_data()
561 uint8_t ep; in handle_usb_data() local
571 ep = ep_idx | USB_EP_DIR_OUT; in handle_usb_data()
584 LOG_DBG("DATA OUT event ep 0x%02x %u", ep, ep_ctrl->data_len); in handle_usb_data()
585 ep_ctrl->cb(ep, USB_DC_EP_DATA_OUT); in handle_usb_data()
588 if (!usbip_send_common(ep, ep_ctrl->data_len)) { in handle_usb_data()
597 ep = ep_idx | USB_EP_DIR_IN; in handle_usb_data()
598 LOG_DBG("DATA IN event ep 0x%02x %u", ep, ep_ctrl->buf_len); in handle_usb_data()
601 if (!usbip_send_common(ep, ep_ctrl->buf_len)) { in handle_usb_data()
605 if (usbip_send(ep, ep_ctrl->buf, ep_ctrl->buf_len) != in handle_usb_data()
612 ep_ctrl->cb(ep, USB_DC_EP_DATA_IN); in handle_usb_data()