Lines Matching full:ep

86 	uint8_t ep;  member
91 static struct udc_rpi_ep_state *udc_rpi_get_ep_state(uint8_t ep) in udc_rpi_get_ep_state() argument
95 if (USB_EP_GET_IDX(ep) >= USB_NUM_BIDIR_ENDPOINTS) { in udc_rpi_get_ep_state()
99 if (USB_EP_DIR_IS_OUT(ep)) { in udc_rpi_get_ep_state()
105 return ep_state_base + USB_EP_GET_IDX(ep); in udc_rpi_get_ep_state()
108 static int udc_rpi_start_xfer(uint8_t ep, const void *data, const size_t len) in udc_rpi_start_xfer() argument
110 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in udc_rpi_start_xfer()
114 LOG_WRN("ep 0x%02x was already armed", ep); in udc_rpi_start_xfer()
117 if (USB_EP_DIR_IS_IN(ep)) { in udc_rpi_start_xfer()
130 LOG_DBG("xfer ep %d len %d pid: %d", ep, len, ep_state->next_pid); in udc_rpi_start_xfer()
156 static inline uint32_t udc_rpi_endpoint_mask(const uint8_t ep) in udc_rpi_endpoint_mask() argument
158 const int bit_index = (USB_EP_GET_IDX(ep) << 1) | !!USB_EP_DIR_IS_OUT(ep); in udc_rpi_endpoint_mask()
163 static void udc_rpi_cancel_endpoint(const uint8_t ep) in udc_rpi_cancel_endpoint() argument
165 struct udc_rpi_ep_state *const ep_state = udc_rpi_get_ep_state(ep); in udc_rpi_cancel_endpoint()
168 const uint32_t mask = udc_rpi_endpoint_mask(ep); in udc_rpi_cancel_endpoint()
183 if (USB_EP_DIR_IS_IN(ep)) { in udc_rpi_cancel_endpoint()
224 msg.ep = USB_CONTROL_EP_OUT; in udc_rpi_handle_setup()
245 uint8_t ep = (i >> 1U) | (in ? USB_EP_DIR_IN : USB_EP_DIR_OUT); in udc_rpi_handle_buff_status() local
247 ep_state = udc_rpi_get_ep_state(ep); in udc_rpi_handle_buff_status()
250 LOG_DBG("buff ep %i in? %i", (i >> 1), in); in udc_rpi_handle_buff_status()
261 msg.ep = ep; in udc_rpi_handle_buff_status()
277 .ep = 0U, in udc_rpi_handle_resume()
290 .ep = 0U, in udc_rpi_handle_suspended()
336 LOG_DBG("buf %u ep %u", *udc_rpi_get_ep_state(0x81)->buf_ctl, in udc_rpi_isr()
341 msg.ep = 0U; in udc_rpi_isr()
388 msg.ep = 0U; in udc_rpi_isr()
537 int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb) in usb_dc_ep_set_callback() argument
539 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_set_callback()
541 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_set_callback()
567 int usb_dc_ep_start_read(uint8_t ep, size_t len) in usb_dc_ep_start_read() argument
571 LOG_DBG("ep 0x%02x len %d", ep, len); in usb_dc_ep_start_read()
573 if (!USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_start_read()
574 LOG_ERR("invalid ep 0x%02x", ep); in usb_dc_ep_start_read()
582 ret = udc_rpi_start_xfer(ep, NULL, len); in usb_dc_ep_start_read()
591 LOG_DBG("ep %x, mps %d, type %d", in usb_dc_ep_check_cap()
609 uint8_t ep = ep_cfg->ep_addr; in usb_dc_ep_configure() local
610 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_configure()
616 LOG_DBG("ep 0x%02x, previous mps %u, mps %u, type %u", in usb_dc_ep_configure()
626 int usb_dc_ep_set_stall(const uint8_t ep) in usb_dc_ep_set_stall() argument
628 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_set_stall()
630 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_set_stall()
635 if (USB_EP_GET_IDX(ep) == 0) { in usb_dc_ep_set_stall()
636 hw_set_alias(usb_hw)->ep_stall_arm = USB_EP_DIR_IS_OUT(ep) ? in usb_dc_ep_set_stall()
642 if (ep == USB_CONTROL_EP_IN) { in usb_dc_ep_set_stall()
652 int usb_dc_ep_clear_stall(const uint8_t ep) in usb_dc_ep_clear_stall() argument
654 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_clear_stall()
657 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_clear_stall()
663 if (USB_EP_GET_IDX(ep) > 0) { in usb_dc_ep_clear_stall()
676 int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled) in usb_dc_ep_is_stalled() argument
678 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_is_stalled()
680 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_is_stalled()
697 int usb_dc_ep_enable(const uint8_t ep) in usb_dc_ep_enable() argument
699 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_enable()
705 LOG_DBG("ep 0x%02x (id: %d) -> type %d", ep, USB_EP_GET_IDX(ep), ep_state->type); in usb_dc_ep_enable()
722 if (USB_EP_DIR_IS_OUT(ep) && ep != USB_CONTROL_EP_OUT) { in usb_dc_ep_enable()
723 return usb_dc_ep_start_read(ep, DATA_BUFFER_SIZE); in usb_dc_ep_enable()
729 int usb_dc_ep_disable(const uint8_t ep) in usb_dc_ep_disable() argument
731 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_disable()
733 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_disable()
749 udc_rpi_cancel_endpoint(ep); in usb_dc_ep_disable()
758 int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data, in usb_dc_ep_write() argument
761 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_write()
765 LOG_DBG("ep 0x%02x, len %u", ep, data_len); in usb_dc_ep_write()
767 if (!ep_state || !USB_EP_DIR_IS_IN(ep)) { in usb_dc_ep_write()
768 LOG_ERR("invalid ep 0x%02x", ep); in usb_dc_ep_write()
772 if (ep == USB_CONTROL_EP_IN && state.abort_control_writes) { in usb_dc_ep_write()
786 if (ep == USB_CONTROL_EP_IN && len > USB_MAX_CTRL_MPS) { in usb_dc_ep_write()
801 ret = udc_rpi_start_xfer(ep, data, len); in usb_dc_ep_write()
819 uint32_t udc_rpi_get_ep_buffer_len(const uint8_t ep) in udc_rpi_get_ep_buffer_len() argument
821 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in udc_rpi_get_ep_buffer_len()
827 int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, in usb_dc_ep_read_wait() argument
830 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_read_wait()
834 LOG_ERR("Invalid Endpoint %x", ep); in usb_dc_ep_read_wait()
838 if (!USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_read_wait()
839 LOG_ERR("Wrong endpoint direction: 0x%02x", ep); in usb_dc_ep_read_wait()
843 if (ep == USB_CONTROL_EP_OUT && state.setup_available) { in usb_dc_ep_read_wait()
850 read_count = udc_rpi_get_ep_buffer_len(ep) - ep_state->read_offset; in usb_dc_ep_read_wait()
853 LOG_DBG("ep 0x%02x, %u bytes, %u+%u, %p", ep, max_data_len, ep_state->read_offset, in usb_dc_ep_read_wait()
859 if (ep == USB_CONTROL_EP_OUT && state.setup_available) { in usb_dc_ep_read_wait()
919 int usb_dc_ep_read_continue(const uint8_t ep) in usb_dc_ep_read_continue() argument
921 const struct udc_rpi_ep_state *const ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_read_continue()
924 if (!ep_state || !USB_EP_DIR_IS_OUT(ep)) { in usb_dc_ep_read_continue()
925 LOG_ERR("Not valid endpoint: %02x", ep); in usb_dc_ep_read_continue()
928 if (ep == USB_CONTROL_EP_OUT) { in usb_dc_ep_read_continue()
935 const size_t len = udc_rpi_get_ep_buffer_len(ep); in usb_dc_ep_read_continue()
938 ep, len, ep_state->read_offset); in usb_dc_ep_read_continue()
946 LOG_DBG("Arming endpoint 0x%02x", ep); in usb_dc_ep_read_continue()
947 return usb_dc_ep_start_read(ep, DATA_BUFFER_SIZE); in usb_dc_ep_read_continue()
949 LOG_DBG("Not arming endpoint 0x%02x", ep); in usb_dc_ep_read_continue()
955 int usb_dc_ep_read(const uint8_t ep, uint8_t *const data, in usb_dc_ep_read() argument
958 if (usb_dc_ep_read_wait(ep, data, max_data_len, read_bytes) != 0) { in usb_dc_ep_read()
966 if (usb_dc_ep_read_continue(ep) != 0) { in usb_dc_ep_read()
973 int usb_dc_ep_halt(const uint8_t ep) in usb_dc_ep_halt() argument
975 return usb_dc_ep_set_stall(ep); in usb_dc_ep_halt()
978 int usb_dc_ep_flush(const uint8_t ep) in usb_dc_ep_flush() argument
980 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_flush()
991 int usb_dc_ep_mps(const uint8_t ep) in usb_dc_ep_mps() argument
993 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(ep); in usb_dc_ep_mps()
1042 struct udc_rpi_ep_state *ep_state = udc_rpi_get_ep_state(msg.ep); in udc_rpi_thread_main()
1050 ep_state->cb(msg.ep, msg.type); in udc_rpi_thread_main()