update version to v2.0.2

This commit is contained in:
Artery-MCU
2022-01-21 15:54:53 +08:00
parent 47b90bbacd
commit 79c8fdf6b4
1190 changed files with 14716 additions and 25013 deletions

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usb_core.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb core header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usb_std.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb standard header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbd_core.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb device core header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbd_int.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb interrupt header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usb_sdr.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_core.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb host core header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -301,6 +301,7 @@ typedef struct
uint32_t conn_sts; /*!< connect status */
uint32_t port_enable; /*!< port enable status */
uint32_t timer; /*!< sof timer */
uint32_t err_cnt[USB_HOST_CHANNEL_NUM]; /*!< error counter */
uint32_t xfer_cnt[USB_HOST_CHANNEL_NUM]; /*!< xfer counter */

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_ctrl.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb header file
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_int.h
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb header file
**************************************************************************
* Copyright notice & Disclaimer
@@ -55,6 +55,7 @@ void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn);
void usbh_hch_out_handler(usbh_core_type *uhost, uint8_t chn);
void usbh_rx_qlvl_handler(usbh_core_type *uhost);
void usbh_wakeup_handler(usbh_core_type *uhost);
void usbh_sof_handler(usbh_core_type *uhost);
/**
* @}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usb_core.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb driver
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbd_core.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb device driver
**************************************************************************
* Copyright notice & Disclaimer
@@ -645,7 +645,7 @@ void usbd_enter_suspend(usbd_core_type *udev)
void usbd_flush_tx_fifo(usbd_core_type *udev, uint8_t ept_num)
{
/* flush endpoint tx fifo */
usb_flush_tx_fifo(udev->usb_reg, ept_num & 0xF);
usb_flush_tx_fifo(udev->usb_reg, ept_num & 0x1F);
}
/**

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbd_int.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb interrupt request
**************************************************************************
* Copyright notice & Disclaimer
@@ -425,8 +425,8 @@ void usbd_reset_handler(usbd_core_type *udev)
/* endpoint fifo alloc */
usbd_fifo_alloc(udev);
/* flush tx fifo 0 */
usb_flush_tx_fifo(usbx, 0);
/* flush all tx fifo */
usb_flush_tx_fifo(usbx, 0x10);
/* clear in and out endpoint interrupt flag */
for(i_index = 0; i_index < USB_EPT_MAX_NUM; i_index ++)

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbd_sdr.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb standard device request
**************************************************************************
* Copyright notice & Disclaimer

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_core.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb host driver
**************************************************************************
* Copyright notice & Disclaimer
@@ -512,6 +512,8 @@ usb_sts_type usbh_core_init(usbh_core_type *uhost,
/* host user handler */
uhost->user_handler->user_init();
uhost->timer = 0;
/* usb host cfg default init */
usbh_cfg_default_init(uhost);
@@ -542,9 +544,6 @@ usb_sts_type usbh_core_init(usbh_core_type *uhost,
/* clock select */
usbh_fsls_clksel(usbx, USB_HCFG_CLK_48M);
/* reset host port */
usbh_reset_port(uhost);
/* set support ls and fs device */
host->hcfg_bit.fslssupp = 0;
@@ -950,11 +949,13 @@ void usbh_reset_port(usbh_core_type *uhost)
/* set port reset */
usb_host->hprt = hprt_val | USB_OTG_HPRT_PRTRST;
usb_delay_ms(10);
usb_delay_ms(100);
/* clear port reset */
usb_host->hprt = hprt_val & (~USB_OTG_HPRT_PRTRST);
usb_delay_ms(20);
}
/**
@@ -968,9 +969,6 @@ static void usbh_attached(usbh_core_type *uhost)
uhost->ctrl.hch_in = usbh_alloc_channel(uhost, 0x80);
uhost->ctrl.hch_out = usbh_alloc_channel(uhost, 0x00);
/* reset port */
usbh_reset_port(uhost);
/* user reset callback handler */
uhost->user_handler->user_reset();
@@ -991,6 +989,9 @@ static void usbh_attached(usbh_core_type *uhost)
uhost->ctrl.ept0_size,
uhost->dev.speed);
usb_flush_tx_fifo(uhost->usb_reg, 0x10);
usb_flush_rx_fifo(uhost->usb_reg);
/* user attached callback */
uhost->user_handler->user_attached();
}
@@ -1027,7 +1028,7 @@ static void usbh_class_request(usbh_core_type *uhost)
{
uhost->global_state = USBH_CLASS;
}
else if(status == USB_ERROR)
else if(status == USB_ERROR || status == USB_FAIL)
{
uhost->global_state = USBH_ERROR_STATE;
}
@@ -1133,7 +1134,13 @@ static void usbh_disconnect(usbh_core_type *uhost)
usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
{
usb_sts_type status = USB_FAIL;
if(uhost->conn_sts == 0 &&
uhost->global_state != USBH_IDLE &&
uhost->global_state != USBH_DISCONNECT)
{
uhost->global_state = USBH_IDLE;
}
switch(uhost->global_state)
{
case USBH_IDLE:
@@ -1141,6 +1148,9 @@ usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
{
uhost->global_state = USBH_PORT_EN;
/* wait stable */
usb_delay_ms(200);
/* port reset */
usbh_reset_port(uhost);
@@ -1153,9 +1163,6 @@ usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
if(uhost->port_enable)
{
uhost->global_state = USBH_ATTACHED;
/* wait stable */
usb_delay_ms(50);
}
break;

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_ctrl.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb host control request
**************************************************************************
* Copyright notice & Disclaimer
@@ -365,7 +365,10 @@ usb_sts_type usbh_ctrl_error_handler(usbh_core_type *uhost)
else
{
uhost->ctrl.sts = CTRL_FAIL;
status = USB_FAIL;
uhost->global_state = USBH_DISCONNECT;
uhost->ctrl.err_cnt = 0;
USBH_DEBUG("control error: device not response");
status = USB_ERROR;
}
return status;
}

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file usbh_int.c
* @version v2.0.0
* @date 2021-11-26
* @version v2.0.2
* @date 2021-12-31
* @brief usb host interrupt request
**************************************************************************
* Copyright notice & Disclaimer
@@ -59,6 +59,7 @@ void usbh_irq_handler(otg_core_type *otgdev)
}
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)
@@ -114,6 +115,16 @@ void usbh_wakeup_handler(usbh_core_type *uhost)
uhost->global_state = USBH_WAKEUP;
}
/**
* @brief usb host sof handler
* @param uhost: to the structure of usbh_core_type
* @retval none
*/
void usbh_sof_handler(usbh_core_type *uhost)
{
uhost->timer ++;
}
/**
* @brief usb host disconnect handler
* @param uhost: to the structure of usbh_core_type
@@ -194,7 +205,11 @@ void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn)
usb_chh->hcchar_bit.oddfrm = TRUE;
uhost->urb_state[chn] = URB_DONE;
}
uhost->hch[chn].toggle_in ^= 1;
else if(usb_chh->hcchar_bit.eptype == EPT_ISO_TYPE)
{
uhost->urb_state[chn] = URB_DONE;
}
uhost->hch[chn].toggle_in ^= 1;
}
else if(hcint_value & USB_OTG_HC_CHHLTD_FLAG)
{
@@ -436,8 +451,6 @@ void usbh_port_handler(usbh_core_type *uhost)
{
if(prt & USB_OTG_HPRT_PRTCONSTS)
{
/* usb unmask disconnect */
usbx->gintmsk_bit.disconintmsk = 0;
/* connect callback */
uhost->conn_sts = 1;
}
@@ -466,7 +479,6 @@ void usbh_port_handler(usbh_core_type *uhost)
/* clean up hprt */
usb_host->hprt &= ~(USB_OTG_HPRT_PRTENA | USB_OTG_HPRT_PRTENCHNG |
USB_OTG_HPRT_PRTOVRCACT | USB_OTG_HPRT_PRTCONDET);
usbx->gintmsk_bit.disconintmsk = 1;
}
}