Lines Matching full:ep
182 static struct usb_dc_stm32_ep_state *usb_dc_stm32_get_ep_state(uint8_t ep) in usb_dc_stm32_get_ep_state() argument
186 if (USB_EP_GET_IDX(ep) >= USB_NUM_BIDIR_ENDPOINTS) { in usb_dc_stm32_get_ep_state()
190 if (USB_EP_DIR_IS_OUT(ep)) { in usb_dc_stm32_get_ep_state()
196 return ep_state_base + USB_EP_GET_IDX(ep); in usb_dc_stm32_get_ep_state()
666 int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb) in usb_dc_ep_set_callback() argument
668 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_set_callback()
670 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_set_callback()
704 int usb_dc_ep_start_read(uint8_t ep, uint8_t *data, uint32_t max_data_len) in usb_dc_ep_start_read() argument
708 LOG_DBG("ep 0x%02x, len %u", ep, max_data_len); in usb_dc_ep_start_read()
711 if (!USB_EP_DIR_IS_OUT(ep) && (ep != EP0_IN || max_data_len)) { in usb_dc_ep_start_read()
712 LOG_ERR("invalid ep 0x%02x", ep); in usb_dc_ep_start_read()
720 status = HAL_PCD_EP_Receive(&usb_dc_stm32_state.pcd, ep, in usb_dc_ep_start_read()
721 usb_dc_stm32_state.ep_buf[USB_EP_GET_IDX(ep)], in usb_dc_ep_start_read()
724 LOG_ERR("HAL_PCD_EP_Receive failed(0x%02x), %d", ep, in usb_dc_ep_start_read()
732 int usb_dc_ep_get_read_count(uint8_t ep, uint32_t *read_bytes) in usb_dc_ep_get_read_count() argument
734 if (!USB_EP_DIR_IS_OUT(ep) || !read_bytes) { in usb_dc_ep_get_read_count()
735 LOG_ERR("invalid ep 0x%02x", ep); in usb_dc_ep_get_read_count()
739 *read_bytes = HAL_PCD_EP_GetRxCount(&usb_dc_stm32_state.pcd, ep); in usb_dc_ep_get_read_count()
748 LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps, in usb_dc_ep_check_cap()
766 uint8_t ep = ep_cfg->ep_addr; in usb_dc_ep_configure() local
767 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_configure()
773 LOG_DBG("ep 0x%02x, previous ep_mps %u, ep_mps %u, ep_type %u", in usb_dc_ep_configure()
789 HAL_PCDEx_PMAConfig(&usb_dc_stm32_state.pcd, ep, PCD_DBL_BUF, in usb_dc_ep_configure()
795 HAL_PCDEx_PMAConfig(&usb_dc_stm32_state.pcd, ep, PCD_SNG_BUF, in usb_dc_ep_configure()
830 int usb_dc_ep_set_stall(const uint8_t ep) in usb_dc_ep_set_stall() argument
832 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_set_stall()
835 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_set_stall()
841 status = HAL_PCD_EP_SetStall(&usb_dc_stm32_state.pcd, ep); in usb_dc_ep_set_stall()
843 LOG_ERR("HAL_PCD_EP_SetStall failed(0x%02x), %d", ep, in usb_dc_ep_set_stall()
853 int usb_dc_ep_clear_stall(const uint8_t ep) in usb_dc_ep_clear_stall() argument
855 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_clear_stall()
858 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_clear_stall()
864 status = HAL_PCD_EP_ClrStall(&usb_dc_stm32_state.pcd, ep); in usb_dc_ep_clear_stall()
866 LOG_ERR("HAL_PCD_EP_ClrStall failed(0x%02x), %d", ep, in usb_dc_ep_clear_stall()
877 int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled) in usb_dc_ep_is_stalled() argument
879 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_is_stalled()
881 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_is_stalled()
892 int usb_dc_ep_enable(const uint8_t ep) in usb_dc_ep_enable() argument
894 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_enable()
897 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_enable()
903 LOG_DBG("HAL_PCD_EP_Open(0x%02x, %u, %u)", ep, ep_state->ep_mps, in usb_dc_ep_enable()
906 status = HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, ep, in usb_dc_ep_enable()
909 LOG_ERR("HAL_PCD_EP_Open failed(0x%02x), %d", ep, in usb_dc_ep_enable()
914 if (USB_EP_DIR_IS_OUT(ep) && ep != EP0_OUT) { in usb_dc_ep_enable()
915 return usb_dc_ep_start_read(ep, in usb_dc_ep_enable()
916 usb_dc_stm32_state.ep_buf[USB_EP_GET_IDX(ep)], in usb_dc_ep_enable()
923 int usb_dc_ep_disable(const uint8_t ep) in usb_dc_ep_disable() argument
925 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_disable()
928 LOG_DBG("ep 0x%02x", ep); in usb_dc_ep_disable()
934 status = HAL_PCD_EP_Close(&usb_dc_stm32_state.pcd, ep); in usb_dc_ep_disable()
936 LOG_ERR("HAL_PCD_EP_Close failed(0x%02x), %d", ep, in usb_dc_ep_disable()
944 int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data, in usb_dc_ep_write() argument
947 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_write()
952 LOG_DBG("ep 0x%02x, len %u", ep, data_len); in usb_dc_ep_write()
954 if (!ep_state || !USB_EP_DIR_IS_IN(ep)) { in usb_dc_ep_write()
955 LOG_ERR("invalid ep 0x%02x", ep); in usb_dc_ep_write()
969 if (ep == EP0_IN && len > USB_MAX_CTRL_MPS) { in usb_dc_ep_write()
973 status = HAL_PCD_EP_Transmit(&usb_dc_stm32_state.pcd, ep, in usb_dc_ep_write()
976 LOG_ERR("HAL_PCD_EP_Transmit failed(0x%02x), %d", ep, in usb_dc_ep_write()
982 if (!ret && ep == EP0_IN && len > 0) { in usb_dc_ep_write()
986 usb_dc_ep_start_read(ep, NULL, 0); in usb_dc_ep_write()
1000 int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len, in usb_dc_ep_read_wait() argument
1003 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_read_wait()
1007 LOG_ERR("Invalid Endpoint %x", ep); in usb_dc_ep_read_wait()
1013 LOG_DBG("ep 0x%02x, %u bytes, %u+%u, %p", ep, max_data_len, in usb_dc_ep_read_wait()
1016 if (!USB_EP_DIR_IS_OUT(ep)) { /* check if OUT ep */ in usb_dc_ep_read_wait()
1017 LOG_ERR("Wrong endpoint direction: 0x%02x", ep); in usb_dc_ep_read_wait()
1027 memcpy(data, usb_dc_stm32_state.ep_buf[USB_EP_GET_IDX(ep)] + in usb_dc_ep_read_wait()
1042 int usb_dc_ep_read_continue(uint8_t ep) in usb_dc_ep_read_continue() argument
1044 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_read_continue()
1046 if (!ep_state || !USB_EP_DIR_IS_OUT(ep)) { /* Check if OUT ep */ in usb_dc_ep_read_continue()
1047 LOG_ERR("Not valid endpoint: %02x", ep); in usb_dc_ep_read_continue()
1055 usb_dc_ep_start_read(ep, usb_dc_stm32_state.ep_buf[USB_EP_GET_IDX(ep)], in usb_dc_ep_read_continue()
1062 int usb_dc_ep_read(const uint8_t ep, uint8_t *const data, const uint32_t max_data_len, in usb_dc_ep_read() argument
1065 if (usb_dc_ep_read_wait(ep, data, max_data_len, read_bytes) != 0) { in usb_dc_ep_read()
1069 if (usb_dc_ep_read_continue(ep) != 0) { in usb_dc_ep_read()
1076 int usb_dc_ep_halt(const uint8_t ep) in usb_dc_ep_halt() argument
1078 return usb_dc_ep_set_stall(ep); in usb_dc_ep_halt()
1081 int usb_dc_ep_flush(const uint8_t ep) in usb_dc_ep_flush() argument
1083 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_flush()
1094 int usb_dc_ep_mps(const uint8_t ep) in usb_dc_ep_mps() argument
1096 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in usb_dc_ep_mps()
1246 uint8_t ep = ep_idx | USB_EP_DIR_OUT; in HAL_PCD_DataOutStageCallback() local
1247 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in HAL_PCD_DataOutStageCallback()
1255 usb_dc_ep_get_read_count(ep, &ep_state->read_count); in HAL_PCD_DataOutStageCallback()
1259 ep_state->cb(ep, USB_DC_EP_DATA_OUT); in HAL_PCD_DataOutStageCallback()
1266 uint8_t ep = ep_idx | USB_EP_DIR_IN; in HAL_PCD_DataInStageCallback() local
1267 struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep); in HAL_PCD_DataInStageCallback()
1271 __ASSERT(ep_state, "No corresponding ep_state for ep"); in HAL_PCD_DataInStageCallback()
1276 ep_state->cb(ep, USB_DC_EP_DATA_IN); in HAL_PCD_DataInStageCallback()