mirror of
https://github.com/ArteryTek/AT32F415_Firmware_Library.git
synced 2026-05-21 01:12:20 +00:00
update version to v2.0.2
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file i2c_application.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief the driver library of the i2c peripheral
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file i2c_application.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief i2c application libray header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 ++)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -62,6 +62,8 @@ void audio_set_interface(void *udev, usb_setup_type *setup);
|
||||
|
||||
usb_audio_type audio_struct = {0, 0, 0, 0, 0, 0x1400, 0, 0, 0, {0x0000, 0x1400, 0x33}, {0x0000, 0x1400, 0x33}};
|
||||
|
||||
static __IO uint16_t audio_feedback_state = 0;
|
||||
static __IO uint8_t audio_spk_out_stage = 0;
|
||||
/* usb device class handler */
|
||||
usbd_class_handler audio_class_handler =
|
||||
{
|
||||
@@ -114,8 +116,10 @@ usb_sts_type class_clear_handler(void *udev)
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_MIC_IN_EPT);
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
#endif
|
||||
|
||||
/* close out endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_SPK_OUT_EPT);
|
||||
@@ -294,7 +298,6 @@ usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
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;
|
||||
uint32_t len = 0;
|
||||
|
||||
/* ...user code...
|
||||
@@ -303,15 +306,13 @@ usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
if((ept_num & 0x7F) == (USBD_AUDIO_MIC_IN_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_MIC_IN_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
usbd_flush_tx_fifo(udev, USBD_AUDIO_MIC_IN_EPT);
|
||||
usbd_ept_send(udev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
else if((ept_num & 0x7F) == (USBD_AUDIO_FEEDBACK_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_FEEDBACK_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -336,7 +337,7 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
{
|
||||
/* speaker data*/
|
||||
audio_codec_spk_fifo_write(audio_struct.audio_spk_data, g_rxlen);
|
||||
|
||||
audio_spk_out_stage = 1;
|
||||
/* get next data */
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
}
|
||||
@@ -352,7 +353,33 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
usb_sts_type class_sof_handler(void *udev)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
if(audio_spk_out_stage & 2)
|
||||
{
|
||||
audio_spk_out_stage = 0;
|
||||
}
|
||||
else if( audio_spk_out_stage )
|
||||
{
|
||||
audio_spk_out_stage |= 2;
|
||||
|
||||
if( 0 == audio_feedback_state )
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
if( audio_feedback_state++ > (1<<FEEDBACK_REFRESH_TIME) ) //timeout
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_flush_tx_fifo(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* ...user code... */
|
||||
|
||||
return status;
|
||||
@@ -403,6 +430,7 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
|
||||
*/
|
||||
void audio_inisoincom_event(void *udev)
|
||||
{
|
||||
#if 0
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
uint32_t fnsof = OTG_DEVICE(pudev->usb_reg)->dsts_bit.soffn;
|
||||
uint32_t epctl_fb = USB_INEPT(pudev->usb_reg, (USBD_AUDIO_FEEDBACK_EPT&0x7F))->diepctl_bit.dpid;
|
||||
@@ -427,7 +455,7 @@ void audio_inisoincom_event(void *udev)
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,22 +471,26 @@ void audio_req_get_cur(void *udev, usb_setup_type *setup)
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.spk_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.spk_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.mic_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.mic_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -514,11 +546,13 @@ void audio_req_get_min(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,11 +567,13 @@ void audio_req_get_max(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,11 +588,13 @@ void audio_req_get_res(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +615,6 @@ void audio_set_interface(void *udev, usb_setup_type *setup)
|
||||
if(audio_struct.spk_alt_setting )
|
||||
{
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -58,11 +58,11 @@ extern "C" {
|
||||
/**
|
||||
* @brief endpoint support max size
|
||||
*/
|
||||
#define AUDIO_REMAIN_SIZE 8
|
||||
#define AUDIO_REMAIN_SIZE 40
|
||||
#define AUDIO_MIC_IN_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_MIC_CHANEL_NUM * (AUDIO_MIC_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_SPK_OUT_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_SPK_CHANEL_NUM * (AUDIO_SPK_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_FEEDBACK_MAXPACKET_SIZE 0x3
|
||||
|
||||
#define FEEDBACK_REFRESH_TIME 0x8
|
||||
/**
|
||||
* @brief request type define
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_conf.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio config
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -46,7 +46,7 @@ extern "C" {
|
||||
*/
|
||||
#define AUDIO_SUPPORT_SPK 1
|
||||
#define AUDIO_SUPPORT_MIC 1
|
||||
#define AUDIO_SUPPORT_FEEDBACK 0
|
||||
#define AUDIO_SUPPORT_FEEDBACK 1
|
||||
|
||||
#define AUDIO_SUPPORT_FREQ_16K 1
|
||||
#define AUDIO_SUPPORT_FREQ_48K 1
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler audio_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -361,8 +367,8 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
0x11, /* bmAttributes: endpoint attributes */
|
||||
LBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x08, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
1, /* bInterval: interval for polling endpoint for data transfers */
|
||||
FEEDBACK_REFRESH_TIME, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
pipe provides new syncronization feedback data. this rate must be a power of
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
1(2ms) to 9(512ms) */
|
||||
@@ -375,7 +381,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -386,7 +395,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_conf.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio config
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -48,7 +48,7 @@ extern "C" {
|
||||
#define AUDIO_SUPPORT_MIC 1
|
||||
#define AUDIO_SUPPORT_FEEDBACK 1
|
||||
|
||||
#define AUDIO_SUPPORT_FREQ_16K 1
|
||||
#define AUDIO_SUPPORT_FREQ_16K 0
|
||||
#define AUDIO_SUPPORT_FREQ_48K 1
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -71,7 +71,8 @@ static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_set_report[64];
|
||||
|
||||
static __IO uint16_t audio_feedback_state = 0;
|
||||
static __IO uint8_t audio_spk_out_stage = 0;
|
||||
/* usb device class handler */
|
||||
usbd_class_handler audio_hid_class_handler =
|
||||
{
|
||||
@@ -134,8 +135,10 @@ usb_sts_type class_clear_handler(void *udev)
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_MIC_IN_EPT);
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
#endif
|
||||
|
||||
/* close out endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_SPK_OUT_EPT);
|
||||
@@ -441,7 +444,6 @@ usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
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;
|
||||
uint32_t len = 0;
|
||||
|
||||
/* ...user code...
|
||||
@@ -450,19 +452,17 @@ usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
if((ept_num & 0x7F) == (USBD_AUDIO_MIC_IN_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_MIC_IN_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
usbd_flush_tx_fifo(udev, USBD_AUDIO_MIC_IN_EPT);
|
||||
usbd_ept_send(udev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
else if((ept_num & 0x7F) == (USBD_AUDIO_FEEDBACK_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_FEEDBACK_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 0;
|
||||
}
|
||||
else if((ept_num & 0x7F) == (USBD_HID_IN_EPT & 0x7F))
|
||||
{
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_HID_IN_EPT & 0x7F);
|
||||
usbd_flush_tx_fifo(udev, USBD_HID_IN_EPT);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -487,7 +487,7 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
{
|
||||
/* speaker data*/
|
||||
audio_codec_spk_fifo_write(audio_struct.audio_spk_data, g_rxlen);
|
||||
|
||||
audio_spk_out_stage = 1;
|
||||
/* get next data */
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
}
|
||||
@@ -510,7 +510,33 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
usb_sts_type class_sof_handler(void *udev)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
if(audio_spk_out_stage & 2)
|
||||
{
|
||||
audio_spk_out_stage = 0;
|
||||
}
|
||||
else if( audio_spk_out_stage )
|
||||
{
|
||||
audio_spk_out_stage |= 2;
|
||||
|
||||
if( 0 == audio_feedback_state )
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
if( audio_feedback_state++ > (1<<FEEDBACK_REFRESH_TIME) ) //timeout
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_flush_tx_fifo(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* ...user code... */
|
||||
|
||||
return status;
|
||||
@@ -561,7 +587,7 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
|
||||
*/
|
||||
void audio_inisoincom_event(void *udev)
|
||||
{
|
||||
|
||||
#if 0
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
uint32_t fnsof = OTG_DEVICE(pudev->usb_reg)->dsts_bit.soffn;
|
||||
uint32_t epctl_fb = USB_INEPT(pudev->usb_reg, (USBD_AUDIO_FEEDBACK_EPT&0x7F))->diepctl_bit.dpid;
|
||||
@@ -586,7 +612,7 @@ void audio_inisoincom_event(void *udev)
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,22 +628,26 @@ void audio_req_get_cur(void *udev, usb_setup_type *setup)
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.spk_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.spk_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.mic_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.mic_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -673,11 +703,13 @@ void audio_req_get_min(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,11 +724,13 @@ void audio_req_get_max(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,11 +745,13 @@ void audio_req_get_res(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,7 +772,6 @@ void audio_set_interface(void *udev, usb_setup_type *setup)
|
||||
if(audio_struct.spk_alt_setting )
|
||||
{
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -70,11 +70,11 @@ extern "C" {
|
||||
/**
|
||||
* @brief endpoint support max size
|
||||
*/
|
||||
#define AUDIO_REMAIN_SIZE 8
|
||||
#define AUDIO_REMAIN_SIZE 40
|
||||
#define AUDIO_MIC_IN_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_MIC_CHANEL_NUM * (AUDIO_MIC_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_SPK_OUT_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_SPK_CHANEL_NUM * (AUDIO_SPK_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_FEEDBACK_MAXPACKET_SIZE 0x3
|
||||
|
||||
#define FEEDBACK_REFRESH_TIME 0x8
|
||||
/**
|
||||
* @brief request type define
|
||||
*/
|
||||
@@ -89,6 +89,17 @@ extern "C" {
|
||||
#define AUDIO_VOLUME_CONTROL 0x02
|
||||
#define AUDIO_FREQ_SET_CONTROL 0x03
|
||||
|
||||
/**
|
||||
* @brief audio descriptor type
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief audio set cur type define
|
||||
*/
|
||||
#define AUDIO_MUTE_CONTROL 0x01
|
||||
#define AUDIO_VOLUME_CONTROL 0x02
|
||||
#define AUDIO_FREQ_SET_CONTROL 0x03
|
||||
|
||||
/**
|
||||
* @brief audio descriptor type
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler audio_hid_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -90,8 +93,13 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
USB_MAX_EP0_SIZE, /* bMaxPacketSize */
|
||||
LBYTE(USBD_VENDOR_ID), /* idVendor */
|
||||
HBYTE(USBD_VENDOR_ID), /* idVendor */
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
LBYTE(USBD_PRODUCT_ID), /* idProduct */
|
||||
HBYTE(USBD_PRODUCT_ID), /* idProduct */
|
||||
#else
|
||||
LBYTE(USBD_PRODUCT_ID+1), /* idProduct */
|
||||
HBYTE(USBD_PRODUCT_ID+1), /* idProduct */
|
||||
#endif
|
||||
0x00, /* bcdDevice rel. 2.00 */
|
||||
0x02,
|
||||
USB_MFC_STRING, /* Index of manufacturer string */
|
||||
@@ -103,7 +111,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -149,7 +160,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_MIC_INPUT_TERMINAL_ID, /* bTerminalID: id of this input terminal*/
|
||||
LBYTE(AUDIO_INPUT_TERMINAL_MICROPHONE),
|
||||
HBYTE(AUDIO_INPUT_TERMINAL_MICROPHONE),/* wTerminalType: terminal is microphone */
|
||||
0x00, /* bAssocTerminal: no association */
|
||||
AUDIO_MIC_OUTPUT_TERMINAL_ID, /* bAssocTerminal: no association */
|
||||
AUDIO_MIC_CHR, /* bNrChannels: two channel */
|
||||
#if (AUDIO_MIC_CHR == 2)
|
||||
0x03, /* wChannelConfig: left front and right front */
|
||||
@@ -177,7 +188,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_MIC_OUTPUT_TERMINAL_ID, /* bTerminalID: id of this output terminal*/
|
||||
LBYTE(AUDIO_TERMINAL_TYPE_STREAMING),
|
||||
HBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
0x00, /* bAssocTerminal: unused */
|
||||
AUDIO_MIC_INPUT_TERMINAL_ID, /* bAssocTerminal: unused */
|
||||
AUDIO_MIC_FEATURE_UNIT_ID, /* bSourceID: from feature unit terminal */
|
||||
0x00, /* iTerminal: unused */
|
||||
#endif
|
||||
@@ -190,7 +201,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_SPK_INPUT_TERMINAL_ID, /* bTerminalID: id of this input terminal*/
|
||||
LBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
HBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
0x00, /* bAssocTerminal: no association */
|
||||
AUDIO_SPK_OUTPUT_TERMINAL_ID, /* bAssocTerminal: no association */
|
||||
AUDIO_SPK_CHR, /* bNrChannels: two channel */
|
||||
#if (AUDIO_SPK_CHR == 2)
|
||||
0x03, /* wChannelConfig: left front and right front */
|
||||
@@ -218,7 +229,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_SPK_OUTPUT_TERMINAL_ID, /* bTerminalID: id of this output terminal*/
|
||||
LBYTE(AUDIO_OUTPUT_TERMINAL_SPEAKER), /* wTerminalType: usb speaker */
|
||||
HBYTE(AUDIO_OUTPUT_TERMINAL_SPEAKER), /* wTerminalType: usb speaker */
|
||||
0x00, /* bAssocTerminal: unused */
|
||||
AUDIO_SPK_INPUT_TERMINAL_ID, /* bAssocTerminal: unused */
|
||||
AUDIO_SPK_FEATURE_UNIT_ID, /* bSourceID: from feature unit terminal */
|
||||
0x00, /* iTerminal: unused */
|
||||
#endif
|
||||
@@ -361,8 +372,8 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
0x11, /* bmAttributes: endpoint attributes */
|
||||
LBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x08, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
1, /* bInterval: interval for polling endpoint for data transfers */
|
||||
FEEDBACK_REFRESH_TIME, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
pipe provides new syncronization feedback data. this rate must be a power of
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
1(2ms) to 9(512ms) */
|
||||
@@ -412,7 +423,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -507,7 +521,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -524,7 +541,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -535,7 +555,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
#define BCD_NUM 0x0100
|
||||
|
||||
#define USBD_VENDOR_ID 0x2E3C
|
||||
#define USBD_PRODUCT_ID 0x5550
|
||||
#define USBD_PRODUCT_ID 0x5555
|
||||
|
||||
#define USBD_SIZ_STRING_LANGID 4
|
||||
#define USBD_SIZ_STRING_SERIAL 0x1A
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -188,7 +194,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -199,7 +208,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -66,7 +66,7 @@ static uint8_t g_req;
|
||||
static uint16_t g_len, g_rxlen;
|
||||
__IO uint8_t g_tx_completed = 1, g_rx_completed = 0;
|
||||
|
||||
uint8_t g_keyboard_tx_completed = 0;
|
||||
__IO uint8_t g_keyboard_tx_completed = 0;
|
||||
|
||||
#define SHIFT 0x80
|
||||
const unsigned char _asciimap[128] =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -106,7 +106,7 @@ typedef struct
|
||||
* @{
|
||||
*/
|
||||
extern usbd_class_handler cdc_keyboard_class_handler;
|
||||
extern uint8_t g_keyboard_tx_completed;
|
||||
extern __IO uint8_t g_keyboard_tx_completed;
|
||||
uint16_t usb_vcp_get_rxdata(void *udev, uint8_t *recv_data);
|
||||
error_status usb_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len);
|
||||
usb_sts_type class_send_report(void *udev, uint8_t *report, uint16_t len);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -76,7 +76,10 @@ usbd_desc_handler cdc_keyboard_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -101,7 +104,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -232,7 +238,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -248,7 +257,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb hid keyboard report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
@@ -286,7 +298,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -297,7 +312,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb custom hid class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -77,7 +77,10 @@ usbd_desc_handler hid_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -102,7 +105,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -155,7 +161,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -250,7 +259,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -267,7 +279,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -278,7 +293,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb custom hid descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -79,7 +79,10 @@ usbd_desc_handler hid_iap_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -104,7 +107,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -157,7 +163,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -185,7 +194,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -202,7 +214,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -213,7 +228,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -56,8 +56,8 @@ static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_set_report[64];
|
||||
uint8_t hid_suspend_flag = 0;
|
||||
uint8_t g_u8tx_completed = 0;
|
||||
__IO uint8_t hid_suspend_flag = 0;
|
||||
__IO uint8_t g_u8tx_completed = 0;
|
||||
|
||||
#define SHIFT 0x80
|
||||
const unsigned char _asciimap[128] =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -86,7 +86,7 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
extern usbd_class_handler keyboard_class_handler;
|
||||
extern uint8_t g_u8tx_completed;
|
||||
extern __IO uint8_t g_u8tx_completed;
|
||||
|
||||
usb_sts_type class_send_report(void *udev, uint8_t *report, uint16_t len);
|
||||
void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -77,7 +77,10 @@ usbd_desc_handler keyboard_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -102,7 +105,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -147,7 +153,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb mouse report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
@@ -186,7 +195,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -203,7 +215,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -214,7 +229,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb keyboard descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file mouse_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid mouse class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -55,7 +55,7 @@ static uint32_t hid_protocol = 0;
|
||||
static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_suspend_flag = 0;
|
||||
__IO uint8_t hid_suspend_flag = 0;
|
||||
uint8_t hid_set_report[64];
|
||||
|
||||
/* usb device class handler */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file mouse_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid mouse header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file mouse_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid mouse device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -77,7 +77,10 @@ usbd_desc_handler mouse_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -102,7 +105,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -147,7 +153,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb mouse report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x05,0x01,
|
||||
0x09,0x02,
|
||||
@@ -200,7 +209,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -217,7 +229,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -228,7 +243,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file mouse_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb mouse descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_bot_scsi.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb mass storage bulk-only transport and scsi command
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -49,7 +49,10 @@ csw_type csw_struct =
|
||||
CSW_BCSWSTATUS_PASS,
|
||||
};
|
||||
|
||||
uint8_t page00_inquiry_data[] = {
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t page00_inquiry_data[] ALIGNED_TAIL = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
@@ -57,7 +60,10 @@ uint8_t page00_inquiry_data[] = {
|
||||
0x00,
|
||||
|
||||
};
|
||||
sense_type sense_data =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD sense_type sense_data ALIGNED_TAIL =
|
||||
{
|
||||
0x70,
|
||||
0x00,
|
||||
@@ -70,8 +76,10 @@ sense_type sense_data =
|
||||
0x00000000
|
||||
};
|
||||
|
||||
|
||||
uint8_t mode_sense6_data[8] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t mode_sense6_data[8] ALIGNED_TAIL =
|
||||
{
|
||||
0x00,
|
||||
0x00,
|
||||
@@ -83,7 +91,10 @@ uint8_t mode_sense6_data[8] =
|
||||
0x00
|
||||
};
|
||||
|
||||
uint8_t mode_sense10_data[8] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t mode_sense10_data[8] ALIGNED_TAIL =
|
||||
{
|
||||
0x00,
|
||||
0x06,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_bot_scsi.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb mass storage bulk-only transport and scsi command header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -194,7 +194,7 @@ typedef struct
|
||||
{
|
||||
uint8_t msc_state;
|
||||
uint8_t bot_status;
|
||||
uint8_t max_lun;
|
||||
uint32_t max_lun;
|
||||
|
||||
uint32_t blk_nbr[MSC_SUPPORT_MAX_LUN];
|
||||
uint32_t blk_size[MSC_SUPPORT_MAX_LUN];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb msc class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -130,7 +130,7 @@ usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
|
||||
switch(setup->bRequest)
|
||||
{
|
||||
case MSC_REQ_GET_MAX_LUN:
|
||||
usbd_ctrl_send(pudev, &msc_struct.max_lun, 1);
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&msc_struct.max_lun, 1);
|
||||
break;
|
||||
case MSC_REQ_BO_RESET:
|
||||
bot_scsi_reset(udev);
|
||||
@@ -220,10 +220,6 @@ 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;
|
||||
usb_flush_tx_fifo(pudev->usb_reg, ept_num&0x7F);
|
||||
// if(msc_struct.msc_state != MSC_STATE_MACHINE_IDLE)
|
||||
// {
|
||||
// bot_scsi_datain_handler(udev, ept_num);
|
||||
// }
|
||||
bot_scsi_datain_handler(udev, ept_num);
|
||||
return status;
|
||||
}
|
||||
@@ -237,8 +233,6 @@ usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
// if(msc_struct.msc_state == MSC_STATE_MACHINE_IDLE)
|
||||
// msc_struct.msc_state = MSC_STATE_MACHINE_CMD;
|
||||
bot_scsi_dataout_handler(udev, ept_num);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb msc class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb msc device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler msc_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -146,7 +152,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -157,7 +166,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file msc_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb msc descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file printer_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb printer class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -61,7 +61,7 @@ uint8_t PRINTER_DEVICE_ID[PRINTER_DEVICE_ID_LEN] =
|
||||
'M', 'F', 'G',':','A','r','t','e', 'r', 'y' ,' ',
|
||||
'C','M', 'D', ':', 'E', 'S', 'C', 'P', 'O', 'S',' ',
|
||||
};
|
||||
static uint8_t g_printer_port_status = 0x18;
|
||||
static uint32_t g_printer_port_status = 0x18;
|
||||
uint8_t g_printer_data[USBD_OUT_MAXPACKET_SIZE];
|
||||
|
||||
/* static variable */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file printer_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file printer_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb printer device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -146,7 +152,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -157,7 +166,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file printer_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb printer descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -396,7 +396,7 @@ usb_sts_type uhost_process_handler(void *uhost)
|
||||
break;
|
||||
|
||||
case USB_HID_GET:
|
||||
usbh_interrupt_recv(puhost, phid->chin, phid->buffer, phid->in_maxpacket);
|
||||
usbh_interrupt_recv(puhost, phid->chin, (uint8_t *)phid->buffer, phid->in_maxpacket);
|
||||
phid->state = USB_HID_POLL;
|
||||
phid->poll_timer = usbh_get_frame(puhost->usb_reg);
|
||||
break;
|
||||
@@ -414,11 +414,11 @@ usb_sts_type uhost_process_handler(void *uhost)
|
||||
puhost->urb_state[phid->chin] = URB_IDLE;
|
||||
if(phid->protocol == USB_HID_MOUSE_PROTOCOL_CODE)
|
||||
{
|
||||
usbh_hid_mouse_decode(phid->buffer);
|
||||
usbh_hid_mouse_decode((uint8_t *)phid->buffer);
|
||||
}
|
||||
else if(phid->protocol == USB_HID_KEYBOARD_PROTOCOL_CODE)
|
||||
{
|
||||
usbh_hid_keyboard_decode(phid->buffer);
|
||||
usbh_hid_keyboard_decode((uint8_t *)phid->buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid class header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -124,7 +124,7 @@ typedef struct
|
||||
usb_hid_ctrl_state_type ctrl_state;
|
||||
usb_hid_state_type state;
|
||||
uint16_t poll_timer;
|
||||
uint8_t buffer[64];
|
||||
uint32_t buffer[16];
|
||||
}usbh_hid_type;
|
||||
|
||||
extern usbh_class_handler_type uhost_class_handler;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_keyboard.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid keyboard type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_keyboard.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid keyboard header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_mouse.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid mouse type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_hid_mouse.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host hid mouse header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_msc_bot_scsi.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host msc bulk-only transfer and scsi type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -598,7 +598,7 @@ usb_sts_type msc_bot_scsi_init(usbh_msc_type *msc_struct)
|
||||
msc_struct->max_lun = 0;
|
||||
msc_struct->use_lun = 0;
|
||||
msc_struct->bot_trans.msc_struct = &usbh_msc;
|
||||
msc_struct->bot_trans.cmd_state = CMD_STATE_WAIT;
|
||||
msc_struct->bot_trans.cmd_state = CMD_STATE_SEND;
|
||||
msc_struct->bot_trans.bot_state = BOT_STATE_SEND_CBW;
|
||||
return USB_OK;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_msc_bot_scsi.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host msc bulk-only transfer and scsi header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_msc_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host msc class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -221,11 +221,10 @@ usb_sts_type uhost_process_handler(void *uhost)
|
||||
case USBH_MSC_INIT:
|
||||
if(pmsc->cur_lun < pmsc->max_lun)
|
||||
{
|
||||
pmsc->l_unit_n[pmsc->cur_lun].ready = MSC_NOT_READY;
|
||||
|
||||
switch(pmsc->l_unit_n[pmsc->cur_lun].state)
|
||||
{
|
||||
case USBH_MSC_INIT:
|
||||
pmsc->l_unit_n[pmsc->cur_lun].ready = MSC_NOT_READY;
|
||||
pmsc->l_unit_n[pmsc->cur_lun].state = USBH_MSC_INQUIRY;
|
||||
break;
|
||||
case USBH_MSC_INQUIRY:
|
||||
@@ -279,6 +278,7 @@ usb_sts_type uhost_process_handler(void *uhost)
|
||||
}
|
||||
else if(status == USB_FAIL)
|
||||
{
|
||||
pmsc->l_unit_n[pmsc->cur_lun].ready = MSC_NOT_READY;
|
||||
pmsc->cur_lun ++;
|
||||
}
|
||||
break;
|
||||
@@ -373,7 +373,7 @@ msc_error_type usbh_msc_is_ready(void *uhost, uint8_t lun)
|
||||
{
|
||||
usbh_core_type *puhost = (usbh_core_type *)uhost;
|
||||
usbh_msc_type *pmsc = (usbh_msc_type *)puhost->class_handler->pdata;
|
||||
return pmsc->l_unit_n[pmsc->cur_lun].ready;
|
||||
return pmsc->l_unit_n[lun].ready;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,6 +390,7 @@ usb_sts_type usbh_msc_read(void *uhost, uint32_t address, uint32_t len, uint8_t
|
||||
usbh_core_type *puhost = (usbh_core_type *)uhost;
|
||||
usbh_msc_type *pmsc = (usbh_msc_type *)puhost->class_handler->pdata;
|
||||
usb_sts_type status;
|
||||
uint32_t timeout = 0;
|
||||
if(puhost->conn_sts == 0 || puhost->global_state != USBH_CLASS
|
||||
|| pmsc->l_unit_n[lun].state != USBH_MSC_IDLE)
|
||||
{
|
||||
@@ -399,8 +400,15 @@ usb_sts_type usbh_msc_read(void *uhost, uint32_t address, uint32_t len, uint8_t
|
||||
pmsc->state = USBH_MSC_READ10;
|
||||
pmsc->l_unit_n[lun].state = USBH_MSC_READ10;
|
||||
pmsc->use_lun = lun;
|
||||
|
||||
timeout = puhost->timer;
|
||||
while(1)
|
||||
{
|
||||
if(puhost->conn_sts == 0 || (puhost->timer - timeout) > (len * 10000))
|
||||
{
|
||||
pmsc->l_unit_n[lun].state = USBH_MSC_IDLE;
|
||||
return USB_FAIL;
|
||||
}
|
||||
status = usbh_msc_bot_scsi_read(uhost, &pmsc->bot_trans, address, buffer, len, lun);
|
||||
if(status == USB_OK)
|
||||
{
|
||||
@@ -430,6 +438,7 @@ usb_sts_type usbh_msc_write(void *uhost, uint32_t address, uint32_t len, uint8_t
|
||||
usbh_core_type *puhost = (usbh_core_type *)uhost;
|
||||
usbh_msc_type *pmsc = (usbh_msc_type *)puhost->class_handler->pdata;
|
||||
usb_sts_type status;
|
||||
uint32_t timeout = 0;
|
||||
if(puhost->conn_sts == 0 || puhost->global_state != USBH_CLASS
|
||||
|| pmsc->l_unit_n[lun].state != USBH_MSC_IDLE)
|
||||
{
|
||||
@@ -441,8 +450,14 @@ usb_sts_type usbh_msc_write(void *uhost, uint32_t address, uint32_t len, uint8_t
|
||||
pmsc->l_unit_n[lun].state = USBH_MSC_WRITE;
|
||||
pmsc->use_lun = lun;
|
||||
|
||||
timeout = puhost->timer;
|
||||
while(1)
|
||||
{
|
||||
if(puhost->conn_sts == 0 || (puhost->timer - timeout) > (len * 10000))
|
||||
{
|
||||
pmsc->l_unit_n[lun].state = USBH_MSC_IDLE;
|
||||
return USB_FAIL;
|
||||
}
|
||||
status = usbh_msc_bot_scsi_write(uhost, &pmsc->bot_trans, address, buffer, len, lun);
|
||||
if(status == USB_OK)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_msc_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host msc class header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
Reference in New Issue
Block a user