update version to v2.1.6

This commit is contained in:
Artery-MCU
2024-12-31 09:21:09 +08:00
parent 716f545aa1
commit ee4796e775
795 changed files with 302228 additions and 217218 deletions

View File

@@ -152,6 +152,7 @@ void usbd_ctrl_recv_status(usbd_core_type *udev);
void usbd_set_stall(usbd_core_type *udev, uint8_t ept_addr);
void usbd_clear_stall(usbd_core_type *udev, uint8_t ept_addr);
void usbd_ept_open(usbd_core_type *udev, uint8_t ept_addr, uint8_t ept_type, uint16_t maxpacket);
void usbd_ept_in_check_fifo(usbd_core_type *udev, uint8_t ept_addr);
void usbd_ept_close(usbd_core_type *udev, uint8_t ept_addr);
void usbd_ept_send(usbd_core_type *udev, uint8_t ept_num, uint8_t *buffer, uint16_t len);
void usbd_ept_recv(usbd_core_type *udev, uint8_t ept_num, uint8_t *buffer, uint16_t len);

View File

@@ -160,6 +160,7 @@ void usbd_core_setup_handler(usbd_core_type *udev, uint8_t ept_num)
usbd_endpoint_request(udev);
break;
default:
usbd_ctrl_unsupport(udev);
break;
}
}
@@ -335,6 +336,28 @@ void usbd_ept_open(usbd_core_type *udev, uint8_t ept_addr, uint8_t ept_type, uin
usb_ept_open(usbx, ept_info);
}
/**
* @brief usb check fifo
* @param udev: to the structure of usbd_core_type
* @param ept_addr: endpoint number
* @retval none
*/
void usbd_ept_in_check_fifo(usbd_core_type *udev, uint8_t ept_addr)
{
otg_global_type *usbx = udev->usb_reg;
uint32_t timeout = 0xFFFF;
uint8_t endp = ept_addr & 0x7F;
if(USB_INEPT(usbx, endp)->diepctl_bit.eptena == SET &&
USB_INEPT(usbx, endp)->diepctl_bit.usbacept == SET)
{
USB_INEPT(usbx, endp)->diepctl_bit.snak = TRUE;
USB_INEPT(usbx, endp)->diepctl_bit.eptdis = TRUE;
USB_INEPT(usbx, endp)->diepctl_bit.snak = TRUE;
while(USB_INEPT(usbx, endp)->diepctl_bit.eptdis && timeout --);
usbd_flush_tx_fifo(udev, endp);
}
}
/**
* @brief usb close endpoint
* @param udev: to the structure of usbd_core_type
@@ -437,7 +460,10 @@ void usbd_ept_send(usbd_core_type *udev, uint8_t ept_addr, uint8_t *buffer, uint
otg_eptin_type *ept_in = USB_INEPT(usbx, ept_info->eptn);
otg_device_type *dev = OTG_DEVICE(usbx);
uint32_t pktcnt;
/* check endpoint fifo */
usbd_ept_in_check_fifo(udev, ept_addr);
/* set send data buffer and length */
ept_info->trans_buf = buffer;
ept_info->total_len = len;

View File

@@ -429,8 +429,12 @@ void usbd_reset_handler(usbd_core_type *udev)
/* clear in and out endpoint interrupt flag */
for(i_index = 0; i_index < USB_EPT_MAX_NUM; i_index ++)
{
USB_INEPT(usbx, i_index)->diepint = 0xFF;
USB_OUTEPT(usbx, i_index)->doepint = 0xFF;
USB_INEPT(usbx, i_index)->diepint = 0xFFFF;
USB_INEPT(usbx, i_index)->diepctl_bit.stall = FALSE;
USB_INEPT(usbx, i_index)->diepctl_bit.snak = TRUE;
USB_OUTEPT(usbx, i_index)->doepint = 0xFFFF;
USB_OUTEPT(usbx, i_index)->doepctl_bit.stall = FALSE;
USB_OUTEPT(usbx, i_index)->doepctl_bit.snak = TRUE;
}
/* clear endpoint flag */

View File

