mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-09 00:21:44 +08:00
replace struct usbd_endpoint_cfg with struct usb_endpoint_descriptor in usbh_ep_open api
This commit is contained in:
parent
a1ed27523c
commit
29d45ef5c7
@ -12,18 +12,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USB Endpoint Configuration.
|
||||
*
|
||||
* Structure containing the USB endpoint configuration.
|
||||
*/
|
||||
struct usbd_endpoint_cfg {
|
||||
uint8_t ep_addr; /* Endpoint addr with direction */
|
||||
uint8_t ep_type; /* Endpoint type */
|
||||
uint16_t ep_mps; /* Endpoint max packet size */
|
||||
uint8_t ep_mult; /* Endpoint additional transcations in micro frame */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief init device controller registers.
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
@ -61,7 +49,7 @@ uint8_t usbd_get_port_speed(const uint8_t port);
|
||||
*
|
||||
* @return On success will return 0, and others indicate fail.
|
||||
*/
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg);
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep);
|
||||
|
||||
/**
|
||||
* @brief Disable the selected endpoint
|
||||
|
@ -89,22 +89,18 @@ static bool is_device_configured(void)
|
||||
* This function sets endpoint configuration according to one specified in USB
|
||||
* endpoint descriptor and then enables it for data transfers.
|
||||
*
|
||||
* @param [in] ep_desc Endpoint descriptor byte array
|
||||
* @param [in] ep Endpoint descriptor byte array
|
||||
*
|
||||
* @return true if successfully configured and enabled
|
||||
*/
|
||||
static bool usbd_set_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||
static bool usbd_set_endpoint(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
struct usbd_endpoint_cfg ep_cfg;
|
||||
|
||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
||||
|
||||
USB_LOG_INFO("Open ep:0x%02x type:%u mps:%u\r\n",
|
||||
ep_cfg.ep_addr, ep_cfg.ep_type, ep_cfg.ep_mps);
|
||||
ep->bEndpointAddress,
|
||||
USB_GET_ENDPOINT_TYPE(ep->bmAttributes),
|
||||
USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize));
|
||||
|
||||
return usbd_ep_open(&ep_cfg) == 0 ? true : false;
|
||||
return usbd_ep_open(ep) == 0 ? true : false;
|
||||
}
|
||||
/**
|
||||
* @brief Disable endpoint for transferring data
|
||||
@ -112,22 +108,17 @@ static bool usbd_set_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||
* This function cancels transfers that are associated with endpoint and
|
||||
* disabled endpoint itself.
|
||||
*
|
||||
* @param [in] ep_desc Endpoint descriptor byte array
|
||||
* @param [in] ep Endpoint descriptor byte array
|
||||
*
|
||||
* @return true if successfully deconfigured and disabled
|
||||
*/
|
||||
static bool usbd_reset_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||
static bool usbd_reset_endpoint(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
struct usbd_endpoint_cfg ep_cfg;
|
||||
|
||||
ep_cfg.ep_addr = ep_desc->bEndpointAddress;
|
||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize & USB_MAXPACKETSIZE_MASK;
|
||||
ep_cfg.ep_type = ep_desc->bmAttributes & USB_ENDPOINT_TYPE_MASK;
|
||||
|
||||
USB_LOG_INFO("Close ep:0x%02x type:%u\r\n",
|
||||
ep_cfg.ep_addr, ep_cfg.ep_type);
|
||||
ep->bEndpointAddress,
|
||||
USB_GET_ENDPOINT_TYPE(ep->bmAttributes));
|
||||
|
||||
return usbd_ep_close(ep_cfg.ep_addr) == 0 ? true : false;
|
||||
return usbd_ep_close(ep->bEndpointAddress) == 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -990,15 +981,18 @@ void usbd_event_reset_handler(void)
|
||||
#ifdef CONFIG_USBDEV_TEST_MODE
|
||||
g_usbd_core.test_mode = false;
|
||||
#endif
|
||||
struct usbd_endpoint_cfg ep0_cfg;
|
||||
struct usb_endpoint_descriptor ep0;
|
||||
|
||||
ep0_cfg.ep_mps = USB_CTRL_EP_MPS;
|
||||
ep0_cfg.ep_type = USB_ENDPOINT_TYPE_CONTROL;
|
||||
ep0_cfg.ep_addr = USB_CONTROL_IN_EP0;
|
||||
usbd_ep_open(&ep0_cfg);
|
||||
ep0.bLength = 7;
|
||||
ep0.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT;
|
||||
ep0.wMaxPacketSize = USB_CTRL_EP_MPS;
|
||||
ep0.bmAttributes = USB_ENDPOINT_TYPE_CONTROL;
|
||||
ep0.bEndpointAddress = USB_CONTROL_IN_EP0;
|
||||
ep0.bInterval = 0;
|
||||
usbd_ep_open(&ep0);
|
||||
|
||||
ep0_cfg.ep_addr = USB_CONTROL_OUT_EP0;
|
||||
usbd_ep_open(&ep0_cfg);
|
||||
ep0.bEndpointAddress = USB_CONTROL_OUT_EP0;
|
||||
usbd_ep_open(&ep0);
|
||||
|
||||
usbd_class_event_notify_handler(USBD_EVENT_RESET, NULL);
|
||||
usbd_event_handler(USBD_EVENT_RESET);
|
||||
|
@ -147,31 +147,31 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
* @param[in] ep_cfg : Endpoint configuration structure pointer
|
||||
* @retval >=0 success otherwise failure
|
||||
*/
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
/*!< ep id */
|
||||
uint8_t epid = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t epid = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
if (epid > (USB_NUM_BIDIR_ENDPOINTS - 1)) {
|
||||
/**
|
||||
* If you use ch58x, you can change the EP_NUMS set to 8
|
||||
*/
|
||||
USB_LOG_ERR("Ep addr %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep addr %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!< ep max packet length */
|
||||
uint8_t mps = ep_cfg->ep_mps;
|
||||
uint8_t mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
/*!< update ep max packet length */
|
||||
if (USB_EP_DIR_IS_IN(ep_cfg->ep_addr)) {
|
||||
if (USB_EP_DIR_IS_IN(ep->bEndpointAddress)) {
|
||||
/*!< in */
|
||||
usb_dc_cfg.ep_in[epid].ep_enable = true;
|
||||
usb_dc_cfg.ep_in[epid].mps = mps;
|
||||
usb_dc_cfg.ep_in[epid].eptype = ep_cfg->ep_type;
|
||||
} else if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
usb_dc_cfg.ep_in[epid].eptype = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
} else if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
/*!< out */
|
||||
usb_dc_cfg.ep_out[epid].ep_enable = true;
|
||||
usb_dc_cfg.ep_out[epid].mps = mps;
|
||||
usb_dc_cfg.ep_out[epid].eptype = ep_cfg->ep_type;
|
||||
usb_dc_cfg.ep_out[epid].eptype = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -101,18 +101,18 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return USB_SPEED_FULL;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_ch32_usbfs_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_ch32_usbfs_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_ch32_usbfs_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_ch32_usbfs_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_ch32_usbfs_udc.out_ep[ep_idx].ep_enable = true;
|
||||
USB_SET_RX_CTRL(ep_idx, USBFS_UEP_R_RES_NAK | USBFS_UEP_AUTO_TOG);
|
||||
} else {
|
||||
g_ch32_usbfs_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_ch32_usbfs_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_ch32_usbfs_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_ch32_usbfs_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_ch32_usbfs_udc.in_ep[ep_idx].ep_enable = true;
|
||||
USB_SET_TX_CTRL(ep_idx, USBFS_UEP_T_RES_NAK | USBFS_UEP_AUTO_TOG);
|
||||
}
|
||||
|
@ -101,24 +101,24 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return USB_SPEED_HIGH;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_ch32_usbhs_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_ch32_usbhs_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_ch32_usbhs_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_ch32_usbhs_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_ch32_usbhs_udc.out_ep[ep_idx].ep_enable = true;
|
||||
USBHS_DEVICE->ENDP_CONFIG |= (1 << (ep_idx + 16));
|
||||
USB_SET_RX_CTRL(ep_idx, USBHS_EP_R_RES_NAK | USBHS_EP_R_TOG_0 | USBHS_EP_R_AUTOTOG);
|
||||
} else {
|
||||
g_ch32_usbhs_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_ch32_usbhs_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_ch32_usbhs_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_ch32_usbhs_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_ch32_usbhs_udc.in_ep[ep_idx].ep_enable = true;
|
||||
USBHS_DEVICE->ENDP_CONFIG |= (1 << (ep_idx));
|
||||
USB_SET_TX_CTRL(ep_idx, USBHS_EP_T_RES_NAK | USBHS_EP_T_TOG_0 | USBHS_EP_T_AUTOTOG);
|
||||
}
|
||||
USB_SET_MAX_LEN(ep_idx, ep_cfg->ep_mps);
|
||||
USB_SET_MAX_LEN(ep_idx, USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -727,36 +727,36 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return speed;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (ep_idx > (USB_NUM_BIDIR_ENDPOINTS - 1)) {
|
||||
USB_LOG_ERR("Ep addr %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep addr %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_dwc2_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_dwc2_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_dwc2_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_dwc2_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
|
||||
USB_OTG_DEV->DAINTMSK |= USB_OTG_DAINTMSK_OEPM & (uint32_t)(1UL << (16 + ep_idx));
|
||||
|
||||
if ((USB_OTG_OUTEP(ep_idx)->DOEPCTL & USB_OTG_DOEPCTL_USBAEP) == 0) {
|
||||
USB_OTG_OUTEP(ep_idx)->DOEPCTL |= (ep_cfg->ep_mps & USB_OTG_DOEPCTL_MPSIZ) |
|
||||
((uint32_t)ep_cfg->ep_type << 18) |
|
||||
USB_OTG_OUTEP(ep_idx)->DOEPCTL |= (USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize) & USB_OTG_DOEPCTL_MPSIZ) |
|
||||
((uint32_t)USB_GET_ENDPOINT_TYPE(ep->bmAttributes) << 18) |
|
||||
USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
|
||||
USB_OTG_DOEPCTL_USBAEP;
|
||||
}
|
||||
} else {
|
||||
g_dwc2_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_dwc2_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_dwc2_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_dwc2_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
|
||||
USB_OTG_DEV->DAINTMSK |= USB_OTG_DAINTMSK_IEPM & (uint32_t)(1UL << ep_idx);
|
||||
|
||||
if ((USB_OTG_INEP(ep_idx)->DIEPCTL & USB_OTG_DIEPCTL_USBAEP) == 0) {
|
||||
USB_OTG_INEP(ep_idx)->DIEPCTL |= (ep_cfg->ep_mps & USB_OTG_DIEPCTL_MPSIZ) |
|
||||
((uint32_t)ep_cfg->ep_type << 18) | (ep_idx << 22) |
|
||||
USB_OTG_INEP(ep_idx)->DIEPCTL |= (USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize) & USB_OTG_DIEPCTL_MPSIZ) |
|
||||
((uint32_t)USB_GET_ENDPOINT_TYPE(ep->bmAttributes) << 18) | (ep_idx << 22) |
|
||||
USB_OTG_DIEPCTL_SD0PID_SEVNFRM |
|
||||
USB_OTG_DIEPCTL_USBAEP;
|
||||
}
|
||||
|
@ -121,19 +121,19 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return USB_SPEED_FULL;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (ep_idx > (USB_NUM_BIDIR_ENDPOINTS - 1)) {
|
||||
USB_LOG_ERR("Ep addr %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep addr %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint16_t wEpRegVal;
|
||||
|
||||
/* initialize Endpoint */
|
||||
switch (ep_cfg->ep_type) {
|
||||
switch (USB_GET_ENDPOINT_TYPE(ep->bmAttributes)) {
|
||||
case USB_ENDPOINT_TYPE_CONTROL:
|
||||
wEpRegVal = USB_EP_CONTROL;
|
||||
break;
|
||||
@ -157,42 +157,42 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
PCD_SET_EPTYPE(USB, ep_idx, wEpRegVal);
|
||||
|
||||
PCD_SET_EP_ADDRESS(USB, ep_idx, ep_idx);
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_enable = true;
|
||||
if (g_fsdev_udc.out_ep[ep_idx].ep_mps > g_fsdev_udc.out_ep[ep_idx].ep_pma_buf_len) {
|
||||
if (g_fsdev_udc.pma_offset + g_fsdev_udc.out_ep[ep_idx].ep_mps > USB_RAM_SIZE) {
|
||||
USB_LOG_ERR("Ep pma %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep pma %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_pma_buf_len = ep_cfg->ep_mps;
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_pma_buf_len = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_fsdev_udc.out_ep[ep_idx].ep_pma_addr = g_fsdev_udc.pma_offset;
|
||||
/*Set the endpoint Receive buffer address */
|
||||
PCD_SET_EP_RX_ADDRESS(USB, ep_idx, g_fsdev_udc.pma_offset);
|
||||
g_fsdev_udc.pma_offset += ep_cfg->ep_mps;
|
||||
g_fsdev_udc.pma_offset += USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
}
|
||||
/*Set the endpoint Receive buffer counter*/
|
||||
PCD_SET_EP_RX_CNT(USB, ep_idx, ep_cfg->ep_mps);
|
||||
PCD_SET_EP_RX_CNT(USB, ep_idx, USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize));
|
||||
PCD_CLEAR_RX_DTOG(USB, ep_idx);
|
||||
} else {
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_enable = true;
|
||||
if (g_fsdev_udc.in_ep[ep_idx].ep_mps > g_fsdev_udc.in_ep[ep_idx].ep_pma_buf_len) {
|
||||
if (g_fsdev_udc.pma_offset + g_fsdev_udc.in_ep[ep_idx].ep_mps > USB_RAM_SIZE) {
|
||||
USB_LOG_ERR("Ep pma %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep pma %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_pma_buf_len = ep_cfg->ep_mps;
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_pma_buf_len = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_fsdev_udc.in_ep[ep_idx].ep_pma_addr = g_fsdev_udc.pma_offset;
|
||||
/*Set the endpoint Transmit buffer address */
|
||||
PCD_SET_EP_TX_ADDRESS(USB, ep_idx, g_fsdev_udc.pma_offset);
|
||||
g_fsdev_udc.pma_offset += ep_cfg->ep_mps;
|
||||
g_fsdev_udc.pma_offset += USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
}
|
||||
|
||||
PCD_CLEAR_TX_DTOG(USB, ep_idx);
|
||||
if (ep_cfg->ep_type != USB_ENDPOINT_TYPE_ISOCHRONOUS) {
|
||||
if (USB_GET_ENDPOINT_TYPE(ep->bmAttributes) != USB_ENDPOINT_TYPE_ISOCHRONOUS) {
|
||||
/* Configure NAK status for the Endpoint */
|
||||
PCD_SET_EP_TX_STATUS(USB, ep_idx, USB_EP_TX_NAK);
|
||||
} else {
|
||||
|
@ -111,26 +111,26 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
usb_endpoint_config_t tmp_ep_cfg;
|
||||
usb_device_handle_t *handle = g_hpm_udc.handle;
|
||||
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_hpm_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_hpm_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_hpm_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_hpm_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_hpm_udc.out_ep[ep_idx].ep_enable = true;
|
||||
} else {
|
||||
g_hpm_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_hpm_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_hpm_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_hpm_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_hpm_udc.in_ep[ep_idx].ep_enable = true;
|
||||
}
|
||||
|
||||
tmp_ep_cfg.xfer = ep_cfg->ep_type;
|
||||
tmp_ep_cfg.ep_addr = ep_cfg->ep_addr;
|
||||
tmp_ep_cfg.max_packet_size = ep_cfg->ep_mps;
|
||||
tmp_ep_cfg.xfer = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
tmp_ep_cfg.ep_addr = ep->bEndpointAddress;
|
||||
tmp_ep_cfg.max_packet_size = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
|
||||
usb_device_edpt_open(handle, &tmp_ep_cfg);
|
||||
return 0;
|
||||
|
@ -288,11 +288,11 @@ uint8_t usbd_force_full_speed(const uint8_t port)
|
||||
return (HWREGB(USB_BASE + MUSB_POWER_OFFSET) & USB_POWER_HSENAB);
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint16_t used = 0;
|
||||
uint16_t fifo_size = 0;
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
uint8_t old_ep_idx;
|
||||
uint32_t ui32Flags = 0;
|
||||
uint16_t ui32Register = 0;
|
||||
@ -308,19 +308,19 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
}
|
||||
|
||||
if (ep_idx > (USB_NUM_BIDIR_ENDPOINTS - 1)) {
|
||||
USB_LOG_ERR("Ep addr %d overflow\r\n", ep_cfg->ep_addr);
|
||||
USB_LOG_ERR("Ep addr %02x overflow\r\n", ep->bEndpointAddress);
|
||||
return -1;
|
||||
}
|
||||
|
||||
old_ep_idx = musb_get_active_ep();
|
||||
musb_set_active_ep(ep_idx);
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_musb_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_musb_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_musb_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_musb_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_musb_udc.out_ep[ep_idx].ep_enable = true;
|
||||
|
||||
HWREGH(USB_BASE + MUSB_IND_RXMAP_OFFSET) = ep_cfg->ep_mps;
|
||||
HWREGH(USB_BASE + MUSB_IND_RXMAP_OFFSET) = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
|
||||
//
|
||||
// Allow auto clearing of RxPktRdy when packet of size max packet
|
||||
@ -348,7 +348,7 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
//
|
||||
// Enable isochronous mode if requested.
|
||||
//
|
||||
if (ep_cfg->ep_type == 0x01) {
|
||||
if (USB_GET_ENDPOINT_TYPE(ep->bmAttributes) == 0x01) {
|
||||
ui32Register |= USB_RXCSRH1_ISO;
|
||||
}
|
||||
|
||||
@ -360,18 +360,18 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
else
|
||||
HWREGB(USB_BASE + MUSB_IND_RXCSRL_OFFSET) = USB_RXCSRL1_CLRDT;
|
||||
|
||||
fifo_size = musb_get_fifo_size(ep_cfg->ep_mps, &used);
|
||||
fifo_size = musb_get_fifo_size(USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize), &used);
|
||||
|
||||
HWREGB(USB_BASE + MUSB_RXFIFOSZ_OFFSET) = fifo_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_RXFIFOADD_OFFSET) = (g_musb_udc.fifo_size_offset >> 3);
|
||||
|
||||
g_musb_udc.fifo_size_offset += used;
|
||||
} else {
|
||||
g_musb_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_musb_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_musb_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_musb_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_musb_udc.in_ep[ep_idx].ep_enable = true;
|
||||
|
||||
HWREGH(USB_BASE + MUSB_IND_TXMAP_OFFSET) = ep_cfg->ep_mps;
|
||||
HWREGH(USB_BASE + MUSB_IND_TXMAP_OFFSET) = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
|
||||
//
|
||||
// Allow auto setting of TxPktRdy when max packet size has been loaded
|
||||
@ -393,7 +393,7 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
//
|
||||
// Enable isochronous mode if requested.
|
||||
//
|
||||
if (ep_cfg->ep_type == 0x01) {
|
||||
if (USB_GET_ENDPOINT_TYPE(ep->bmAttributes) == 0x01) {
|
||||
ui32Register |= USB_TXCSRH1_ISO;
|
||||
}
|
||||
|
||||
@ -405,7 +405,7 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
else
|
||||
HWREGB(USB_BASE + MUSB_IND_TXCSRL_OFFSET) = USB_TXCSRL1_CLRDT;
|
||||
|
||||
fifo_size = musb_get_fifo_size(ep_cfg->ep_mps, &used);
|
||||
fifo_size = musb_get_fifo_size(USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize), &used);
|
||||
|
||||
HWREGB(USB_BASE + MUSB_TXFIFOSZ_OFFSET) = fifo_size & 0x0f;
|
||||
HWREGH(USB_BASE + MUSB_TXFIFOADD_OFFSET) = (g_musb_udc.fifo_size_offset >> 3);
|
||||
|
@ -200,20 +200,20 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
* @param[in] ep_cfg : Endpoint configuration structure pointer
|
||||
* @retval >=0 success otherwise failure
|
||||
*/
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
/*!< ep id */
|
||||
uint8_t epid = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t epid = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
/*!< ep max packet length */
|
||||
uint8_t mps = ep_cfg->ep_mps;
|
||||
if (USB_EP_DIR_IS_IN(ep_cfg->ep_addr))
|
||||
uint8_t mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
if (USB_EP_DIR_IS_IN(ep->bEndpointAddress))
|
||||
{
|
||||
/*!< In */
|
||||
usb_dc_cfg.ep_in[epid].mps = mps;
|
||||
usb_dc_cfg.ep_in[epid].eptype = ep_cfg->ep_type;
|
||||
usb_dc_cfg.ep_in[epid].eptype = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
usb_dc_cfg.ep_in[epid].ep_enable = true;
|
||||
/*!< Open ep */
|
||||
if (ep_cfg->ep_type != USB_ENDPOINT_TYPE_ISOCHRONOUS)
|
||||
if (USB_GET_ENDPOINT_TYPE(ep->bmAttributes) != USB_ENDPOINT_TYPE_ISOCHRONOUS)
|
||||
{
|
||||
/*!< Enable endpoint interrupt */
|
||||
NRF_USBD->INTENSET = (1 << (USBD_INTEN_ENDEPIN0_Pos + epid));
|
||||
@ -238,14 +238,14 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
NRF_USBD->EPINEN |= USBD_EPINEN_ISOIN_Msk;
|
||||
}
|
||||
}
|
||||
else if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr))
|
||||
else if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress))
|
||||
{
|
||||
/*!< Out */
|
||||
usb_dc_cfg.ep_out[epid].mps = mps;
|
||||
usb_dc_cfg.ep_out[epid].eptype = ep_cfg->ep_type;
|
||||
usb_dc_cfg.ep_out[epid].eptype = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
usb_dc_cfg.ep_out[epid].ep_enable = true;
|
||||
/*!< Open ep */
|
||||
if (ep_cfg->ep_type != USB_ENDPOINT_TYPE_ISOCHRONOUS)
|
||||
if (USB_GET_ENDPOINT_TYPE(ep->bmAttributes) != USB_ENDPOINT_TYPE_ISOCHRONOUS)
|
||||
{
|
||||
NRF_USBD->INTENSET = (1 << (USBD_INTEN_ENDEPOUT0_Pos + epid));
|
||||
NRF_USBD->EPOUTEN |= (1 << (epid));
|
||||
@ -274,8 +274,8 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
}
|
||||
|
||||
/*!< Clear stall and reset DataToggle */
|
||||
NRF_USBD->EPSTALL = (USBD_EPSTALL_STALL_UnStall << USBD_EPSTALL_STALL_Pos) | (ep_cfg->ep_addr);
|
||||
NRF_USBD->DTOGGLE = (USBD_DTOGGLE_VALUE_Data0 << USBD_DTOGGLE_VALUE_Pos) | (ep_cfg->ep_addr);
|
||||
NRF_USBD->EPSTALL = (USBD_EPSTALL_STALL_UnStall << USBD_EPSTALL_STALL_Pos) | (ep->bEndpointAddress);
|
||||
NRF_USBD->DTOGGLE = (USBD_DTOGGLE_VALUE_Data0 << USBD_DTOGGLE_VALUE_Pos) | (ep->bEndpointAddress);
|
||||
|
||||
__ISB();
|
||||
__DSB();
|
||||
|
@ -174,15 +174,15 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return USB_SPEED_FULL;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (USB_EP_DIR_IS_IN(ep_cfg->ep_addr)) {
|
||||
if (USB_EP_DIR_IS_IN(ep->bEndpointAddress)) {
|
||||
uint8_t epnum = USBD_EPNUM_FROM_IN_EPIDX(ep_idx);
|
||||
|
||||
g_nuvoton_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_nuvoton_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_nuvoton_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_nuvoton_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_nuvoton_udc.in_ep[ep_idx].ep_enable = true;
|
||||
if (ep_idx == 0) {
|
||||
/* EP0 ==> control IN endpoint, address 0 */
|
||||
@ -194,8 +194,8 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
} else {
|
||||
uint8_t epnum = USBD_EPNUM_FROM_OUT_EPIDX(ep_idx);
|
||||
|
||||
g_nuvoton_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_nuvoton_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_nuvoton_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_nuvoton_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_nuvoton_udc.out_ep[ep_idx].ep_enable = true;
|
||||
if (ep_idx == 0) {
|
||||
/* EP1 ==> control OUT endpoint, address 0 */
|
||||
|
@ -236,45 +236,45 @@ int usbd_set_address(const uint8_t addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct usb_endpoint_descriptor *usbd_get_ep0_desc(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
static struct usb_endpoint_descriptor *usbd_get_ep0_desc(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
static struct usb_endpoint_descriptor ep0_desc;
|
||||
|
||||
/* Config EP0 mps from speed */
|
||||
ep0_desc.bEndpointAddress = ep_cfg->ep_addr;
|
||||
ep0_desc.bEndpointAddress = ep->bEndpointAddress;
|
||||
ep0_desc.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT;
|
||||
ep0_desc.bmAttributes = ep_cfg->ep_type;
|
||||
ep0_desc.wMaxPacketSize = ep_cfg->ep_mps;
|
||||
ep0_desc.bmAttributes = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
ep0_desc.wMaxPacketSize = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
ep0_desc.bInterval = 0;
|
||||
ep0_desc.bLength = 7;
|
||||
|
||||
return &ep0_desc;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
struct pusb2_dc_ep_state *ep_state;
|
||||
uint32_t error;
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
ep_state = &g_pusb2_udc.out_ep[ep_idx];
|
||||
} else {
|
||||
ep_state = &g_pusb2_udc.in_ep[ep_idx];
|
||||
}
|
||||
|
||||
ep_state->ep_mps = ep_cfg->ep_mps;
|
||||
ep_state->ep_type = ep_cfg->ep_type;
|
||||
ep_state->desc = usbd_get_ep0_desc(ep_cfg);
|
||||
ep_state->ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
ep_state->ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
ep_state->desc = usbd_get_ep0_desc(ep);
|
||||
|
||||
USB_ASSERT(ep_state->priv_ep != NULL);
|
||||
USB_LOG_DBG("try to enable ep@0x%x 0x%x:0x%x\n", ep_cfg->ep_addr,
|
||||
USB_LOG_DBG("try to enable ep@0x%x 0x%x:0x%x\n", ep->bEndpointAddress,
|
||||
ep_state->priv_ep, ep_state->desc );
|
||||
error = FPUsb2DcEpEnable(&g_pusb2_udc.pusb2.device_ctrl,
|
||||
ep_state->priv_ep,
|
||||
(const FUsbEndpointDescriptor *)ep_state->desc);
|
||||
if (FPUSB2_SUCCESS != error){
|
||||
USB_LOG_ERR("enable ep-%d failed, error = 0x%x\n", ep_cfg->ep_addr, error);
|
||||
USB_LOG_ERR("enable ep-%d failed, error = 0x%x\n", ep->bEndpointAddress, error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -205,9 +205,9 @@ uint8_t usbd_get_port_speed(const uint8_t port)
|
||||
return USB_SPEED_FULL;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (ep_idx == 0) {
|
||||
/**
|
||||
@ -222,10 +222,10 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
g_rp2040_udc.in_ep[ep_idx].dpram_data_buf = (uint8_t *)&usb_dpram->ep0_buf_a[0];
|
||||
}
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_addr = ep_cfg->ep_addr;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_addr = ep->bEndpointAddress;
|
||||
g_rp2040_udc.out_ep[ep_idx].ep_enable = true;
|
||||
/*!< Get control reg */
|
||||
g_rp2040_udc.out_ep[ep_idx].buffer_control = &usb_dpram->ep_buf_ctrl[ep_idx].out;
|
||||
@ -241,9 +241,9 @@ int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
}
|
||||
|
||||
} else {
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_addr = ep_cfg->ep_addr;
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_addr = ep->bEndpointAddress;
|
||||
g_rp2040_udc.in_ep[ep_idx].ep_enable = true;
|
||||
/*!< Get control reg */
|
||||
g_rp2040_udc.in_ep[ep_idx].buffer_control = &usb_dpram->ep_buf_ctrl[ep_idx].in;
|
||||
|
@ -51,16 +51,16 @@ int usbd_set_address(const uint8_t addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbd_ep_open(const struct usbd_endpoint_cfg *ep_cfg)
|
||||
int usbd_ep_open(const struct usb_endpoint_descriptor *ep)
|
||||
{
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep_cfg->ep_addr);
|
||||
uint8_t ep_idx = USB_EP_GET_IDX(ep->bEndpointAddress);
|
||||
|
||||
if (USB_EP_DIR_IS_OUT(ep_cfg->ep_addr)) {
|
||||
g_xxx_udc.out_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_xxx_udc.out_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
if (USB_EP_DIR_IS_OUT(ep->bEndpointAddress)) {
|
||||
g_xxx_udc.out_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_xxx_udc.out_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
} else {
|
||||
g_xxx_udc.in_ep[ep_idx].ep_mps = ep_cfg->ep_mps;
|
||||
g_xxx_udc.in_ep[ep_idx].ep_type = ep_cfg->ep_type;
|
||||
g_xxx_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
|
||||
g_xxx_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user