@@ -335,7 +335,7 @@ static usb_sts_type usbd_set_configuration(usbd_core_type *udev)
udev->class_handler->clear_handler(udev);
usbd_ctrl_send_status(udev);
}
else if(config_value == udev->dev_config)
else if(config_value != udev->dev_config)
{
udev->class_handler->clear_handler(udev);
udev->dev_config = config_value;

View File

@@ -46,60 +46,58 @@ void usbh_irq_handler(otg_core_type *otgdev)
{
otg_global_type *usbx = otgdev->usb_reg;
usbh_core_type *uhost = &otgdev->host;
uint32_t intsts = usb_global_get_all_interrupt(usbx);
if(usbx->gintsts_bit.curmode == 1)
{
if(intsts & USB_OTG_HCH_FLAG)
{
usbh_hch_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_HCH_FLAG);
}
if(intsts & USB_OTG_SOF_FLAG)
{
usbh_sof_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_SOF_FLAG);
}
if(intsts & USB_OTG_MODEMIS_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_MODEMIS_FLAG);
}
if(intsts & USB_OTG_WKUP_FLAG)
{
usbh_wakeup_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_WKUP_FLAG);
}
while(usbx->gintsts & USB_OTG_RXFLVL_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_RXFLVL_FLAG)
{
usbh_rx_qlvl_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_RXFLVL_FLAG);
}
if(intsts & USB_OTG_DISCON_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_HCH_FLAG)
{
usbh_hch_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_HCH_FLAG);
}
if(usb_global_get_all_interrupt(usbx) & USB_OTG_SOF_FLAG)
{
usbh_sof_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_SOF_FLAG);
}
if(usb_global_get_all_interrupt(usbx) & USB_OTG_MODEMIS_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_MODEMIS_FLAG);
}
if(usb_global_get_all_interrupt(usbx) & USB_OTG_WKUP_FLAG)
{
usbh_wakeup_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_WKUP_FLAG);
}
if(usb_global_get_all_interrupt(usbx) & USB_OTG_DISCON_FLAG)
{
usbh_disconnect_handler(uhost);
usb_global_clear_interrupt(usbx, USB_OTG_DISCON_FLAG);
}
if(intsts & USB_OTG_PRT_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_PRT_FLAG)
{
usbh_port_handler(uhost);
}
if(intsts & USB_OTG_INCOMPIP_INCOMPISOOUT_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_INCOMPIP_INCOMPISOOUT_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_INCOMPIP_INCOMPISOOUT_FLAG);
}
if(intsts & USB_OTG_INCOMISOIN_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_INCOMISOIN_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_INCOMISOIN_FLAG);
}
if(intsts & USB_OTG_PTXFEMP_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_PTXFEMP_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_PTXFEMP_FLAG);
}
if(intsts & USB_OTG_ISOOUTDROP_FLAG)
if(usb_global_get_all_interrupt(usbx) & USB_OTG_ISOOUTDROP_FLAG)
{
usb_global_clear_interrupt(usbx, USB_OTG_ISOOUTDROP_FLAG);
}
}
}
@@ -157,7 +155,8 @@ void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn)
{
otg_global_type *usbx = uhost->usb_reg;
otg_hchannel_type *usb_chh = USB_CHL(usbx, chn);
uint32_t hcint_value = usb_chh->hcint & usb_chh->hcintmsk;
uint32_t hcint_value = usb_chh->hcint;
hcint_value &= usb_chh->hcintmsk;
if( hcint_value & USB_OTG_HC_ACK_FLAG)
{
@@ -283,7 +282,8 @@ void usbh_hch_out_handler(usbh_core_type *uhost, uint8_t chn)
{
otg_global_type *usbx = uhost->usb_reg;
otg_hchannel_type *usb_chh = USB_CHL(usbx, chn);
uint32_t hcint_value = usb_chh->hcint & usb_chh->hcintmsk;
uint32_t hcint_value = usb_chh->hcint;
hcint_value &= usb_chh->hcintmsk;
if( hcint_value & USB_OTG_HC_ACK_FLAG)
{

View File

@@ -85,6 +85,8 @@ static usb_sts_type class_init_handler(void *udev)
/* set out endpoint to receive status */
usbd_ept_recv(pudev, USBD_CUSTOM_HID_OUT_EPT, pcshid->g_rxhid_buff, USBD_CUSTOM_OUT_MAXPACKET_SIZE);
pcshid->send_state = 0;
return status;
}
@@ -240,7 +242,11 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
custom_hid_type *pcshid = (custom_hid_type *)pudev->class_handler->pdata;
pcshid->send_state = 0;
/* ...user code...
trans next packet data
*/
@@ -326,12 +332,16 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
*/
usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t len)
{
usb_sts_type status = USB_OK;
usb_sts_type status = USB_FAIL;
usbd_core_type *pudev = (usbd_core_type *)udev;
custom_hid_type *pcshid = (custom_hid_type *)pudev->class_handler->pdata;
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED)
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED && pcshid->send_state == 0)
{
pcshid->send_state = 1;
usbd_ept_send(pudev, USBD_CUSTOM_HID_IN_EPT, report, len);
status = USB_OK;
}
return status;
}
@@ -385,7 +395,7 @@ static void usb_hid_buf_process(void *udev, uint8_t *report, uint16_t len)
{
pcshid->g_txhid_buff[i_index] = report[i_index];
}
usbd_ept_send(pudev, USBD_CUSTOM_HID_IN_EPT, pcshid->g_txhid_buff, len);
custom_hid_class_send_report(pudev, pcshid->g_txhid_buff, len);
break;
default:
break;

View File

@@ -77,6 +77,7 @@ typedef struct
uint8_t hid_set_report[64];
uint8_t hid_get_report[64];
uint8_t hid_state;
uint8_t send_state;
}custom_hid_type;
/**

View File

@@ -74,9 +74,12 @@ static usb_sts_type class_init_handler(void *udev)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
mouse_type *pmouse = (mouse_type *)pudev->class_handler->pdata;
/* open hid in endpoint */
usbd_ept_open(pudev, USBD_MOUSE_IN_EPT, EPT_INT_TYPE, USBD_MOUSE_IN_MAXPACKET_SIZE);
pmouse->send_state = 0;
return status;
}
@@ -226,11 +229,13 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
mouse_type *pmouse = (mouse_type *)pudev->class_handler->pdata;
/* ...user code...
trans next packet data
*/
pmouse->send_state = 0;
return status;
}
@@ -303,13 +308,15 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
*/
usb_sts_type usb_mouse_class_send_report(void *udev, uint8_t *report, uint16_t len)
{
usb_sts_type status = USB_OK;
usb_sts_type status = USB_FAIL;
usbd_core_type *pudev = (usbd_core_type *)udev;
mouse_type *pmouse = (mouse_type *)pudev->class_handler->pdata;
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED)
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED && pmouse->send_state == 0)
{
usbd_flush_tx_fifo(pudev, USBD_MOUSE_IN_EPT);
pmouse->send_state = 1;
usbd_ept_send(pudev, USBD_MOUSE_IN_EPT, report, len);
status = USB_OK;
}
return status;

View File

@@ -87,6 +87,7 @@ typedef struct
uint8_t mouse_buffer[4];
uint8_t hid_state;
__IO uint8_t hid_suspend_flag;
uint8_t send_state;
}mouse_type;
/**