[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/driver/connectivity/usb_class/include/icusb_debug_tool.h b/mcu/driver/connectivity/usb_class/include/icusb_debug_tool.h
new file mode 100644
index 0000000..defb0af
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/icusb_debug_tool.h
@@ -0,0 +1,225 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_debug_tool.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb common driver debug buffer definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifdef __IC_USB_ENABLE__
+
+#ifndef USB_DEBUG_TOOL_H
+#define USB_DEBUG_TOOL_H
+
+/***********************************************
+ implement definition
+************************************************/
+
+#define ICUSB_DBG_DATA_SIZE 512
+
+typedef enum
+{
+ IC_USB_DBG_SET_TXPKTREADY,
+ IC_USB_SET_EVENT,
+ IC_USB_RETRIEVE_EVENT,
+ IC_USB_SUSSPEND_DEVICE,
+ IC_USB_REMOTE_WAKEUP,
+ IC_USB_REMOTE_WAKEUP_DONE,
+ IC_USB_RESET,
+ IC_USB_CONN,
+ IC_USB_DISCONN,
+ IC_USB_BABBLE,
+ IC_USB_SESSREQ,
+ IC_USB_MASK_HISR,
+ IC_USB_DBG_HISR,
+ IC_USB_DMA_CALLBACK,
+ IC_USB_CONN_AND_DISCONN,
+ IC_USB_UNEXPECTED_EP0_INTR,
+ IC_USB_UNEXPECTED_TX_INTR,
+ IC_USB_EPN_RX_INTR,
+ IC_USB_UNEXPECTED_RX_INTR,
+ IC_USB_UNMASK_HISR,
+ IC_USB_DMA_TIMEOUT_ERROR,
+ IC_USB_EP0_INTR,
+ IC_USB_EPN_TX_INTR,
+ IC_USB_PN_RX_INTR,
+ IC_USB_SEND_DATA_DONE,
+ IC_USB_EP0_Setup,
+ IC_USB_EP0_Data,
+ IC_USB_DMA_LISR,
+
+#ifdef __IC_USB_EEM_SUPPORT__
+ IC_USB_EEM_START,
+ IC_USB_EEM_END,
+ IC_USB_EEM_RECEIVE,
+ IC_USB_EEM_SEND,
+ IC_USB_EEM_ClearRX,
+ IC_USB_EEM_ClearTX,
+ IC_USB_EEM_Resume,
+ IC_USB_EEM_Suspend,
+#endif
+
+#ifdef __IC_USB_ICCD_SUPPORT__
+ IC_USB_ICCD_CTRL_EP_HDLR,
+ IC_USB_ICCD_HDLR,
+ IC_USB_ICCD_START,
+ IC_USB_ICCD_END,
+ IC_USB_ICCD_POWER_ON,
+ IC_USB_ICCD_POWER_OFF,
+ IC_USB_ICCD_DATA_TRANSFER,
+ IC_USB_ICCD_Already_POWER_ON,
+ IC_USB_ICCD_ERROR,
+ IC_USB_ICCD_BUSY_WAIT,
+ IC_USB_ICC_DATA_CMD,
+ IC_USB_ICC_XFR_CMD,
+ IC_USB_ICC_Power_ON_CMD,
+ IC_USB_ICC_Power_OFF_CMD,
+ IC_USB_ICC_SLOT_CMD,
+ IC_USB_ICC_ENUMERATION_FAIL,
+ IC_USB_ICC_RESET_DEVICE,
+ IC_USB_ICC_SUSPEND,
+ IC_USB_ICC_RESUME,
+ IC_USB_ICC_STALL,
+#endif
+ USB_DBG_MAX
+}ICUSB_DBG_INFO;
+
+
+/***********************************************
+ Implement enum and structure
+************************************************/
+
+typedef struct
+{
+ ICUSB_DBG_INFO tag;
+ kal_uint32 time;
+ kal_uint32 data1;
+ kal_uint32 data2;
+}ICUsb_Dbg_Data;
+
+
+typedef struct
+{
+ ICUsb_Dbg_Data dbg_data[ICUSB_DBG_DATA_SIZE];
+ kal_uint16 dbg_data_idx;
+}ICUsb_Dbg_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern void ICUSB_Dbg_Trace(ICUSB_DBG_INFO tag, kal_uint32 time, kal_uint32 data1, kal_uint32 data2);
+
+
+#endif
+/* USB_DEBUG_TOOL_H */
+
+#endif
+
diff --git a/mcu/driver/connectivity/usb_class/include/icusb_eem_adap.h b/mcu/driver/connectivity/usb_class/include/icusb_eem_adap.h
new file mode 100644
index 0000000..d529a26
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/icusb_eem_adap.h
@@ -0,0 +1,157 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * Icusb_eem_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host EEM class adaptaion layer definitaions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_EEM_DRV_H
+#define USB_HOST_EEM_DRV_H
+
+typedef enum
+{
+ USB_EEM_DONE, //Setup DMA
+ USB_EEM_TRANSFER, // DMA Still Running --> last data hasn't send out
+ USB_EEM_NEXT_TRANSFER,
+ USB_EEM_NOT_READY, // USB config = F , Enumeraion not finish or device removed
+ USB_EEM_CRC_ERROR, // CRC_check_flag = T
+ USB_EEM_LENGTH_ERROR, // Data length doesn't match
+ USB_EEM_HEADER_TYPE_ERROR, // data or command packet define
+ USB_EEM_HEADER_PARAM_ERROR //command parameter type
+}USB_EEM_RESPONSE;
+
+
+extern kal_bool USB_EEM_START(kal_uint8 eem_index, module_type ownerid);
+
+extern kal_bool USB_EEM_END(kal_uint8 eem_index, module_type ownerid);
+
+//extern kal_bool USB_EEM_CRC_Check_Set(kal_uint8 eem_index, module_type ownerid,kal_bool CRC_check);
+
+//extern kal_bool USB_EEM_Set_Owner(kal_uint8 eem_index, module_type ownerid);
+
+extern void USB_EEM_Clear_TX_Buffer(kal_uint8 eem_index, module_type ownerid);
+
+extern void USB_EEM_Clear_RX_Buffer(kal_uint8 eem_index, module_type ownerid); //doesn't support
+
+extern USB_EEM_RESPONSE USB_EEM_Send_Frame(kal_uint8 eem_index,peer_buff_struct *peer_buff_ptr, flc2_pool_id_enum pool_id);
+
+//extern USB_EEM_RESPONSE USB_EEM_Send_Frame(kal_uint8 eem_index, module_type ownerid,kal_uint8 *Buffaddr, kal_uint16 Length,kal_bool CRC_Check,kal_uint16 CRC_Value);
+
+extern USB_EEM_RESPONSE USB_EEM_Receive_Frame(kal_uint8 eem_index, module_type ownerid,kal_uint8 *Buffaddr, kal_uint16 Length);
+
+extern void USB_EEM_rx_buff_reserve(kal_uint8 eem_index,void* buff_ptr[], kal_uint32 num);
+
+extern void USB_EEM_rx_buff_release(kal_uint8 eem_index,void* buff_ptr[], kal_uint32 *num);
+
+
+// Error message
+
+
+#endif /* USB_HOST_ACM_DRV_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/icusb_eem_drv.h b/mcu/driver/connectivity/usb_class/include/icusb_eem_drv.h
new file mode 100644
index 0000000..71760be
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/icusb_eem_drv.h
@@ -0,0 +1,297 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_eem_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host EEM class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_EEM_DRV_H
+#define USB_HOST_EEM_DRV_H
+
+ //#include "icusb_drv.h"
+ #include "drv_comm.h"
+ #include "usb_host_default_drv.h"
+/***********************************************
+ eem class descriptor definition
+************************************************/
+#define USB_EEM_DEVICE_CODE 0x00
+#define USB_EEM_SUBCLASS_CODE 0x00
+#define USB_EEM_PROTOCOL_CODE 0x00
+
+#define USB_EEM_DATA_INTERFACE_CLASS_CODE 0x02
+#define USB_EEM_DATA_INTERFACE_SUBCLASS_CODE 0x0C
+#define USB_EEM_DATA_INTERFACE_PROTOCOL_CODE 0x07
+
+/***********************************************
+ eem class specific command definition
+************************************************/
+#define USB_EEM_Packet_Type_Mask 0x8000
+#define USB_EEM_Command 0x3800
+#define USB_EEM_Command_Param 0x07FF
+
+#define USB_EEM_DATA_CRC 0x4000
+#define USB_EEM_DATA_Length 0x3FFF
+
+#define USB_EEM_Header_Length 2
+
+
+#define USB_EEM_Command_TYPE 0x1000
+#define USB_EEM_Data_TYPE 0x0000
+
+#define USB_EEM_Data_CRC_SET 0x0000
+
+
+/***********************************************
+ eem class Buffer & Data Length
+************************************************/
+
+#define USB_EEM_MAX_FRAME_SIZE 1518 // TCPIP protocol
+#define USB_EEM_MIN_FRAME_SIZE 46 // TCPIP protocol
+
+#define EEM_TX_BUFFER_NUM 10 // EEM task allocate buffer
+#define EEM_RX_BUFFER_NUM 10 // EEM task allocate buffer
+
+#define USB_MAX_EEM_NUM 1
+
+
+typedef enum
+{
+ USB_EEM_DONE = 0, //Setup DMA
+ USB_EEM_TRANSFER, // DMA Still Running --> last data hasn't send out
+ USB_EEM_NEXT_TRANSFER,
+
+ USB_EEM_NOT_READY, // USB config = F , Enumeraion not finish or device removed
+
+ USB_EEM_CRC_ERROR, // CRC_check_flag = T
+ USB_EEM_LENGTH_ERROR, // Data length doesn't match
+
+ USB_EEM_HEADER_TYPE_ERROR, // data or command packet define
+ USB_EEM_HEADER_PARAM_ERROR //command parameter type
+
+} USB_EEM_RESPONSE;
+
+
+typedef enum
+{
+ IC_USB_SIM1 = 0,
+ IC_USB_SIM2
+} IC_USB_NUM;
+
+typedef enum
+{
+ USB_HOST_EEM_DATA_PAYLOAD = 0,
+ USB_HOST_EEM_COMMAND
+}USB_EEM_HEADER_TYPE;
+
+
+typedef enum
+{
+ USB_HOST_EEM_CMD_ECHO = 0,
+ USB_HOST_EEM_CMD_ECHO_RESPONSE,
+ USB_HOST_EEM_CMD_SUSPEND_HINT,
+ USB_HOST_EEM_CMD_RESPONSE_HINT,
+ USB_HOST_EEM_CMD_RESPONSE_COMPLETE_HINT,
+ USB_HOST_EEM_CMD_TICKLE
+}USB_HOST_EEM_CMD;
+
+typedef enum
+{
+ EEM_RX_FIRST_PACKET =0,
+ EEM_RX_MIDDLE_PACKET,
+ EEM_RX_LAST_PACKET
+}USBH_EEM_RX_STATE;
+
+/* EEM Data header*/
+typedef struct
+{
+ kal_bool bmType;
+ kal_bool bmCRC;
+ kal_uint16 eem_frame_length;
+}USBH_EEM_Data_Header;
+
+
+/* EEM Command Header */
+typedef struct
+{
+ kal_bool bmType;
+ USB_HOST_EEM_CMD bmEEMCmd;
+ kal_uint16 eem_Cmd_Param;
+}USBH_EEM_Command_Header;
+
+
+typedef struct
+{
+ peer_buff_struct *buffer_ptr;
+ kal_uint8 *data_ptr;
+ kal_uint16 data_length;
+ kal_uint8 pool_id;
+}EEM_Buffer_CONTROL;
+
+
+typedef struct
+{
+ USBH_EP_Struct ep_tx_info;
+ USBH_EP_Struct ep_rx_info;
+ USBH_Common_Struct common_info;
+
+ kal_uint8 dev_error_count;
+ kal_bool config; //Descriptor match
+ kal_bool dev_attatch; //Vbus3.3 provide & Device class match
+ kal_bool usb_command;
+ kal_bool reponse_hint;
+ kal_bool reponse_complete_hint;
+ kal_uint16 response_time;
+ kal_uint16 response_complete_time;
+
+ kal_bool dma_rx_running;
+ kal_bool dma_tx_running;
+
+ kal_uint8 tx_sent_buff_index; //data is sending out
+ kal_uint8 tx_wait_buff_index; // wait for next transfer
+ EEM_Buffer_CONTROL tx_buffer[EEM_TX_BUFFER_NUM];
+
+ kal_uint8 rx_full_buff_index; // receive Data
+ kal_uint8 rx_empty_buff_index; // empty buffer get from EEM Tsk
+ EEM_Buffer_CONTROL rx_buffer[EEM_RX_BUFFER_NUM];
+
+ kal_uint16 rx_last_data_length; //FIFO + DMA + FIFO
+ kal_uint16 rx_dma_length; //DMA transfer length
+ USBH_EEM_RX_STATE ep_rx_status;
+
+ USB_EP_DIRECTION stall_ep_dir;
+ kal_uint32 sleep_timer_handle; /* use timer to check whether App need to use Device or not */
+
+}USB_Host_EEM_Struct;
+
+/************************************************************
+
+ extern variables and functions
+
+*************************************************************/
+extern USBD_ClassDriver_Struct USB_Host_Eem_Drv;
+extern USB_Host_EEM_Struct g_UsbHostEem[USB_MAX_EEM_NUM];
+
+//extern kal_uint8 USB_EEM_Check_index(kal_uint8 usb_ip_port);
+extern void USB_Host_EEM_State_Start(void);
+extern void USB_Host_EEM_State_End(void);
+extern void USB_Host_Eem_DMA_TX_Hdlr(void);
+extern void USB_Host_Eem_DMA_RX_Hdlr(void);
+extern void USB_Host_Eem_Data_Transfer(USB_EP_DIRECTION direction);
+extern void USB_Host_Eem_ECHO_Command(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_uint16 nBytes, void *pDst);
+
+#endif /* USB_HOST_ACM_DRV_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/icusb_iccd_adap.h b/mcu/driver/connectivity/usb_class/include/icusb_iccd_adap.h
new file mode 100644
index 0000000..2c4dc42
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/icusb_iccd_adap.h
@@ -0,0 +1,122 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * icusb_iccd_adap.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host mass storage adaptaion layer definitaions (file system API)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_ICCD_ADAP_H
+#define USB_HOST_ICCD_ADAP_H
+
+typedef enum
+{
+ ICUSB_ICCD_P_ATR,
+ ICUSB_ICCD_P_ATR_LENGTH,
+ ICUSB_ICCD_P_DESCRIPTOR,
+ ICUSB_ICCD_P_DELAY
+}USB_HOST_ICCD_PARAMETER;
+
+typedef struct{
+ kal_uint8 *pATR;
+ kal_uint32 atrLen;
+}ICUSB_ICCD_INFO;
+
+
+//SIM Drive : return Status
+typedef enum
+{
+ DEVICE_Is_Always_Busy,
+ DEVICE_Is_Ready,
+ DEVICE_HW_FAIL,
+ ATR_RESPONSE_FAIL,
+ APDU_FAIL,
+ APDU_SUCCESS
+}USB_ICCD_STATE;
+
+
+// SIM Drive => iccd_index is mapping to ICUSB HW
+// only SIM Driver will user use these API
+
+extern USB_ICCD_STATE ICUSB_ICCD_POWER_ON(kal_uint8 iccd_index);
+extern USB_ICCD_STATE ICUSB_ICCD_POWER_RESET(kal_uint8 iccd_index);
+extern USB_ICCD_STATE ICUSB_ICCD_DATA_Transfer(kal_uint8 iccd_index,kal_uint16 tx_length,kal_uint8 *tx_buffer, kal_uint8 *rx_buffer, kal_uint16 *rx_size);
+
+extern void ICUSB_ICCD_Parameter_Setting(kal_uint8 iccd_index,USB_HOST_ICCD_PARAMETER parameter, kal_uint16 data);
+extern void ICUSB_ICCD_Parameter_Querry(kal_uint8 iccd_index, ICUSB_ICCD_INFO *pInfo);
+
+extern void ICUSB_ICCD_Init(kal_uint8 iccd_index);
+extern kal_bool IC_USB_POWER_ON(kal_uint8 iccd_index,kal_bool blocking);
+extern kal_bool IC_USB_Reset_Card(kal_uint8 iccd_index);
+
+
+#endif /* USB_HOST_ICCD_ADAP_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/icusb_iccd_drv.h b/mcu/driver/connectivity/usb_class/include/icusb_iccd_drv.h
new file mode 100644
index 0000000..0fce166
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/icusb_iccd_drv.h
@@ -0,0 +1,260 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * icusb_iccd_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host mass storage class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_ICCD_DRV_H
+#define USB_HOST_ICCD_DRV_H
+
+#include "usb_host_default_drv.h"
+
+/***********************************************
+ iccd class descriptor definition
+************************************************/
+#define USB_ICCD_DEVICE_CODE 0x00
+#define USB_ICCD_SUBCLASS_CODE 0x00
+#define USB_ICCD_PROTOCOL_CODE 0x00
+#define USB_ICCD_INTERFACE_CLASS_CODE 0x0B
+#define USB_ICCD_INTERFACE_SUBCLASS_CODE 0x00
+#define USB_ICCD_INTERFACE_PROTOCOL_CODE 0x02
+
+
+/************************************************************
+ ICCD class parameter definition
+*************************************************************/
+#define USB_ICCD_POWER_ON 0x62
+#define USB_ICCD_POWER_OFF 0x63
+#define USB_ICCD_XFR_BLOCK 0x65
+#define USB_ICCD_DATA_BLOCK 0x6F
+#define USB_ICCD_SLOT_STATUS 0x81
+
+
+//Data Block Parameter
+#define USB_DATA_bResponse_APDU_DONE 0x00
+#define USB_DATA_bResponse_APDU_START_PACKET 0x01
+#define USB_DATA_bResponse_APDU_MIDDLE_PACKET 0x02
+#define USB_DATA_bResponse_APDU_LAST_PACKET 0x03
+#define USB_DATA_bResponse_NEXT_XFR 0x10
+#define USB_DATA_bResponse_Status_Info 0x40
+#define USB_DATA_bResponse_Polling 0x80
+
+//Status parameter
+#define USB_bmIccStatus 0x03
+#define USB_bmIccStatus_Active 0
+#define USB_bmIccStatus_Not_Active 1
+#define USB_bmIccStatus_Not_Present 2
+
+#define USB_bmCommandStatus 0xC0
+#define USB_bmCommandStatus_Ready 0x00
+#define USB_bmCommandStatus_Error 0x40
+
+//Error Code
+#define USB_ICC_MUTE 0xFE
+#define USB_XFR_OVERRUN 0xFC
+#define USB_HW_ERROR 0xFB
+
+
+// Event flag. mith be handled in HISR level. This event is used when state complete to retrive waiting task
+#define EVENT_USB_ICCD_DONE ((kal_uint32)0x00000001)
+#define EVENT_USB_ICCD_DETATCH ((kal_uint32)0x00000002)
+#define EVENT_ICUSB_ENUMERATION_DONE ((kal_uint32)0x00000004) //notice SIM Drive
+#define EVENT_ICUSB_ENUMERATION_FAIL ((kal_uint32)0x00000008) //notice SIM Drive
+
+#define ICCD_ATR_REQ_LENGTH 50
+
+// USB Host ICCD Support Number = ICUSB number
+#define USB_MAX_ICCD_NUM 1
+
+
+
+// ICCD state
+typedef enum
+{
+ USB_HOST_ICCD_IDLE,
+ USB_HOST_ICCD_SEND_COMMAND,
+ USB_HOST_ICCD_REQUEST_COMMAND,
+ USB_HOST_ICCD_SEND_CLEAR_STALL,
+ USB_HOST_ICCD_REQUEST_CLEAR_STALL
+}USB_HOST_ICCD_STATE;
+
+
+
+// Result of the RESPONSE,REQUEST state (EP0 Setup, Data, Status stage complete)
+typedef enum
+{
+ USB_HOST_ICCD_RESULT_OK,
+ USB_HOST_ICCD_RESULT_TIMEOUT,
+ USB_HOST_ICCD_RESULT_NO_RESPONSE,
+ USB_HOST_ICCD_RESULT_NOT_CONFIG,
+ USB_HOST_ICCD_RESULT_STALL
+}USB_HOST_ICCD_RESULT;
+
+// USB-ICC Status (use Data Command / Slot_Status command)
+typedef enum
+{
+ USB_ICCD_DEVICE_Active,
+ USB_ICCD_DEVICE_Cannot_Response,
+ USB_ICCD_DEVICE_HW_ERROR,
+ USB_ICCD_DEVICE_Not_Active,
+ USB_ICCD_DEVICE_NOT_CONFIG,
+ USB_ICCD_DEVICE_Fail //Ep0 contorl pipe transfer fail
+}USB_HOST_ICCD_DEV_STATE;
+
+
+/* The ICCD APDU Response type*/
+typedef enum
+{
+ USB_HOST_ICCD_APDU_RESPONSE,
+ USB_HOST_ICCD_APDU_DONE,
+ USB_HOST_ICCD_APDU_POLLING,
+ USB_HOST_ICCD_CMD_FAIL, // need to get Smart SIM Status
+ USB_HOST_ICCD_NOT_CONFIG,
+ USB_HOST_ICCD_ERROR //Ep0 contorl pipe transfer fail
+}USB_HOST_ICCD_CMD_STATE;
+
+/* Ctrl EP commands that may used after ICCD class driver is started
+ Note that it contains both standard and class specific request */
+typedef enum
+{
+ USB_HOST_ICCD_EP0_CMD_NONE,
+ USB_HOST_ICCD_EP0_CMD_POWER_ON,
+ USB_HOST_ICCD_EP0_CMD_POWER_OFF,
+ USB_HOST_ICCD_EP0_CMD_XFR_BLOCK,
+ USB_HOST_ICCD_EP0_CMD_DATA_BLOCK,
+ USB_HOST_ICCD_EP0_CMD_SLOT_STATUS,
+ USB_HOST_ICCD_EP0_CMD_CLEAR_STALL
+}USB_HOST_ICCD_EP0_CMD;
+
+/************************************************************
+ Implementation structures
+*************************************************************/
+typedef struct
+{
+ kal_uint8 bStatus;
+ kal_uint8 bError;
+ kal_uint8 bReserved;
+}USB_Host_ICCD_Status_Struct;
+
+typedef struct
+{
+ /* device level resource */
+ USBH_Common_Struct common_info;
+
+ kal_eventgrpid event_id; /* event used for (CBW, DATA, CSW) state machine to retrive waiting task */
+ kal_eventgrpid start_event_id;
+ kal_mutexid mutex_id; /* mutex used to protect ms command. When USB task is polling state machine, read/write action from application task should be protected */
+
+ kal_uint32 sleep_timer_handle; /* use timer to check whether App need to use Device or not */
+
+ kal_uint8 dev_error_count;
+ kal_bool config; //Descriptor match
+ kal_bool dev_attatch; //Vbus3.3 provide & Device class match
+
+ USB_HOST_ICCD_DEV_STATE dev_state; //USB-ICC state: ready,active,error
+ USB_HOST_ICCD_RESULT ep0_result; //Setup + Data + Stage Complete
+ USB_HOST_ICCD_CMD_STATE apdu_response; //using DATA_BLOCK query
+ USB_HOST_ICCD_EP0_CMD ep0_cmd; // ICCD Class specific Command
+
+ kal_uint8 atr_data[ICCD_ATR_REQ_LENGTH]; /* ATR Response*/
+ kal_uint16 atr_length;
+ kal_uint16 sleep_time;
+ kal_uint16 rx_real_length;
+ kal_uint16* rx_buffer;
+
+}USB_Host_ICCD_Struct;
+
+
+/************************************************************
+ extern variables and functions
+*************************************************************/
+
+extern USBD_ClassDriver_Struct USB_Host_Iccd_Drv;
+extern USB_Host_ICCD_Struct g_UsbHostIccd[USB_MAX_ICCD_NUM];
+
+extern void USB_Host_ICCD_Reset_Card(kal_uint8 iccd_index);
+extern void USB_Host_ICCD_Enumeration_Fail(kal_uint8 usb_ip_port);
+
+extern USB_HOST_ICCD_RESULT USB_Host_ICCD_POWER_ON(kal_uint8 iccd_index);
+extern USB_HOST_ICCD_RESULT USB_Host_ICCD_POWER_OFF(kal_uint8 iccd_index);
+extern USB_HOST_ICCD_RESULT USB_Host_ICCD_XFR_BLOCK(kal_uint8 iccd_index,kal_uint16 buflen, kal_uint8 *buffer);
+extern USB_HOST_ICCD_CMD_STATE USB_Host_ICCD_DATA_BLOCK(kal_uint8 iccd_index,kal_uint16 *rx_size, kal_uint8 *buffer);
+extern USB_HOST_ICCD_DEV_STATE USB_Host_ICCD_SLOT_STATUS(kal_uint8 iccd_index);
+
+extern void USB_Host_ICCD_Sleep_Timeout(void *parameter);
+
+
+
+#endif /* USB_HOST_MS_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/otg.h b/mcu/driver/connectivity/usb_class/include/otg.h
new file mode 100644
index 0000000..7f244a9
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/otg.h
@@ -0,0 +1,199 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * otg_drv_pri.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+* This file intends for otg definitions.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef OTG_H
+#define OTG_H
+
+#include "otg_if.h"
+//#include "kal_non_specific_general_types.h"
+#include "usb_comm.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+#include "dcl.h"
+
+
+typedef struct
+{
+ kal_uint32 *hnp_srp_parameter;
+ USB_DEVICE_TYPE hnp_srp_type; /* This is mainly used for SRP, HNP */
+ kal_bool b_check_srp; /* If SRP is in progress */
+}OTG_Struct;
+
+
+typedef enum
+{
+ OTG_HDLR_TASK_INIT_MS,
+ OTG_HDLR_TASK_END_MS,
+ OTG_HDLR_TASK_INIT_NOMAL_MS,
+ OTG_HDLR_TASK_END_NORMAL_MS,
+ OTG_HDLR_TASK_ONLY_END_NORMAL_MS,
+ OTG_HDLR_TASK_MAX
+}OTG_HDLR_TASK_TYPE;
+
+
+typedef struct
+{
+ LOCAL_PARA_HDR
+ kal_uint32 *parameter;
+ OTG_HDLR_TASK_TYPE type;
+}otg_hdlr_ind_struct;
+
+
+extern OTG_Struct gUsbOtg;
+
+extern DCL_HANDLE g_OTG_Dcl_Handle;
+
+extern void OTG_Init_Phase1(void);
+extern void OTG_Init_Phase2(void);
+extern void OTG_Release(void);
+extern void OTG_Start_SRP(void);
+extern void OTG_Config_SRP(USB_DEVICE_TYPE type, kal_uint32 *parameter);
+extern void OTG_Config_HNP(USB_DEVICE_TYPE type, kal_uint32 *parameter);
+extern void OTG_Display_Message(OTG_DISPLAY_MSG_TYPE otg_msg_type);
+extern void OTG_Hdlr_Send_Msg(OTG_HDLR_TASK_TYPE type, kal_uint32* parameter);
+
+
+extern void OTG_B_EnDis_HNP(kal_bool set);
+extern void OTG_B_Set_Session_Valid(kal_bool set);
+
+
+#endif
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/ptp_state.h b/mcu/driver/connectivity/usb_class/include/ptp_state.h
new file mode 100644
index 0000000..827a86d
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/ptp_state.h
@@ -0,0 +1,409 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * ptp_state.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file implements the PICTURE TRANSFER PROTOCOL definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef PTP_STATE_H
+#define PTP_STATE_H
+
+//#include "usb_custom.h"
+//#include "fat_fs.h"
+
+
+#include "fs_type.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+#include "kal_general_types.h"
+
+
+
+/***********************************************
+ PTP specific command definitions
+************************************************/
+/* Operation Codes */
+#define PTP_GET_DEVICE_INFO 0x1001
+#define PTP_OPEN_SESSION 0x1002
+#define PTP_CLOSE_SESSION 0x1003
+#define PTP_GET_STORAGE_IDS 0x1004
+#define PTP_GET_STORAGE_INFO 0x1005
+#define PTP_GET_NUM_OBJECTS 0x1006
+#define PTP_GET_OBJECT_HANDLES 0x1007
+#define PTP_GET_OBJECT_INFO 0x1008
+#define PTP_GET_OBJECT 0x1009
+#define PTP_GET_THUMB 0x100A
+#define PTP_SEND_OBJECT_INFO 0x100C
+#define PTP_SEND_OBJECT 0x100D
+#define PTP_GET_PARTIAL_OBJECT 0x101B
+
+/* Response Codes */
+#define PTP_OK 0x2001
+#define PTP_GENERAL_ERROR 0x2002
+#define PTP_SESSION_NOT_OPEN 0x2003
+#define PTP_OPERATION_NOT_SUPPORTED 0x2005
+#define PTP_PARAMETER_NOT_SUPPORTED 0x2006
+#define PTP_NO_THUMBNAIL_PRESENT 0x2010
+#define PTP_DEVICE_BUSY 0x2019
+#define PTP_TRANSACTION_CANCELLED 0x201F
+
+/* Event Codes */
+#define PTP_CANCEL_TRANSACTION 0x4001
+#define PTP_OBJECT_ADDED 0x4002
+#define PTP_OBJECT_REMOVED 0x4003
+#define PTP_STORE_ADDED 0x4004
+#define PTP_STORE_REMOVED 0x4005
+#define PTP_OBJECT_INFO_CHAGNED 0x4007
+#define PTP_REQUEST_OBJECT_TRANSFER 0x4009
+
+
+/* Object Format Codes*/
+#define PTP_ASSOCIATION 0x3001
+#define PTP_SCRIPT 0x3002
+#define PTP_DPOF 0x3006
+#define PTP_EXIF_JPEG 0x3801
+#define PTP_TIFF_EP 0x3802
+#define PTP_BMP 0x3804
+#define PTP_CIFF 0x3805
+#define PTP_GIF 0x3807
+#define PTP_JFIF 0x3808
+#define PTP_PNG 0x380B
+#define PTP_TIFF 0x380D
+#define PTP_TIFF_IT 0x380E
+
+/* Functional Mode Values*/
+#define PTP_STANDARD_MODE 0x0000
+#define PTP_SLEEP_STATE 0x0001
+
+/* ObjectInfo ProtectionStatus Values*/
+#define PTP_NO_PROTECTION 0x0000
+#define PTP_READ_ONLY 0x0001
+
+/* Storage Types */
+#define PTP_FIXED_ROM 0x0001
+#define PTP_REMOVABLE_ROM 0x0002
+#define PTP_FIXED_RAM 0x0003
+#define PTP_REMOVABLE_RAM 0x0004
+
+/* File System Type Values */
+#define PTP_GENERIC_FLAT 0x0001
+#define PTP_GENERIC_HIERARCHICAL 0x0002
+#define PTP_DCF 0x0003
+
+/* StorageInfo AccessCapability Values */
+#define PTP_READ_WRITE 0x0000
+#define PTP_READ_ONLY_WITHOUT_DELETION 0x0001
+#define PTP_READ_ONLY_WITH_DELETION 0x0002
+
+/* Association Types */
+#define PTP_GENERIC_FOLDER 0x0001
+#define PTP_ALBUM 0x0002
+#define PTP_TIME_SEQUENCE 0x0003
+#define PTP_HORIZONTAL_PANORAMIC 0x0004
+#define PTP_VERTICAL_PANORAMIC 0x0005
+#define PTP_2D_PANORAMIC 0x0006
+#define PTP_ANCILLARY 0x0007
+
+/***********************************************
+ Implement definition
+************************************************/
+#define PTP_MAX_OPERATION_CODE_SIZE 13
+#define PTP_MAX_EVENT_CODE_SIZE 7
+#define PTP_MAX_OBJECT_FORMAT_CODE_SIZE 2
+#define PTP_MAX_SCRIPT_OBJECT_HANDLES 6
+//#define PTP_OBJECT_INFO_SIZE 94
+
+#define PTP_SCRIPT_STORAGE_ID 0x00000000
+#define PTP_IMAGE_STORAGE_ID 0x00010001
+#define PTP_ALL_STORAGE_ID 0x0001FFFF
+
+/* Script object handle */
+#define DDISCVRY_DPS 0xC1000000
+#define HDISCVRY_DPS 0xC1000001
+#define DREQUEST_DPS 0xC1000002
+#define DRSPONSE_DPS 0xC1000003
+#define HREQUEST_DPS 0xC1000004
+#define HRSPONSE_DPS 0xC1000005
+
+/* Script object flag shift */
+#define DDISCVRY 0
+#define HDISCVRY 1
+#define DREQUEST 2
+#define DRSPONSE 3
+#define HREQUEST 4
+#define HRSPONSE 5
+
+/* Object handle value */
+#define PTP_NO_HANDLE -1
+
+/***********************************************
+ Implement enum and structure
+************************************************/
+typedef struct
+{
+ kal_uint16 StandardVersion;
+ kal_uint16 VenderExtensionID[2];
+ kal_uint16 VenderExtensionVersion;
+ kal_uint8 VendorExtensionDesc; /* empty string */
+ kal_uint8 FunctionalMode[2];
+ kal_uint8 OperationsSupportedSize[4];
+ kal_uint8 OperationsSupported[PTP_MAX_OPERATION_CODE_SIZE][2];
+ kal_uint8 EventsSupportedSize[4];
+ kal_uint8 EventsSupported[PTP_MAX_EVENT_CODE_SIZE][2];
+ kal_uint8 DevicePropertiesSupportedSize[4]; /* empty array*/
+ kal_uint8 CaptureFormatsSize[4]; /* empty array*/
+ kal_uint8 ImageFormatsSize[4];
+ kal_uint8 ImageFormats[PTP_MAX_OBJECT_FORMAT_CODE_SIZE][2];
+// kal_uint8 padding; /* sizeof(PTP_DeviceInfo_Struct) still count this byte */
+}PTP_DeviceInfo_Struct;
+
+
+typedef struct
+{
+ kal_uint16 StorageType;
+ kal_uint16 FilesystemType;
+ kal_uint16 AccessCapability;
+ kal_uint16 MaxCapacity[4];
+ kal_uint16 FreeSpaceInBytes[4];
+ kal_uint16 FreeSpaceInImages[2];
+}PTP_StorageInfo_Struct;
+
+
+typedef struct
+{
+ kal_uint32 StorageID;
+ kal_uint16 ObjectFormat;
+ kal_uint16 ProtectionStatus;
+ kal_uint32 ObjectCompressedSize;
+ kal_uint16 ThumbFormat;
+ kal_uint16 ThumbCompressedSize[2];
+ kal_uint16 ThumbPixWidth[2];
+ kal_uint16 ThumbPixHeight[2];
+ kal_uint16 ImagePixWidth[2];
+ kal_uint16 ImagePixHeight[2];
+ kal_uint16 ImageBitDepth[2];
+ kal_uint16 ParentObject[2];
+ kal_uint16 AssociationType;
+ kal_uint32 AssociationDesc;
+ kal_uint32 SequenceNumber;
+}PTP_ObjectInfo_Struct;
+
+
+typedef struct
+{
+ /* Pointer to buffer for XML packet transmission operation*/
+ kal_uint8 *dps_request_tx_data;
+ kal_uint8 *dps_response_tx_data;
+ kal_uint8 *dps_request_rx_data;
+ kal_uint8 *dps_response_rx_data;
+
+ /* PTP dataset structure */
+ PTP_DeviceInfo_Struct image_deviceinfo;
+ PTP_StorageInfo_Struct image_storageinfo;
+ PTP_ObjectInfo_Struct image_objectinfo;
+
+ kal_uint32 received_xml_size;
+ kal_uint32 send_dps_request_xml_size;
+ kal_uint32 send_dps_response_xml_size;
+ kal_uint32 current_opened_object_handle; /* current opened object handle */
+ FS_HANDLE current_file_handle; /* current file handle opened by USB */
+
+ kal_uint8 dps_rx_buffer_index; /* Rx XML buffer index, 1 : request xml, 0 : response xml */
+ kal_uint8 script_flag; /* XML script flag */
+ kal_bool get_data_error; /* a flag to check if there is any error happened when taregt send datat to host. In PTP, it means there is an error at the file system operation of image file */
+ kal_uint32 rw_bytes; /* R/W bytes for FS R/W*/
+ kal_bool dps_discovery;
+ kal_bool mmi_start_job; /* a flag to check if it is doing a job now*/
+ kal_bool next_xml_is_start_job;
+ kal_bool is_start_job_xml;
+ kal_bool is_wait_host_respone;
+} PTP_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern PTP_Struct g_PTPImage;
+
+extern void PTP_Parse_MMI_Meg(ilm_struct *p_recv_ilm);
+extern void PTP_Parse_USB_Meg(ilm_struct *p_recv_ilm);
+
+
+#endif /* PTP_STATE_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb.h b/mcu/driver/connectivity/usb_class/include/usb.h
new file mode 100644
index 0000000..329b9eb
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb.h
@@ -0,0 +1,1019 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb1.1 definitions.
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_H
+#define USB_H
+
+
+#include "usb_custom.h"
+#include "usb_custom_def.h"
+//#include "usb_drv.h"
+#include "dcl.h"
+#include "usb_comm.h"
+#include "kal_general_types.h"
+
+
+/* Remove dependence.
+ * It should be releated to MMI behavior. Thus, add it on makefile if request is incoming.
+ */
+//#ifdef __TC01__
+//#define __USB_BOOT_NOT_CHECK_NVRAM_SETTING__
+//#endif
+
+/***********************************************
+ standard command definition
+************************************************/
+
+/* Standard Request Codes */
+#define USB_GET_STATUS 0x00
+#define USB_CLEAR_FEATURE 0x01
+#define USB_SET_FEATURE 0x03
+#define USB_SET_ADDRESS 0x05
+#define USB_GET_DESCRIPTOR 0x06
+#define USB_SET_DESCRIPTOR 0x07
+#define USB_GET_CONFIGURATION 0x08
+#define USB_SET_CONFIGURATION 0x09
+#define USB_GET_INTERFACE 0x0A
+#define USB_SET_INTERFACE 0x0B
+#define USB_SYNCH_FRAME 0x0C
+
+/* Vendor Request Codes */
+#define USB_GET_MS_DESCRIPTOR 0xCC
+
+/* Command bit fields */
+#define USB_CMD_DATADIR 0x80
+
+/* Request Type Field */
+#define USB_CMD_TYPEMASK 0x60
+#define USB_CMD_STDREQ 0x00
+#define USB_CMD_CLASSREQ 0x20
+#define USB_CMD_VENDREQ 0x40
+#define USB_CMD_STDDEVIN 0x80
+#define USB_CMD_STDDEVOUT 0x00
+#define USB_CMD_STDIFIN 0x81
+#define USB_CMD_STDIFOUT 0x01
+#define USB_CMD_STDEPIN 0x82
+#define USB_CMD_STDEPOUT 0x02
+#define USB_CMD_CLASSIFIN 0xA1
+#define USB_CMD_CLASSIFOUT 0x21
+#define USB_CMD_VENDDEVIN 0xC0
+#define USB_CMD_VENDDEVOUT 0x40
+
+
+/* Standard command descriptor type*/
+#define USB_DEVICE 0x01
+#define USB_CONFIG 0x02
+#define USB_STRING 0x03
+#define USB_INTERFACE 0x04
+#define USB_ENDPOINT 0x05
+#define USB_DEVICE_QUALIFIER 0x06
+#define USB_OTHER_SPEED 0x07
+#define USB_INTERFACE_POWER 0x08
+#define USB_OTG_DESC 0x09
+#define USB_INTERFACE_ASSOCIATION 0x0B
+
+#define USB_CMD_DESCMASK 0xFF00
+#define USB_CMD_DEVICE (USB_DEVICE<<8)
+#define USB_CMD_CONFIG (USB_CONFIG<<8)
+#define USB_CMD_STRING (USB_STRING<<8)
+#define USB_CMD_INTERFACE (USB_INTERFACE<<8)
+#define USB_CMD_ENDPOINT (USB_ENDPOINT<<8)
+#define USB_CMD_DEVICE_QUALIFIER (USB_DEVICE_QUALIFIER<<8)
+#define USB_CMD_OTHER_SPEED (USB_OTHER_SPEED<<8)
+#define USB_CMD_INTERFACE_POWER (USB_INTERFACE_POWER<<8)
+
+/* Standard Device Feature Selectors */
+#define USB_FTR_DEVREMWAKE 0x0001
+#define USB_FTR_EPHALT 0x0000
+#define USB_FTR_B_HNP_ENB 0x0003
+#define USB_FTR_A_HNP_SUPPORT 0x0004
+#define USB_FTR_A_ALT_HNP_SUPPORT 0x0005
+#define USB_FTR_TEST_MODE 0x0002
+
+/* Vendor OS feature descriptor, feature index */
+#define USB_FTR_GENRE 0x0001
+#define USB_FTR_EXT_COMPAT_ID 0x0004
+#define USB_FTR_EXT_PROPERTIES 0x0005
+
+
+/* USB test mode */
+#define USB_TEST_J 0x01
+#define USB_TEST_K 0x02
+#define USB_TEST_SE0_NAK 0x03
+#define USB_TEST_PACKET 0x04
+
+/***********************************************
+ standard descriptor definition
+************************************************/
+/* Scriptor length */
+#define USB_DEVDSC_LENGTH 18
+#define USB_CFGDSC_LENGTH 9
+#define USB_IFDSC_LENGTH 9
+#define USB_MAX_IFDSC_LENGTH 258 /* this will change depend on different class interface */
+ /*descriptor requirment*/
+ /* 258 is for video streaming class interface */
+#define USB_EPDSC_LENGTH 7
+#define USB_OTGDSC_LENGTH 3
+#define USB_MAX_CLASS_EPDESC_LENGTH 12 /* this will change depend on different class interface */
+ /*descriptor requirment*/
+ /* 12 is for video control interrupt ep */
+#define USB_IAD_LENGTH 8
+#define USB_DEV_QUA_DSC_LENGTH 10
+#define USB_OTHER_CFGDSC_LENGTH 9
+#define USB_MAX_OS_STRING_LENGTH 18
+#define USB_MAX_OS_FEATURE_DESC_LENGTH 40
+
+
+/* Endpoint direction */
+#define USB_EP_DIR 0x80
+#define USB_EP_DIR_IN 0x80
+#define USB_EP_DIR_OUT 0x00
+
+/* Endpoint transfer types */
+#define USB_EP_TFMASK 0x03
+#define USB_EP_CONTROL 0x00
+#define USB_EP_ISO 0x01
+#define USB_EP_BULK 0x02
+#define USB_EP_INTR 0x03
+
+/* ISO Synchronization types */
+#define USB_ISO_NO_SYNCHRONIZATION 0x00
+#define USB_ISO_ASYNCHRONOUS 0x01
+#define USB_ISO_ADAPTIVE 0x02
+#define USB_ISO_SYNCHRONOUS 0x03
+
+/* ISO Usage types */
+#define USB_ISO_DATA 0x00
+#define USB_ISO_FEEDBACK 0x01
+#define USB_ISO_IMPLICIT_FEEDBACK 0x02
+
+/*****Descriptor Element*****/
+/* Define values for Standard Device Descriptor */
+/* For Device descriptor */
+
+/* bcdDevice value */
+#define USB_DEVDSC_BCDDEVICE_PHONE 0x0100 /* Release number of USB device */
+#define USB_DEVDSC_BCDDEVICE_MODEM_CARD 0x0200 /* Release number of USB modem card device for ECMT */
+#define USB_DEVDSC_BCDDEVICE_MODEM_CARD_FOR_NDIS 0x0300 /* Release number of USB modem card device for NDIS*/
+
+/* Device class code for composite device */
+#define USB_COMPOSITE_DEVICE_CODE 0xEF
+#define USB_COMPOSITE_SUBCLASS_CODE 0x02
+#define USB_COMPOSITE_PROTOCOL_CODE 0x01
+
+/* Device class code for without IAD composite device */
+#define USB_COMPOSITE_NO_IAD_DEVICE_CODE 0x00
+#define USB_COMPOSITE_NO_IAD_SUBCLASS_CODE 0x00
+#define USB_COMPOSITE_NO_IAD_PROTOCOL_CODE 0x00
+
+
+#define USB_DEVDSC_CONFIGS USB_MAX_CONFIG // USB_DEVDSC_CONFIGS --> USB_GetChargeCurrentTableSize()
+
+
+/*For Configuration descriptor*/
+#define USB_CFGDSC_ATTR_NATURE 0x80
+#define USB_CFGDSC_ATTR_SELFPOWER 0x40
+#define USB_CFGDSC_ATTR_REMOTEWAKEUP 0x20
+#define USB_CFGDSC_MAXPOWER (500/2)
+
+#define USB_OTG_HNP_SUPPORT 0x02
+#define USB_OTG_SRP_SUPPORT 0x01
+
+
+/***********************************************
+ Hub class code definition
+************************************************/
+#define USB_HUB_DEVICE_CLASS_CODE 0x09
+#define USB_HUB_DEVICE_SUBCLASS_CODE 0x00
+//#define USB_HUB_DEVICE_PROTOCOL_CODE 0x00
+#define USB_HUB_INTERFACE_CLASS_CODE 0x09
+#define USB_HUB_INTERFACE_SUBCLASS_CODE 0x00
+//#define USB_HUB_INTERFACE_PROTOCOL_CODE 0x00
+
+
+/***********************************************
+ Implement definition
+************************************************/
+
+/* Define configuration, interface, ep number */
+#define USB_MAX_CONFIG 6 /* configuration number */
+#define USB_MAX_IAD 1
+
+#define USB_MAX_INTERFACE 2 /* interface number */
+
+#define USB_MAX_INTERFACE_ALTERNATE_NUM 1 /* interface alternate seting number */
+
+#if defined(__USB_EP_TEST__)
+#define USB_MAX_EP_BULK_TX 4 /* max bulk in ep number */
+#define USB_MAX_EP_BULK_RX 3 /* max bulk in ep number */
+#define USB_MAX_EP_ISO_TX 4 /* max interrupt ep number */
+#define USB_MAX_EP_INTR_TX 4 /* max interrupt ep number */
+#else
+#define USB_MAX_EP_BULK_TX 1 /* max bulk in ep number */
+#define USB_MAX_EP_BULK_RX 1 /* max bulk in ep number */
+#define USB_MAX_EP_INTR_TX 1 /* max interrupt ep number */
+#define USB_MAX_EP_ISO_TX 1 /* max interrupt ep number */
+#endif
+
+#define USB_MAX_STRING 12 /* string number */
+
+#define USB_MAX_EP_PER_IF 3 /* 3 is for image class */
+
+/* serial string array size for that unique Serial number*/
+#define USB_SERIAL_STRING_LEN 16
+
+/* define endpoint data parameters */
+#define USB_EP_NODATA -1 /* no more data for endpoint to send */
+
+
+/***********************************************
+ standard command structure
+************************************************/
+
+/* usb standard command structure */
+typedef struct
+{
+ kal_uint8 bmRequestType;
+ kal_uint8 bRequest;
+ kal_uint16 wValue;
+ kal_uint16 wIndex;
+ kal_uint16 wLength;
+}Usb_Command;
+
+
+
+/***********************************************
+ Standard descriptor structure
+************************************************/
+
+/* standard device descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint16 bcdUSB;
+ kal_uint8 bDeviceClass;
+ kal_uint8 bDeviceSubClass;
+ kal_uint8 bDeviceProtocol;
+ kal_uint8 bMaxPacketSize0;
+ kal_uint16 idVendor;
+ kal_uint16 idProduct;
+ kal_uint16 bcdDevice;
+ kal_uint8 iManufacturer;
+ kal_uint8 iProduct;
+ kal_uint8 iSerialNumber;
+ kal_uint8 bNumConfigurations;
+}Usb_Dev_Dscr;
+
+
+/* standard configuration descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint16 wTotalLength;
+ kal_uint8 bNumInterfaces;
+ kal_uint8 bConfigurationValue;
+ kal_uint8 iConfiguration;
+ kal_uint8 bmAttributes;
+ kal_uint8 bMaxPower;
+}Usb_Cfg_Dscr;
+
+
+/* standard IAD descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bFirstInterface;
+ kal_uint8 bInterfaceCount;
+ kal_uint8 bFunctionClass;
+ kal_uint8 bFunctionSubClass;
+ kal_uint8 bFunctionProtocol;
+ kal_uint8 iFunction;
+}Usb_IAD_Dscr;
+
+
+/* standard interface descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bInterfaceNumber;
+ kal_uint8 bAlternateSetting;
+ kal_uint8 bNumEndpoints;
+ kal_uint8 bInterfaceClass;
+ kal_uint8 bInterfaceSubClass;
+ kal_uint8 bInterfaceProtocol;
+ kal_uint8 iInterface;
+}Usb_If_Dscr;
+
+
+/* standard endpoint descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bEndpointAddress;
+ kal_uint8 bmAttributes;
+ kal_uint8 wMaxPacketSize[2];
+ kal_uint8 bInterval;
+}Usb_Ep_Dscr;
+
+
+/* standard string descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint16 wData[1];
+}Usb_String_Dscr;
+
+
+/* standard string descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bAttribute;
+}Usb_Otg_Dscr;
+
+
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint16 bcdUSB;
+ kal_uint8 bDeviceClass;
+ kal_uint8 bDeviceSubClass;
+ kal_uint8 bDeviceProtocol;
+ kal_uint8 bMaxPacketSize0;
+ kal_uint8 bNumConfigurations;
+ kal_uint8 bReserved;
+}Usb_Dev_Qual_Dscr;
+
+
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint16 wTotalLength;
+ kal_uint8 bNumInterfaces;
+ kal_uint8 bConfigurationValue;
+ kal_uint8 iConfiguration;
+ kal_uint8 bmAttributes;
+ kal_uint8 MaxPower;
+}Usb_Other_Speed_Cfg_Dscr;
+
+
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 qwSignature[14];
+ kal_uint8 bMS_VendorCode;
+ kal_uint8 bPad;
+}Usb_OS_String_Dscr;
+
+
+typedef struct
+{
+ kal_uint32 dwLength;
+ kal_uint16 bcdVersion;
+ kal_uint16 wIndex;
+ kal_uint8 bCount;
+ kal_uint8 bPads_1[7];
+ kal_uint8 bFirstInterfaceNumber;
+ kal_uint8 bPads_2;
+ kal_uint8 compatibleID[8];
+ kal_uint8 subcompatibleID[8];
+ kal_uint8 bPads_3[6];
+}Usb_Ext_Compat_ID_OS_Feature_Dscr;
+
+
+/***********************************************
+ implement enum and structure
+************************************************/
+
+/* device states */
+typedef enum
+{
+ DEVSTATE_DEFAULT = 0,
+ DEVSTATE_SET_ADDRESS,
+ DEVSTATE_ADDRESS,
+ DEVSTATE_CONFIG
+}USB_DEVICE_STATE;
+
+
+/* Endpoint 0 state */
+typedef enum
+{
+ USB_EP0_IDLE=0,
+ USB_EP0_RX,
+ USB_EP0_TX,
+ USB_EP0_RX_STATUS
+}USB_EP0_STATE;
+
+
+/* EP0 status */
+typedef struct
+{
+ kal_int32 nBytesLeft; /* number of bytes left to send in TX mode */
+ void *pData; /* pointer to data to transmit/receive */
+ kal_int32 nBytesRecv; /* number of bytes received in RX mode */
+ kal_uint8 byFAddr; /* new function address */
+ kal_bool no_ZLP; /* No need ZLP when wLength == transfer size */
+}Usb_Ep0_Status;
+
+
+/* Bulk IN endpoint status */
+typedef struct
+{
+ void *pData; /* pointer to data buffer */
+ kal_int32 nBytesLeft; /* number of bytes left to send */
+ kal_uint8 byEP; /* endpoint number */
+}Usb_EpBIn_Status;
+
+
+/* Bulk OUT endpoint status */
+typedef struct
+{
+ void *pData; /* pointer to data buffer */
+ kal_int32 nBuffLen; /* length of data buffer */
+ kal_int32 nBytesRecv; /* number of bytes received */
+ kal_uint8 byEP; /* endpoint number */
+}Usb_EpBOut_Status;
+
+
+typedef enum
+{
+ USB_NORMAL_BOOT = 0,
+ USB_BOOT_ONE_PORT,
+ USB_BOOT_TWO_PORT,
+ USB_BOOT_THREE_PORT,
+ USB_BOOT_FOUR_PORT,
+ USB_BOOT_FIVE_PORT
+// USB_RNDIS_ONE_PORT
+}USB_Comport_Boot_Status;
+
+typedef enum
+{
+ USB_COMPORT_WIN = 0,
+ USB_COMPORT_WIN_SINGLE_INTERFACE,
+ USB_COMPORT_MAC,
+ USB_COMPORT_LINUX,
+ USB_COMPORT_MBIM,
+}USB_Comport_OS_Driver_Status;
+
+typedef enum
+{
+ USB_MASK_OWNER_COM_1 = 0,
+ USB_MASK_OWNER_COM_2,
+ USB_MASK_OWNER_COM_3,
+ USB_MASK_OWNER_COM_4,
+ USB_MASK_OWNER_COM_5,
+ USB_MASK_OWNER_MS = 10,
+ USB_MASK_OWNER_ALL,
+ USB_MASK_OWNER_MAX
+}USB_MASK_OWNER;
+
+
+/* interface create function pointer */
+typedef void (*usb_create_if_func_ptr)(void *);
+/* interface speed reset function pointer */
+typedef void (* usb_speed_if_func_ptr)(kal_bool bset);
+/* EP0 rx interrupt handler */
+typedef void (*usb_ep0_rx_ptr)(void *);
+/* class specific command interrupt handler */
+typedef void (*usb_class_specific_handler_ptr)(Usb_Ep0_Status *, Usb_Command*);
+/* endpoint interrupt handler */
+typedef void (*usb_ep_handler_ptr)(void);
+/* EP0 command interrupt handler */
+typedef void (*usb_ep0_cmd_ptr)(Usb_Command *pcmd);
+
+typedef void (*usb_void_func)(void);
+
+/* endpoint information, including endpoint status */
+typedef struct
+{
+ union
+ {
+ Usb_Ep_Dscr stdep; /* ep descriptor */
+ kal_uint8 classep[USB_MAX_CLASS_EPDESC_LENGTH];
+ }epdesc;
+
+ union
+ {
+ Usb_EpBIn_Status epin_status;
+ Usb_EpBOut_Status epout_status;
+ }ep_status; /* ep status */
+
+ usb_ep_handler_ptr ep_reset; /* ep reset handler */
+ kal_uint16 epdscr_size; /* descriptor length */
+}Usb_Ep_Info;
+
+
+typedef struct
+{
+ Usb_Ep_Info *ep_info[USB_MAX_EP_PER_IF];/* endpoint attach to the interface info */
+ kal_uint16 ifdscr_size; /* descriptor length */
+ Usb_If_Dscr stdif;
+}Usb_Alternate_Interface_Info;
+
+
+/* interface information, including endpoint information and interface information*/
+typedef struct
+{
+ kal_char *interface_name_ptr; /* interface name */
+ usb_class_specific_handler_ptr if_class_specific_hdlr; /* interface specific handler, handle ep0 class specific request */
+ kal_uint16 ifdscr_size; /* descriptor length */
+ union
+ {
+ Usb_If_Dscr stdif;
+ kal_uint8 classif[USB_MAX_IFDSC_LENGTH];
+ }ifdscr;
+
+ Usb_Ep_Info *ep_info[USB_MAX_EP_PER_IF];/* endpoint attach to the interface info */
+
+#if defined(__USB_SUPPORT_ISO_PIPE__)
+ Usb_Alternate_Interface_Info alternate_if_info[USB_MAX_INTERFACE_ALTERNATE_NUM];
+ kal_uint8 alternate_setting; /* alternate setting number */
+#endif
+
+}Usb_Interface_Info;
+
+
+/* configuration information */
+typedef struct
+{
+ Usb_Cfg_Dscr stdcfg; /* config descriptor */
+}Usb_Config_Info;
+
+
+typedef struct
+{
+ kal_bool b_enable;
+ kal_uint8 cmd;
+ usb_ep0_cmd_ptr ep0_cmd_hdlr;
+}Usb_EP0_Cmd_Hdler;
+
+/* device information, used for usb level */
+typedef struct
+{
+ USB_DEVICE_TYPE device_type;
+ USB_DEVICE_STATE nDevState; /*DEVSTATE_CONFIG,DEVSTATE_ADDRESS,DEVSTATE_DEFAULT*/
+ kal_bool remoteWk;
+#if defined(__DUAL_TALK_MODEM_SUPPORT__)
+ kal_bool isRemoteWking;
+#endif
+
+ kal_uint32 memory_addr;// allocate memory buffer address
+ kal_uint32 reserved_memory_size;//memory left size
+
+ kal_bool self_powered;
+ kal_bool ep0_send_one_pkt; /* the variable to record ep0 will send only one packet */
+ kal_bool usb_send_config_result; /* to send configure may be fail */
+
+ kal_uint8 config_num;
+ kal_uint8 interface_num[USB_MAX_INTERFACE];
+ USB_EP0_STATE ep0_state;
+
+
+ /* Add for multi-configurations*/
+ PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
+ kal_uint8 multi_Max_Power[USB_MAX_CONFIG];
+ kal_uint8 current_table_index;
+
+
+ /* used for resource management*/
+// optimize code size : cannot change order
+ kal_uint8 resource_ep_bulk_tx_number;
+ kal_uint8 resource_ep_bulk_rx_number;
+ kal_uint8 resource_ep_intr_tx_number;
+ kal_uint8 resource_interface_number;
+ kal_uint8 resource_string_number;
+#ifdef __USB_SUPPORT_ISO_PIPE__
+ kal_uint8 resource_ep_iso_tx_number;
+#endif
+#if defined(__USB_SUPPORT_ISO_PIPE__)
+ kal_uint8 resource_interface_alternate_number[USB_MAX_INTERFACE];
+#endif
+ kal_uint8 resource_iad_number;
+// resource_iad_number : must be the end of resource parameter
+
+
+
+ /* the configuration only one for saving memory */
+// optimize code size : cannot change order
+ Usb_Dev_Dscr devdscr;
+ Usb_Cfg_Dscr cfgdscr;
+ Usb_Ep_Info ep_bulk_tx_info[USB_MAX_EP_BULK_TX];
+ Usb_Ep_Info ep_bulk_rx_info[USB_MAX_EP_BULK_RX];
+ Usb_Ep_Info ep_intr_tx_info[USB_MAX_EP_INTR_TX];
+ Usb_Interface_Info if_info[USB_MAX_INTERFACE];
+#ifdef __USB_SUPPORT_ISO_PIPE__
+ Usb_Ep_Info ep_iso_tx_info[USB_MAX_EP_ISO_TX];
+#endif
+ Usb_String_Dscr *resource_string[USB_MAX_STRING];
+ Usb_IAD_Dscr iad_desc[USB_MAX_IAD];
+#ifdef __OTG_ENABLE__
+ Usb_Otg_Dscr otgdscr;
+#endif
+#ifdef __USB_IMAGE_CLASS__
+ Usb_OS_String_Dscr os_string_desc;
+ Usb_Ext_Compat_ID_OS_Feature_Dscr os_feature_desc;
+#endif
+
+ kal_uint8 *conf; /*just for descriptor transfer*/
+// conf : : must be the end of descriptor parameter
+
+ Usb_Command cmd; /*USB_COMMAND*/
+
+ Usb_Ep0_Status ep0info;
+ usb_ep0_rx_ptr ep0_rx_handler;
+ Usb_EP0_Cmd_Hdler ep0_class_cmd_handler; /* class specific ep0 cmd */
+
+ /* serial string unique for each phone*/
+ kal_uint16 serial_string[USB_SERIAL_STRING_LEN];
+
+ /* customizable variables*/
+ const USB_DEVICE_PARAM *device_param;
+} Usb_Device;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern Usb_Device gUsbDevice;
+
+void USB_EP0_Command_Hdlr(kal_bool bError);
+
+
+#ifdef __RTL_SIMULATION_FOR_60QBIT__
+extern void usb_irq_disable_duration_test2(void);
+#endif
+
+extern void USB_Send_Msg_Ext_Queue(module_type dstid,msg_type msg_id,void *data);
+
+extern kal_uint32 USB_Get_Memory (kal_uint32 len);
+extern void USB_Free_Memory(void);
+
+#endif /* USB_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_adap.h b/mcu/driver/connectivity/usb_class/include/usb_adap.h
new file mode 100644
index 0000000..9c07395
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_adap.h
@@ -0,0 +1,328 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_adap.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb adaption layer between HW driver and class drivers
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_ADAP_H
+#define USB_ADAP_H
+
+
+//#include "kal_non_specific_general_types.h"
+#include "usb_comm.h"
+#include "dcl.h"
+//#include "usb_drv.h"
+#include "usb.h"
+#include "usb_mode.h"
+
+//#if defined(__MTK_TARGET__)
+//#if defined (__ARMCC_VERSION)
+//#define INLINE static __inline
+//#elif defined (__GNUC__)
+//#define INLINE inline
+//#endif /* ARMCC , GNUC */
+//#else /* __MTK_TARGET__ */
+//#define INLINE __inline
+//#endif /* __MTK_TARGET__ */
+
+
+static INLINE USB_DEVICE_STATE USB_Get_Device_State(void)
+{
+ return gUsbDevice.nDevState;
+}
+
+static INLINE void USB_Set_Device_State(USB_DEVICE_STATE usb_device_state)
+{
+ gUsbDevice.nDevState = usb_device_state;
+}
+
+static INLINE USB_DEVICE_TYPE USB_Get_Device_Type(void)
+{
+ return gUsbDevice.device_type;
+}
+
+static INLINE void USB_Set_Device_Type(USB_DEVICE_TYPE usb_device_type)
+{
+ gUsbDevice.device_type = usb_device_type;
+}
+
+static INLINE USB_EP0_STATE USB_Get_Endpoint0_State(void)
+{
+ return gUsbDevice.ep0_state;
+}
+
+static INLINE void USB_Set_Endpoint0_State(USB_EP0_STATE ep0_state)
+{
+ gUsbDevice.ep0_state = ep0_state;
+}
+
+static INLINE USB_Comport_Boot_Status USB_Get_Comport_Boot_Status(void)
+{
+ return g_UsbMode.usb_comport_boot;
+}
+
+static INLINE void USB_Release(void)
+{
+
+}
+
+static INLINE void USB_Register_EP0_RxHdlr(usb_ep0_rx_ptr handler)
+{
+ gUsbDevice.ep0_rx_handler = handler;
+}
+
+
+
+extern void USB_Register_CreateFunc(kal_char* if_name, usb_create_if_func_ptr if_create_func, usb_void_func if_init_func,
+ usb_void_func if_enable_func, usb_speed_if_func_ptr if_speed_func, usb_void_func if_resume_func);
+extern void USB_Register_Device_Code(kal_uint8 device_code, kal_uint8 subclass_code, kal_uint8 protocol_code, kal_uint16 product_code);
+extern void USB_DeRegister_CreateFunc(void);
+//extern void USB_DeRegister_Device_Code(void);
+extern Usb_Ep_Info* USB_Get_Intr_Ep(kal_uint8 *p_num);
+#ifdef __USB_SUPPORT_ISO_PIPE__
+extern Usb_Ep_Info* USB_Get_Iso_Tx_Ep(kal_uint8 *p_num);
+#endif
+#if defined(__USB_SUPPORT_ISO_PIPE__)
+extern Usb_Alternate_Interface_Info* USB_Get_Interface_Alternate_Setting(kal_uint8 p_num);
+#endif
+
+extern Usb_Ep_Info* USB_Get_Bulk_Tx_Ep(kal_uint8 *p_num);
+extern Usb_Ep_Info* USB_Get_Bulk_Rx_Ep(kal_uint8 *p_num);
+extern Usb_Interface_Info* USB_Get_Interface_Number(kal_uint8 *p_num);
+extern kal_uint8 USB_Get_String_Number(void *usb_string);
+extern Usb_IAD_Dscr* USB_Get_IAD_Number(void);
+
+extern void USB_Release_Device_Status(void);
+extern void USB_Register_EP0_Class_CmdHdlr(kal_uint8 cmd, usb_ep0_cmd_ptr handler);
+extern void USB_Init(USB_DEVICE_TYPE type, kal_bool b_enable, kal_bool is_ft_mode);
+//extern void USB_Release(void);
+//extern void USB_Register_EP0_RxHdlr(usb_ep0_rx_ptr handler);
+void USB_Mask_USB_CORE(USB_MASK_OWNER owner);
+void USB_UnMask_USB_CORE(USB_MASK_OWNER owner);
+extern void USB_UnMask_Irq(USB_MASK_OWNER owner);
+extern void USB_Mask_Irq(USB_MASK_OWNER owner);
+extern void USB_Generate_EP0Data(Usb_Ep0_Status*pep0state, Usb_Command*pcmd, void *data, kal_int32 len);
+
+
+extern void USB_Register_Drv_Info(USB_DRV_HDLR_TYPE type, kal_uint32 ep_num, usb_drv_intr_handler_ptr hdlr);
+extern void USB_Set_UnMask_Irq(kal_bool set);
+extern kal_bool USB_Get_UnMask_Irq(void);
+extern kal_uint16 USB_GetFrameCount(void);
+extern void USB_PDNmode(kal_bool pdn_en);
+
+
+extern void USB_TxEPEn(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, USB_ENDPT_DMA_USAGE dma_usage_type, kal_bool is_flush, kal_bool is_ft_mode);
+extern void USB_TxEPDis(kal_uint32 ep_num, USB_ENDPT_DMA_USAGE dma_usage_type);
+extern void USB_RxEPEn(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, USB_ENDPT_DMA_USAGE dma_usage_type, kal_bool is_flush, kal_bool is_ft_mode);
+extern void USB_RxEPDis(kal_uint32 ep_num, USB_ENDPT_DMA_USAGE dma_usage_type);
+extern void USB_Config_TxEP_Type(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, kal_bool b_is_use_dma);
+extern void USB_Config_RxEP_Type(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, kal_bool b_is_use_dma);
+extern void USB_TxEPClearDataTog(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern void USB_RxEPClearDataTog(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern USB_EP_STATE USB_TxEP_Usage(kal_uint32 ep_num);
+extern USB_EP_STATE USB_RxEP_Usage(kal_uint32 ep_num);
+extern void USB_EPFIFORead(kal_uint32 ep_num, kal_uint16 nBytes, void *pDst, kal_bool force_one_byte_access);
+extern void USB_EPFIFOWrite (kal_uint32 ep_num, kal_uint16 nBytes, void *pSrc);
+extern void USB_CtrlEPStall(kal_uint32 ep_num, USB_EP_DIRECTION direction, kal_bool stall_enable);
+//extern void USB_Get_EP0_Status(kal_bool *p_transaction_end, kal_bool *p_sent_stall);
+extern void USB_Update_EP0_State(USB_EP0_DRV_STATE state, kal_bool stall, kal_bool end);
+extern kal_uint32 USB_EP0_Pkt_Len(void);
+extern void USB_EP_Tx_Ready(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern kal_uint32 USB_EP_Rx_Pkt_Len(kal_uint32 ep_num);
+extern void USB_EP_Rx_Ready(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern kal_bool USB_Is_EP_Tx_Empty(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern kal_bool USB_Is_EP_Rx_Empty(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern void USB_Clear_Tx_EP_FIFO(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, kal_bool b_reset_toggle);
+extern void USB_Clear_Rx_EP_FIFO(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type, kal_bool b_reset_toggle);
+
+/* DMA control functions */
+extern void USB_Get_DMA_Channel(kal_uint32 ep_tx_num, kal_uint32 ep_rx_num, USB_EP_DIRECTION direction, kal_bool same_chan);
+extern void USB_Stop_DMA_Channel(kal_uint32 ep_num, USB_EP_DIRECTION direction);
+extern void USB_Free_DMA_Channel(kal_uint32 ep_tx_num, kal_uint32 ep_rx_num, USB_EP_DIRECTION direction, kal_bool same_chan);
+extern void USB_DMA_Setup(kal_uint32 ep_num, USB_EP_DIRECTION direction, USB_ENDPT_TXFER_TYPE ep_type, kal_uint32 addr, kal_uint32 length,
+ usb_dma_callback callback, kal_bool callback_upd_run, kal_bool known_size, USB_DMA_TYPE dma_type);
+
+extern kal_bool USB_DMA_Get_Run_Status(kal_uint32 ep_num, USB_EP_DIRECTION direction);
+extern void USB_DMA_Set_Run_Status(kal_uint32 ep_num, USB_EP_DIRECTION direction, kal_bool status);
+extern void USB_Set_DMA_Limiter(kal_uint32 dma_limit_num);
+
+
+extern void USB_Switch_DMA_Burst_mode(kal_bool b_enable);
+extern void USB_Register_DMA_Channel(kal_uint32 ep_num, USB_EP_DIRECTION direction, kal_uint8 chan_num, kal_bool same_chan);
+extern void USB_Set_DMA_Burst_Mode(kal_uint8 dma_burst_mode);
+
+extern kal_bool USB_Is_High_Speed(void);
+
+extern void USB_Enter_Test_Mode(USB_TEST_MODE_TYPE test_selector);
+//extern void USB_Reset_FIFO(void);
+extern kal_bool USB_Is_FIFO_Not_Empty(void);
+extern kal_bool USB_Is_Suspend_Power_Status(void);
+
+extern void USB_Polling_Transmit_Done(kal_uint32 ep_num, USB_ENDPT_TXFER_TYPE ep_type);
+extern void USB_Polling_Transmit_Data(kal_uint32 ep_num, USB_EP_DIRECTION direction, USB_ENDPT_TXFER_TYPE ep_type, kal_uint32 addr, kal_uint32 length,
+ usb_dma_callback callback, kal_bool callback_upd_run, kal_bool known_size, USB_DMA_TYPE dma_type);
+extern void USB_Polling_Recv_Data(void);
+
+
+extern void USB_Clr_RX_EP_ISR(kal_uint32 ep_num);
+extern kal_bool USB_Get_RX_EP_ISR_Status(kal_uint32 ep_num);
+
+//extern kal_bool USBDL_Is_USB_Download_Mode(void);
+//extern kal_bool USBDL_Is_USB_Fast_Meta_Mode(void);
+
+
+extern void USB_Debug_Information(kal_uint32 ep_num, USB_EP_DIRECTION direction,kal_bool check_error);
+extern void USB_DUMP(void);
+
+extern DCL_USB_IP_VERSION USB_IP_Version(void);
+
+
+extern kal_uint32 USB_Intr_Max_Packet_Size(void);
+extern kal_uint32 USB_Bulk_Max_Packet_Size(void);
+#ifdef __USB_SUPPORT_ISO_PIPE__
+extern kal_uint32 USB_Iso_Max_Packet_Size(void);
+#endif
+
+
+extern DCL_HANDLE g_USB_Dcl_Handle;
+
+typedef void (*usb_hisr)(void);
+
+
+//=========================== DCL interface to other module =====================================//
+
+extern void USB_GPTI_StartItem(kal_uint32 handle,kal_uint16 tick,void (*gptimer_func)(void *),void *parameter);
+extern void USB_GPTI_StopItem(kal_uint32 handle);
+extern void USB_GPTI_GetHandle(kal_uint32* handle);
+extern void USB_GPTI_ReleaseHandle(kal_uint32* handle);
+//extern kal_uint32 USB_GPTI_GetHandle(void);
+//extern kal_uint32 USB_GPTI_ReleaseHandle(kal_uint32 handle);
+
+
+#ifdef WEBCAM_SUPPORT
+extern void USB_GPT3_Start(void);
+extern void USB_GPT3_Stop(void);
+extern kal_uint32 USB_GPT3_return_current_count(void);
+#endif
+
+
+extern void USB_CHR_USB_EINT_UnMask(void);
+
+//extern kal_bool USB_INT_USBBoot(void);
+
+//extern void USB_BMT_NO_CHARGING_OUT(kal_bool cable_in);
+
+static INLINE kal_bool USB_INT_USBBoot(void)
+{
+ DCL_HANDLE g_PW_Dcl_Handle;
+ PW_CTRL_IS_USB_BOOT CtrlVal;
+
+ g_PW_Dcl_Handle = DclPMU_Open(DCL_PW, FLAGS_NONE);
+ DclPW_Control(g_PW_Dcl_Handle, PW_CMD_IS_USB_BOOT,(DCL_CTRL_DATA_T *)&CtrlVal);
+ return (kal_bool)CtrlVal.val;
+}
+
+static INLINE void USB_Get_Current_Table(void)
+{
+ DCL_HANDLE pmu_handle; // add for usb charging
+
+ pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);
+ DclPMU_Control(pmu_handle, CHR_GET_CHR_CURRENT_LIST, (DCL_CTRL_DATA_T *)&gUsbDevice.get_chr_current_list);
+ DclPMU_Close(pmu_handle);
+}
+
+static INLINE void USB_Register_USB_HISR(usb_hisr func_ptr)
+{
+ DCL_HANDLE pmu_handle; // add for usb charging
+ CHR_DET_CTRL_REGISTER_USB_HISR ChrDetVal;
+
+ pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);
+ ChrDetVal.usb_det_hisr = func_ptr;
+ Dcl_Chr_Det_Control(pmu_handle, CHR_DET_CMD_REGISTER_USB_HISR, (DCL_CTRL_DATA_T *)&ChrDetVal);
+ DclPMU_Close(pmu_handle);
+}
+
+
+static INLINE void USB_BMT_NO_CHARGING_OUT(void)
+{
+ DCL_HANDLE bmt_handler;
+ BMT_CTRL_SENDMES2UEM_T bmt_cmd_data1;
+
+ bmt_handler = DclBMT_Open(DCL_BMT,FLAGS_NONE);
+ bmt_cmd_data1.ChargerMsg = DCL_BMT_USB_NO_CHARGING_OUT;
+ DclBMT_Control(bmt_handler, BMT_CMD_SENDMES2UEM, (DCL_CTRL_DATA_T *)&bmt_cmd_data1); // New API with CMD & DATA
+}
+
+static INLINE void USB_BMT_NO_CHARGING_IN(void)
+{
+ DCL_HANDLE bmt_handler;
+ BMT_CTRL_SENDMES2UEM_T bmt_cmd_data1;
+
+ bmt_handler = DclBMT_Open(DCL_BMT,FLAGS_NONE);
+ bmt_cmd_data1.ChargerMsg = DCL_BMT_USB_NO_CHARGING_IN;
+ DclBMT_Control(bmt_handler, BMT_CMD_SENDMES2UEM, (DCL_CTRL_DATA_T *)&bmt_cmd_data1); // New API with CMD & DATA
+}
+
+
+#endif /* USB_ADAP_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_debug_tool.h b/mcu/driver/connectivity/usb_class/include/usb_debug_tool.h
new file mode 100644
index 0000000..5bb18ba
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_debug_tool.h
@@ -0,0 +1,1057 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_debug_tool.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb common driver debug buffer definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_DEBUG_TOOL_H
+#define USB_DEBUG_TOOL_H
+
+
+#include "kal_general_types.h"
+
+
+
+/***********************************************
+ implement definition
+************************************************/
+
+#if defined(__LOW_COST_SUPPORT_ULC__)
+#define USB_DBG_DATA_SIZE 64
+#else
+#define USB_DBG_DATA_SIZE 512
+#endif
+
+
+typedef enum
+{
+ USB_EP0_SET_CONFIGURATION = 1,
+ USB_RESET,
+ USB_SUSPEND,
+ USB_RESUME,
+ USB_DISCONN,
+ USB_RELEASE_TYPE,
+ USB_DBG_CABLE_PLUG_IN,
+ USB_DBG_CABLE_PLUG_OUT,
+ USB_DMA_LISR,
+ USB_DBG_HISR,
+ USB_DBG_HISR_ERROR_REASON,
+ USB_DBG_IN_HOST_MODE,
+ USB_DBG_DMA_CALLBACK,
+ USB_HISR_ERROR,
+ USB_HISR_SUSPEND_AND_CONN_ISR,
+ USB_UNEXPECTED_RX_HISR,
+ USB_DBG_HISR_STALL_INTR,
+ USB_UPDATE_EP0_STATE_CLEAR_SENT_STALL,
+ USB_UPDATE_EP0_STATE_SEND_STALL,
+ USB_EPN_CLEAR_SENT_STALL_RX,
+ USB_EPN_CLEAR_SENT_STALL_TX,
+ USB_EPN_SEND_STALL_RX,
+ USB_EPN_SEND_STALL_TX,
+ USB_HISR_DMA_CALLBACK_1,
+ USB_HISR_DMA_CALLBACK_2,
+ USB_DBG_DMA_CALLBACK_2,
+ USB_HISR_DMA_CALLBACK_FAST_1,
+ USB_HISR_DMA_CALLBACK_FAST_2,
+ USB_HISR_EP0_TX,
+ USB_HISR_EP0_RX,
+ USB_EPN_CTRL_STALL,
+ USB_CLEAR_TX_EP_FIFO,
+ USB_CLEAR_RX_EP_FIFO,
+ USB_EPN_UNEXPECTED_TX_HISR,
+ USB_EPN_UNEXPECTED_RX_HISR,
+ USB_UPDATE_EP0_STATE_READ_END,
+ USB_UPDATE_EP0_STATE_WRITE_RDY,
+ USB_EP0_SET_ADDRESS,
+ USB_EP0_GET_DESCRIPTOR,
+ USB_EP0_SET_INTERFACE,
+ USB_EP0_GET_CONFIGURATION,
+ USB_EP0_GET_INTERFACE,
+ USB_EP0_CLEAR_FEATURE,
+ USB_EP0_SET_FEATURE,
+ USB_EP0_GET_STATUS_TX,
+ USB_EP0_GET_STATUS_RX,
+ USB_MS_STOP_DMA_0,
+ USB_MS_STOP_DMA_1,
+ USB_MS_STOP_DMA_2,
+ USB_MS_STOP_DMA_3,
+ USB_SET_PDN_FLAG_TRUE,
+ USB_SET_PDN_FLAG_FALSE,
+ USB_TASK_UNMASK_EINT,
+ USB_USBCFG_REQ,
+ USB_DBG_SET_TXPKTREADY,
+ USB_TXCSR_STAT,
+ USB_RXCSR_STAT,
+ USB_MASK_IRQ,
+ USB_UNMASK_IRQ,
+ USB_MEMORY_GET,
+ USB_MEMORY_FREE,
+#ifdef __USB_MASS_STORAGE_ENABLE__
+ USB_MS_BUILD_DMA_TX,
+ USB_MS_BUILD_DMA_TX_CALLBACK,
+ USB_MS_BUILD_DMA_RX,
+ USB_MS_BUILD_DMA_RX_CALLBACK,
+ USB_MS_FIFO_RX_HDLR,
+ USB_MS_FIFO_RX_WITH_WRONG_CBW_SIZE,
+// USB_MS_BUILD_DMA_RX_START_TIMER,
+// USB_MS_BUILD_DMA_RX_STOP_TIMER,
+// USB_MS_BUILD_DMA_RX_TIMEOUT,
+ USB_MS_ERROR_CMD,
+ USB_MS_EP0_RESET,
+ USB_MS_RESET_MSG,
+ USB_MS_RECEIVE_RESET_MSG,
+ USB_MS_SWITCH_TO_FIFO_RX_BY_USB_CONFIG,
+ USB_MS_GET_MAX_LUN,
+ USB_MS_CMD_CBW_IS_NOT_VALID,
+ USB_MS_CMD_TESTUNITREADY,
+ USB_MS_CMD_INQUIRY,
+ USB_MS_CMD_PREVALLOW_MEDIA_REMOVL,
+ USB_MS_CMD_USBMS_WRITE10,
+ USB_MS_CMD_USBMS_USB_END,
+ USB_MS_CMD_USBMS_MSDC,
+ USB_MS_CMD_USBMS_WRITE12,
+ USB_MS_CMD_USBMS_READ10,
+ USB_MS_CMD_USBMS_READ12,
+ USB_MS_CMD_READ_CAPACITY,
+ USB_MS_CMD_READ_FORMATCAPACITY,
+ USB_MS_CMD_REQUESTSENSE,
+ USB_MS_CMD_USBMS_VERIFY,
+ USB_MS_CMD_MODE_SENSE,
+ USB_MS_CMD_MODE_SENSE6,
+ USB_MS_CMD_START_STOP_UNIT,
+ USB_MS_CMD_SYNCHRONIZE_CACHE_10,
+ USB_MS_CMD_READ_TOC,
+ USB_MS_CMD_VENDOR,
+ USB_MS_LOCKFAT,
+ USB_MS_UNLOCKFAT,
+ USB_MS_LOCKFAT_FAIL,
+ USB_MS_READ_FAIL_HANDLER,
+#endif
+ USB_ACM_DMA_SETUP,
+ USB_ACM_DMA_SETUP_1,
+ USB_ACM_DMA_SETUP_2,
+ USB_ACM_DMA_SETUP_3,
+ USB_ACM_DMA_SETUP_4,
+ USB_ACM_DMA_CALLBACK,
+ USB_ACM_SEND_INTERRUPT,
+ USB_ACM_SEND_INTERRUPT1,
+ USB_ACM_SEND_INTERRUPT2,
+ USB_ACM_INTERRUPT_HANDLER,
+ USB_ACM_INTERRUPT_RESET,
+ USB_ACM_TIMEOUT,
+ USB_ACM_ESCAPE_CHAR,
+ USB_ACM_USB2UART_RNDIS_Intr,
+ USB_ACM_USB2UART_RNDIS_Error,
+ USB_ACM_USB2UART_RNDIS_Busy,
+ USB_ACM_USB2UART_PutUARTBytes,
+ USB_ACM_USB2UART_PutUARTByte,
+ USB_ACM_USB2UART_GetUARTByte,
+ USB_ACM_USB2UART_CtrlDCD,
+ USB_ACM_USB2UART_SendISRData,
+ USB_ACM_USB2UART_PutISRBytes,
+ USB_ACM_USB2UART_PutBytes,
+ USB_ACM_USB2UART_ClrTxBuffer,
+ USB_ACM_USB2UART_ClrRxBuffer,
+ USB_ACM_USB2UART_EP_DISABLE,
+ USB_ACM_USB2UART_EP_ENABLE,
+ USB_ACM_USB2UART_Clear_Tx_ISR_Buffer,
+ USB_ACM_USB2UART_Clear_Rx_ISR_Buffer,
+ USB_ACM_USB2UART_Clear_Tx_Buffer,
+ USB_ACM_USB2UART_Switch_port,
+ USB_ACM_SEND_SHORT_PKT,
+ USB_ACM_DMA_SEND_SHORT_PKT,
+ USB_ACM_RX_PKT,
+ USB_ACM_RX_PKT_LENGTH,
+ USB_ACM_RX_FLC_PKT_LENGTH,
+ USB_ACM_RX_NEXT_PKT_LENGTH,
+ USB_ACM_SEND_READY_TO_WRITE,
+ USB_ACM_SEND_READY_TO_READ,
+ USB_ACM_HIGH_SPEED_IF_ENABLE,
+ USB_ACM_HIGH_SPEED_IF_DISABLE,
+ USB_ACM_HIGHSPEED_PUTBYTES,
+ USB_ACM_HIGHSPEED_GETBYTES,
+ USB_ACM_HIGHSPEED_GET_FRAME,
+ USB_ACM_HIGHSPEED_PUTBYTES_SETUP_DMA,
+ USB_ACM_HIGHSPEED_MOVE_RC_INDEX,
+ USB_ACM_HIGHSPEED_MOVE_R_INDEX,
+ USB_ACM_HIGHSPEED_MOVE_W_INDEX,
+ USB_ACM_HIGHSPEED_RX_IS_EMPTY,
+ USB_ACM_HIGHSPEED_RX_BUF_COUNT,
+ USB_ACM_EP0_PUTBYTES,
+ USB_ACM_EP0_GETBYTES,
+ USB_ACM_EP0_MOVE_RC_INDEX,
+ USB_ACM_EP0_MOVE_R_INDEX,
+ USB_ACM_EP0_MOVE_W_INDEX,
+ USB_ACM_EP0_RX_IS_EMPTY,
+ USB_ACM_EP0_RX_BUF_COUNT,
+#ifdef PICTBRIDGE_SUPPORT
+ USB_DBG_PTP_GET_DEVICE_INFO,
+ USB_DBG_PTP_OPEN_SESSION,
+ USB_DBG_PTP_CLOSE_SESSION,
+ USB_DBG_PTP_GET_STORAGE_IDS,
+ USB_DBG_PTP_GET_STORAGE_INFO,
+ USB_DBG_PTP_GET_NUM_OBJECTS,
+ USB_DBG_PTP_GET_OBJECT_HANDLES,
+ USB_DBG_PTP_GET_OBJECT_INFO,
+ USB_DBG_PTP_GET_OBJECT,
+ USB_DBG_PTP_GET_THUMB,
+ USB_DBG_PTP_GET_PARTIAL_OBJECT,
+ USB_DBG_PTP_SEND_OBJECT_INFO,
+ USB_DBG_PTP_SEND_OBJECT,
+ USB_DBG_DPS_HREQUEST_CONF,
+ USB_DBG_DPS_HREQUEST_CONF_CANCEL,
+ USB_DBG_DPS_HRESPONSE_CONF,
+ USB_DBG_DPS_DREQUEST_REQ,
+ USB_DBG_DPS_2_DREQUEST_REQ_WARNING,
+ USB_DBG_DPS_DRESPONSE_REQ,
+ USB_DBG_DPS_START_JOB_REQ,
+ USB_DBG_DPS_CLOSE_JOB_REQ,
+ USB_DBG_PTP_CLOSE_FS_ERROR,
+#endif
+#ifdef __USB_IMAGE_CLASS__
+ USB_IMAGE_NULL_PKT_TIME_OUT,
+ USB_IMAGE_SEND_RESET_MSG,
+ USB_IMAGE_DEVICE_RESET,
+ USB_IMAGE_CABLE_PLUG_OUT,
+ USB_IMAGE_BUILD_DMA_TX,
+ USB_IMAGE_BUILD_RETURN_DMA_TX,
+ USB_IMAGE_BUILD_DMA_TX_CALLBACK,
+ USB_IMAGE_BUILD_DMA_RX,
+ USB_IMAGE_BUILD_DMA_RX_CALLBACK,
+ USB_IMAGE_SEND_INTERRUPT,
+ USB_IMAGE_SEND_INTERRUPT1,
+ USB_IMAGE_SEND_INTERRUPT2,
+ USB_IMAGE_SEND_INTERRUPT3,
+ USB_IMAGE_INTERRUPT_PKT_FULL,
+ USB_IMAGE_CANCEL_BY_DEVICE1,
+ USB_IMAGE_CANCEL_BY_DEVICE2,
+ USB_IMAGE_CANCEL_BY_DEVICE3,
+ USB_IMAGE_EP0_RESET,
+ USB_IMAGE_EP0_CANCEL,
+ USB_IMAGE_EP0_GET_DEVICE_STATUS,
+ USB_IMAGE_INTERRUPT_HANDLER,
+ USB_IMAGE_SESSION_NOT_OPEN_ERROR,
+ USB_IMAGE_EP0_CANCEL_WITH_WRONG_TRANSACTION_ID,
+#endif
+#ifdef __MTP_ENABLE__
+ USB_MTP_GET_DEVICE_INFO,
+ USB_MTP_OPEN_SESSION,
+ USB_MTP_CLOSE_SESSION,
+ USB_MTP_GET_STORAGE_IDS,
+ USB_MTP_GET_STORAGE_INFO,
+ USB_MTP_GET_NUM_OBJECTS,
+ USB_MTP_GET_OBJECT_HANDLES,
+ USB_MTP_GET_OBJECT_INFO,
+ USB_MTP_GET_OBJECT,
+ USB_MTP_DELETE_OBJECT,
+ USB_MTP_SEND_OBJECT_INFO,
+ USB_MTP_SEND_OBJECT,
+ USB_MTP_GET_DEVICE_PROP_DESC,
+ USB_MTP_GET_DEVICE_PROP_VALUE,
+ USB_MTP_SET_DEVICE_PROP_VALUE,
+ USB_MTP_GET_PARTIAL_OBJECT,
+ USB_MTP_GET_OBJECT_PROPS_SUPPORTED,
+ USB_MTP_GET_OBJECT_PROP_DESC,
+ USB_MTP_GET_OBJECT_PROP_VALUE,
+ USB_MTP_SET_OBJECT_PROP_VALUE,
+ USB_MTP_GET_OBJECT_PROP_LIST,
+ USB_MTP_GET_OBJECT_REFERENCES,
+ USB_MTP_SET_OBJECT_REFERENCES,
+ USB_MTP_SKIP,
+ USB_MTP_OPEN_SESSION_RSP,
+ USB_MTP_CLOSE_SESSION_RSP,
+ USB_MTP_GET_STORAGE_IDS_RSP,
+ USB_MTP_GET_STORAGE_INFO_RSP,
+ USB_MTP_GET_NUM_OBJECTS_RSP,
+ USB_MTP_GET_OBJECT_HANDLES_RSP,
+ USB_MTP_GET_OBJECT_INFO_RSP,
+ USB_MTP_GET_OBJECT_RSP,
+ USB_MTP_DELETE_OBJECT_RSP,
+ USB_MTP_SEND_OBJECT_INFO_RSP,
+ USB_MTP_SEND_OBJECT_RSP,
+ USB_MTP_GET_DEVICE_PROP_DESC_RSP,
+ USB_MTP_GET_DEVICE_PROP_VALUE_RSP,
+ USB_MTP_SET_DEVICE_PROP_VALUE_RSP,
+ USB_MTP_GET_PARTIAL_OBJECT_RSP,
+ USB_MTP_GET_OBJECT_PROPS_SUPPORTED_RSP,
+ USB_MTP_GET_OBJECT_PROP_DESC_RSP,
+ USB_MTP_GET_OBJECT_PROP_VALUE_RSP,
+ USB_MTP_SET_OBJECT_PROP_VALUE_RSP,
+ USB_MTP_GET_OBJECT_REFERENCES_RSP,
+ USB_MTP_SET_OBJECT_REFERENCES_RSP,
+ USB_MTP_SKIP_RSP,
+ USB_MTP_RECEIVE_RSP_MSG,
+ USB_MTP_NO_DATA_HDLR,
+ USB_MTP_TX_DATA_HDLR,
+ USB_MTP_TX_DATA_HDLR_1,
+ USB_MTP_TX_DATA_HDLR_2,
+ USB_MTP_TX_DATA_UNEXPECTED_ZERO_SIZE,
+ USB_MTP_TX_DATA_UNVALID_MSG,
+ USB_MTP_RX_DATA_UNVALID_MSG,
+ USB_MTP_RX_DATA_HDLR_1,
+ USB_MTP_TX_DMA_CALLBACK_HDLR,
+ USB_MTP_RX_DATA_CALLBACK_HDLR,
+ USB_MTP_RESPONSE_MSG_WITH_WRONG_STATE,
+ USB_IMAGE_RELEASE_MTP,
+ USB_IMAGE_PARSE_MTP_MSG,
+ USB_IMAGE_PARSE_MTP_EVENT_MSG,
+ USB_MTP_SEND_ENABLE_REQ_MSG,
+ USB_MTP_SEND_DISABLE_REQ_MSG,
+ USB_MTP_SEND_OP_REQ_MSG,
+ USB_MTP_SEND_ABORT_EVENT_MSG,
+ USB_MTP_IMAGE_OP_HDLR,
+ USB_MTP_HOST_SEND_PACKET_IN_WRONG_STATE,
+ USB_MTP_RECEIVE_ENABLE_RSP,
+ USB_MTP_RECEIVE_DISABLE_RSP,
+#endif
+#ifdef WEBCAM_SUPPORT
+ USB_VIDEO_PROBE_DONE,
+ USB_VIDEO_PROBE_COMMIT_DONE,
+ USB_VIDEO_PROBE_COMMIT_DONE_1,
+ USB_VIDEO_PROBE_COMMIT_DONE_2,
+ USB_VIDEO_PROBE_CONTROL_ERROR,
+ USB_VIDEO_STILL_PROBE_NONE,
+ USB_VIDEO_STILL_PROBE_DONE,
+ USB_VIDEO_STILL_PROBE_COMMIT_DONE,
+ USB_VIDEO_STILL_PROBE_CONTROL_ERROR,
+ USB_VIDEO_GET_VIDEO_BUF_1,
+ USB_VIDEO_GET_VIDEO_BUF_2,
+ USB_VIDEO_COMPLETE_VIDEO_BUF_1,
+ USB_VIDEO_COMPLETE_VIDEO_BUF_2,
+ USB_VIDEO_COMPLETE_VIDEO_BUF_3,
+ USB_VIDEO_COMPLETE_VIDEO_BUF_4,
+ USB_VIDEO_GET_STILL_BUF,
+ USB_VIDEO_COMPLETE_STILL_BUF,
+ USB_VIDEO_DMA_DONE_HDLR_1,
+ USB_VIDEO_DMA_DONE_HDLR_2,
+ USB_VIDEO_DMA_DONE_HDLR_3,
+ USB_VIDEO_STILL_DMA_DONE_HDLR,
+ USB_VIDEO_SEND_VIDEO_1,
+ USB_VIDEO_SEND_VIDEO_2,
+ USB_VIDEO_SEND_INCALL_JPEG,
+ USB_VIDEO_SEND_INCALL_JPEG_DMA_CALLBACK,
+ USB_VIDEO_SEND_INCALL_JPEG_DMA_DONE,
+ USB_VIDEO_SEND_INCALL_JPEG_DMA_DONE_HDLR_1,
+ USB_VIDEO_SEND_INCALL_JPEG_DMA_DONE_HDLR_2,
+ USB_VIDEO_INCALL_TIMEOUT_HDLR,
+ USB_VIDEO_STOP_MSG,
+#endif
+#ifdef __OTG_ENABLE__
+ USB_OTG_HISR,
+ USB_OTG_SET_STATUS,
+ USB_OTG_STATE_START,
+ USB_OTG_STATE_A_IDLE,
+ USB_OTG_STATE_A_WAIT_VRISE,
+ USB_OTG_STATE_A_WAIT_BCON,
+ USB_OTG_STATE_A_HOST,
+ USB_OTG_STATE_A_SUSPEND,
+ USB_OTG_STATE_A_PERIPHERALE,
+ USB_OTG_STATE_A_WAIT_VFALL,
+ USB_OTG_STATE_B_IDLE,
+ USB_OTG_STATE_B_SRP_INIT,
+ USB_OTG_STATE_B_PERIPHERAL,
+ USB_OTG_STATE_B_WAIT_ACON,
+ USB_OTG_STATE_B_HOST,
+ USB_OTG_STATE_FROM_A_IDLE_TO_A_WAIT_BCON,
+ USB_OTG_STATE_FROM_A_PERIPHERAL_TO_A_WAIT_BCON,
+ USB_OTG_STATE_FROM_A_WAIT_BCON_TO_A_HOST,
+ USB_OTG_STATE_FROM_A_HOST_TO_A_WAIT_BCON,
+ USB_OTG_STATE_FROM_A_HOST_TO_A_SUSPEND,
+ USB_OTG_STATE_FROM_A_SUSPEND_TO_A_WAIT_BCON,
+ USB_OTG_STATE_FROM_A_SUSPEND_TO_A_PERIPHERAL,
+ USB_OTG_STATE_FROM_A_SUSPEND_TO_A_HOST,
+ USB_OTG_STATE_FROM_B_IDLE_TO_B_PERIPHERAL,
+ USB_OTG_STATE_FROM_B_PERIPHERAL_TO_B_WAIT_ACON,
+ USB_OTG_STATE_FROM_B_WAIT_ACON_TO_B_HOST,
+ USB_OTG_STATE_FROM_B_WAIT_ACON_TO_B_PERIPHERAL,
+ USB_OTG_STATE_FROM_B_HOST_TO_B_PERIPHERAL,
+ USB_OTG_STATE_FROM_A_WAIT_VFAIL_TO_A_IDLE,
+ USB_OTG_B_DEVICE_PENDING_DOWN_HDLR,
+ USB_OTG_RESET,
+ USB_OTG_SESSREQ,
+ USB_OTG_RESUME,
+ USB_OTG_SOF,
+ USB_OTG_TIMEOUT_HDLR,
+#endif
+#if defined(__OTG_ENABLE__)||defined(__IC_USB_ENABLE__)
+ USB_HCD_UNMASK_HISR,
+ USB_HCD_RESUME,
+ USB_HCD_CONN,
+ USB_HCD_DISCONN,
+ USB_HCD_BABBLE,
+ USB_HCD_DMA_CALLBACK,
+ USB_HCD_DMA_TIMEOUT_ERROR,
+ USB_HCD_EP0_INTR,
+ USB_HCD_EPN_TX_INTR,
+ USB_HCD_EPN_RX_INTR,
+ USB_HCD_SEND_DATA_DONE,
+ USB_HCD_EP0_Setup,
+ USB_HCD_EP0_Data,
+ USB_HCD_EP0_Status,
+ USB_HCD_EP0_CSR0,
+ USBD_EP0_CMD_TAKE_MUTEX,
+ USBD_EP0_CMD_GIVE_MUTEX,
+ USBD_EP0_CMD_SET_EVENT,
+ USBD_EP0_CMD_REC_EVENT,
+ USBD_CH9_CALLBACK_ERROR,
+ USBD_CH9_CALLBACK_START,
+ USBD_CH9_CALLBACK_DELAY_SET_ADDR,
+ USBD_CH9_CALLBACK_TIME_OUT,
+ USBD_CH9_CALLBACK_SET_ADDR,
+ USBD_CH9_CALLBACK_GET_DEV_DESC_8,
+ USBD_CH9_CALLBACK_GET_DEV_DESC,
+ USBD_CH9_CALLBACK_GET_CONF_DESC_9,
+ USBD_CH9_CALLBACK_GET_CONF_DESC,
+ USBD_CH9_CALLBACK_SET_HNP_ENABLE,
+ USBD_CH9_CALLBACK_SET_CONF,
+ USBD_CH9_CALLBACK_SET_CONF_DONE,
+ USBD_HOST_STOP_VBUS,
+ USBD_RESUME,
+ USBD_SUSPEND,
+ USB_HOST_DEFAULT_STARTUP,
+ USB_HOST_MS_ERROR_HLDR,
+ USB_HOST_MS_CHECK_MEDIA,
+ USB_HOST_MS_QUERY_MEDIA,
+ USB_HOST_MS_RESET,
+ USB_HOST_MS_EP0_GET_LUN,
+ USB_HOST_MS_EP0_RESET,
+ USB_HOST_SET_EVENT,
+ USB_HOST_RETRIEVE_EVENT,
+ USB_HOST_MS_REQUEST_SENSE_1,
+ USB_HOST_MS_REQUEST_SENSE_2,
+ USB_HOST_MS_REQUEST_SENSE_3,
+ USB_HOST_MS_INQUIRY_1,
+ USB_HOST_MS_INQUIRY_2,
+ USB_HOST_MS_INQUIRY_3,
+ USB_HOST_MS_READ_FORMAT_CAPACITY_1,
+ USB_HOST_MS_READ_FORMAT_CAPACITY_2,
+ USB_HOST_MS_READ_FORMAT_CAPACITY_3,
+ USB_HOST_MS_READ_CAPACITY_1,
+ USB_HOST_MS_READ_CAPACITY_2,
+ USB_HOST_MS_READ_CAPACITY_3,
+ USB_HOST_MS_READ_CAPACITY_ERROR,
+ USB_HOST_MS_TEST_UNIT_READY_1,
+ USB_HOST_MS_TEST_UNIT_READY_2,
+ USB_HOST_MS_TEST_UNIT_READY_3,
+ USB_HOST_MS_MODE_SENSE6_1,
+ USB_HOST_MS_MODE_SENSE6_2,
+ USB_HOST_MS_MODE_SENSE6_3,
+ USB_HOST_MS_MODE_SENSE6_ALL_1,
+ USB_HOST_MS_MODE_SENSE6_ALL_2,
+ USB_HOST_MS_MODE_SENSE6_ALL_3,
+ USB_HOST_MS_MODE_SENSE10_ALL_1,
+ USB_HOST_MS_MODE_SENSE10_ALL_2,
+ USB_HOST_MS_MODE_SENSE10_ALL_3,
+ USB_HOST_MS_READ_1,
+ USB_HOST_MS_READ_2,
+ USB_HOST_MS_READ_3,
+ USB_HOST_MS_WRITE_1,
+ USB_HOST_MS_WRITE_2,
+ USB_HOST_MS_WRITE_3,
+ USB_HOST_MS_CTRL_EP_HDLR,
+ USB_HOST_MS_BULK_EP_HDLR,
+ USB_HOST_MS_HDLR,
+ USB_HOST_MS_STATE_HDLR,
+ USB_HOST_MS_STATE_HDLR_ERROR1,
+ USB_HOST_MS_STATE_HDLR_ERROR2,
+ USB_HOST_MS_BULK_EP_HDLR_ERROR1,
+ USB_HOST_MS_BULK_EP_HDLR_ERROR2,
+ USB_HOST_MS_CBW_HDLR,
+ USB_HOST_MS_DATA_HDLR,
+ USB_HOST_MS_CSW_HDLR,
+ USB_HOST_MS_START_TIMER,
+ USB_HOST_MS_STATE_MAIN_FALSE,
+ USB_HOST_MS_TIME_OUT,
+ USB_HOST_A_CABLE_PLUG_IN,
+ USB_HOST_A_CABLE_PLUG_OUT,
+ USB_HOST_EXCEPTIONS,
+ USB_HOST_MS_READSECTORS_1,
+ USB_HOST_MS_READSECTORS_2,
+ USB_HOST_MS_READSECTORS_3,
+ USB_HOST_MS_READSECTORS_4,
+ USB_HOST_MS_READSECTORS_5,
+ USB_HOST_MS_READSECTORS_6,
+ USB_HOST_MS_WRITESECTORS_1,
+ USB_HOST_MS_WRITESECTORS_2,
+ USB_HOST_MS_WRITESECTORS_3,
+ USB_HOST_MS_WRITESECTORS_4,
+ USB_HOST_MS_WRITESECTORS_5,
+ USB_HOST_MS_WRITESECTORS_6,
+ USB_HOST_MS_MOUNTDEVICE_1,
+ USB_HOST_MS_MOUNTDEVICE_2,
+ USB_HOST_MS_MOUNTDEVICE_3,
+ USB_HOST_MS_MOUNTDEVICE_4,
+ USB_HOST_MS_MEDIACHANGE_1,
+ USB_HOST_MS_MEDIACHANGE_2,
+ USB_HOST_MS_MEDIACHANGE_3,
+ USB_HOST_MS_MEDIACHANGE_4,
+ USB_HOST_MS_MEDIACHANGE_5,
+ USB_HOST_MS_GETDISKGEOMETRY_1,
+ USB_HOST_MS_GETDISKGEOMETRY_2,
+ USB_HOST_MS_GETDISKGEOMETRY_3,
+ USB_HOST_MS_GETDISKGEOMETRY_4,
+ USB_HOST_MS_GETDISKGEOMETRY_5,
+ USB_HOST_MS_MESSAGEACK_1,
+ USB_HOST_MS_MESSAGEACK_2,
+ USB_HOST_MS_MESSAGEACK_3,
+ USB_HOST_MS_MESSAGEACK_4,
+ USB_HOST_MS_MESSAGEACK_5,
+ USB_HOST_MS_REPORT_MEDIA_STATE,
+ USB_HOST_MS_WRONG_EP_MAXPKT_SIZE,
+ USB_OTG_MASK_HISR,
+ USB_OTG_UNMASK_HISR,
+ USB_OTG_STATE_A_WAIT_BCON_TURN_OFF_VBUS,
+ USB_HCD_CONN_AND_DISCONN,
+ USB_A_CABLE_OUT_BUT_NO_DISCONN,
+ USB_HCD_UNEXPECTED_TX_INTR,
+ USB_HCD_UNEXPECTED_RX_INTR,
+ USB_HCD_UNEXPECTED_EP0_INTR,
+ USB_OTG_MODE_SELECTION,
+#endif
+
+#ifdef __USB_STRESS_TEST__
+ DBG_USB_ECHO_Build_TX,
+ DBG_USB_ECHO_Build_RX,
+ DBG_USB_ECHO_TX_DMA_Callback,
+ DBG_USB_ECHO_RX_DMA_Callback,
+#endif
+ USB_EP_META_INIT,
+ USB_CMD_SetFeature,
+ USB_HCD_NAKTIMEOUT,
+ USB_DBG_MAX
+}USB_DBG_INFO;
+
+
+/***********************************************
+ Implement enum and structure
+************************************************/
+
+typedef struct
+{
+ USB_DBG_INFO tag;
+ kal_uint32 time;
+ kal_uint32 data1;
+ kal_uint32 data2;
+}Usb_Dbg_Data;
+
+
+typedef struct
+{
+ Usb_Dbg_Data dbg_data[USB_DBG_DATA_SIZE];
+ kal_uint16 dbg_data_idx;
+}Usb_Dbg_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern void USB_Dbg_Trace(USB_DBG_INFO tag, kal_uint32 data1, kal_uint32 data2);
+
+
+#endif /* USB_DEBUG_TOOL_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_host_acm_drv.h b/mcu/driver/connectivity/usb_class/include/usb_host_acm_drv.h
new file mode 100644
index 0000000..b371ffa
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_host_acm_drv.h
@@ -0,0 +1,145 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_acm_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host CDC ACM class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_ACM_DRV_H
+#define USB_HOST_ACM_DRV_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usbd.h"
+
+typedef struct
+{
+ /* device level resource */
+ USBH_EP_Struct ep_tx_info;
+ USBH_EP_Struct ep_rx_info;
+ USBH_Common_Struct common_info;
+}USB_Host_Acm_Struct;
+
+
+/************************************************************
+ extern variables and functions
+*************************************************************/
+
+extern USBD_ClassDriver_Struct USB_Host_Acm_Drv;
+extern USB_Host_Acm_Struct g_UsbHostAcm;
+
+
+
+#endif /* USB_HOST_ACM_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_host_default_drv.h b/mcu/driver/connectivity/usb_class/include/usb_host_default_drv.h
new file mode 100644
index 0000000..76483e9
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_host_default_drv.h
@@ -0,0 +1,93 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_default_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host default class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_DEFAULT_DRV_H
+#define USB_HOST_DEFAULT_DRV_H
+
+#include "usbd.h"
+
+
+#if defined(__OTG_ENABLE__)
+extern USBD_ClassDriver_Struct USB_Host_Ext_Default_Drv;
+#endif
+
+#if defined(__IC_USB_ENABLE__)
+extern USBD_ClassDriver_Struct USB_Host_Int_Default_Drv;
+#endif
+
+#endif /* USB_HOST_DEFAULT_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_host_ms_adap.h b/mcu/driver/connectivity/usb_class/include/usb_host_ms_adap.h
new file mode 100644
index 0000000..588a217
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_host_ms_adap.h
@@ -0,0 +1,95 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_ms_adap.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host mass storage adaptaion layer definitaions (file system API)
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_MS_ADAP_H
+#define USB_HOST_MS_ADAP_H
+
+#include "fs_type.h"
+
+
+/* Read and write command sector size limitation, 64KB */
+#define USB_HOST_MS_RW_MAX_SEC_LEN 128
+
+
+/* Read and write command sector size limitation when data source is in D-cacheable region */
+#define USB_HOST_MS_RW_MAX_DCACHE_SEC_LEN 8
+
+
+/* OTG drive */
+extern FS_Driver FS_OTGDrv;
+
+#endif /* USB_HOST_MS_ADAP_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_host_ms_drv.h b/mcu/driver/connectivity/usb_class/include/usb_host_ms_drv.h
new file mode 100644
index 0000000..bdf9ff3
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_host_ms_drv.h
@@ -0,0 +1,424 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_ms_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host mass storage class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_MS_DRV_H
+#define USB_HOST_MS_DRV_H
+
+#include "usbms_drv.h"
+//#include "kal_non_specific_general_types.h"
+//#include "kal_release.h"
+#include "usbd.h"
+/************************************************************
+ MS class parameter definition
+*************************************************************/
+
+/* string size in INQUERY data format */
+#define USBMS_INQUIRY_VENDOR_INFO_LEN 8
+#define USBMS_INQUIRY_PRODUCT_IDEN_LEN 16
+#define USBMS_INQUIRY_PRODUCT_REV_LEN 4
+
+/* command and adta length for each ms command */
+#define USBMS_INQUIRY_CMD_LEN 6
+#define USBMS_INQUIRY_DATA_LEN 36
+#define USBMS_READ_FORMATCAPACITY_CMD_LEN 10
+#define USBMS_READ_FORMATCAPACITY_DATA_LEN 12
+#define USBMS_READ_CAPACITY_CMD_LEN 10
+#define USBMS_READ_CAPACITY_DATA_LEN 8
+#define USBMS_MODE_SENSE6_CMD_LEN 6
+#define USBMS_MODE_SENSE6_DATA_LEN 4
+#define USBMS_MODE_SENSE_CMD_LEN 10
+#define USBMS_MODE_SENSE_DATA_LEN 4
+#define USBMS_REQUESTSENSE_CMD_LEN 12
+#define USBMS_REQUESTSENSE_DATA_LEN 18
+#define USBMS_TEST_UNIT_READY_CMD_LEN 6
+#define USBMS_TEST_UNIT_READY_DATA_LEN 0
+#define USBMS_READ_CMD_LEN 10
+#define USBMS_WRITE_CMD_LEN 10
+
+#define USBMS_CBW_LENGTH 31
+#define USBMS_CSW_LENGTH 13
+#define USBMS_CBWCB_LENGTH 16
+
+/************************************************************
+ Implementation definition
+*************************************************************/
+/* State machine polling periord*/
+#define USB_HOST_MS_QUERY_PERIOD 40 /* 10ms unit */
+
+/* Maxumum buffer size for CBW command and DATA except READ and WRITE command */
+#define USBMS_MAX_CMD_LEN 16
+#define USBMS_MAX_DATA_LEN 64
+
+/* Event flag. (CBW, DATA, CSW) is handled in HISR level
+ This event is used when state complete to retrive waiting task*/
+#define EVENT_USB_MS_DONE ((kal_uint32)0x00000001)
+#define EVENT_USB_MS_DETATCH ((kal_uint32)0x00000002)
+
+/* This is constraint by both secotr size and device DMA length */
+/* DMA length can not exceed 0xffff=>65535 */
+#define USBMS_MAX_DATA_LENGTH (32*1024)
+
+
+// USB Host Max Support Number = ICUSB + OTG
+#define USB_MAX_MS_NUM 1 //
+
+
+/* Bulk endpoint state*/
+typedef enum
+{
+ USB_HOST_MS_NONE,
+ USB_HOST_MS_CBW,
+ USB_HOST_MS_DATA,
+ USB_HOST_MS_CSW,
+ USB_HOST_MS_CBW_CLEAR_STALL,
+ USB_HOST_MS_DATA_CLEAR_STALL,
+ USB_HOST_MS_CSW_CLEAR_STALL
+}USB_HOST_MS_STATE;
+
+/* DATA stage direction */
+typedef enum
+{
+ USB_HOST_MS_DATA_NONE, /* no data phase is needed */
+ USB_HOST_MS_DATA_RECV,
+ USB_HOST_MS_DATA_SEND
+}USB_HOST_MS_DATA_DIR;
+
+/* Result of the CBW, DATA, CSW state */
+typedef enum
+{
+ USB_HOST_MS_RESULT_OK,
+ USB_HOST_MS_RESULT_CSW_FAIL,
+ USB_HOST_MS_RESULT_TIMEOUT,
+ USB_HOST_MS_RESULT_NO_RESPONSE,
+ USB_HOST_MS_RESULT_STALL,
+ USB_HOST_MS_RESULT_FORMAT_ERROR
+}USB_HOST_MS_RESULT;
+
+/* Ctrl EP commands that may used after MS class driver is started
+ Note that it contains both standard and class specific request */
+typedef enum
+{
+ USB_HOST_MS_EP0_CMD_NONE,
+ USB_HOST_MS_EP0_CMD_RESET,
+ USB_HOST_MS_EP0_CMD_GET_LUN,
+ USB_HOST_MS_EP0_CMD_CLEAR_STALL_IN,
+ USB_HOST_MS_EP0_CMD_CLEAR_STALL_OUT
+}USB_HOST_MS_EP0_CMD;
+
+
+/* The MS device status */
+typedef enum
+{
+ USB_HOST_MS_DEV_STATE_READY,
+ USB_HOST_MS_DEV_STATE_ERROR,
+ USB_HOST_MS_DEV_STATE_FATAL_ERROR
+}USB_HOST_MS_DEV_STATE;
+
+/* The media state for each LUN */
+typedef enum
+{
+ USB_HOST_MS_MEDIA_STATE_ABSENT,
+ USB_HOST_MS_MEDIA_STATE_READY,
+ USB_HOST_MS_MEDIA_STATE_WR_PROTECT,
+ USB_HOST_MS_MEDIA_STATE_CHANGED,
+ USB_HOST_MS_MEDIA_STATE_ERROR
+}USB_HOST_MS_MEDIA_STATE;
+
+typedef enum
+{
+ USB_HOST_MS_MSG_MEDIA_CHANGE,
+ USB_HOST_MS_MSG_PLUG_IN,
+ USB_HOST_MS_MSG_PLUG_OUT
+}USB_HOST_MS_MSG_TYPE;
+
+
+/************************************************************
+ Implementation structures
+*************************************************************/
+
+/* CBW and DATA related parameters */
+typedef struct
+{
+ kal_uint8 lun;
+ kal_uint32 cmd_len;
+ kal_uint8 *cmd_buff;
+ kal_uint32 data_len;
+ kal_uint8 *data_buff;
+ USB_HOST_MS_DATA_DIR data_dir;
+}USBH_Ms_Cmd_Struct;
+
+/* Media information for each LUN */
+typedef struct
+{
+ kal_uint32 sec_size;
+ kal_uint32 sec_num;
+ USB_HOST_MS_MEDIA_STATE state;
+ USB_HOST_MS_MEDIA_STATE pre_state;
+
+ kal_uint8 vendor_info[USBMS_INQUIRY_VENDOR_INFO_LEN];
+ kal_uint8 product_iden[USBMS_INQUIRY_PRODUCT_IDEN_LEN];
+ kal_uint8 product_rev[USBMS_INQUIRY_PRODUCT_REV_LEN];
+}USBH_Ms_Media_Struct;
+
+
+
+typedef struct
+{
+ /* device level resource */
+ USBH_EP_Struct ep_tx_info;
+ USBH_EP_Struct ep_rx_info;
+ USBH_Common_Struct common_info;
+
+ kal_eventgrpid event_id; /* event used for (CBW, DATA, CSW) state machine to retrive waiting task */
+ kal_mutexid mutex_id; /* mutex used to protect ms command. When USB task is polling state machine, read/write action from application task should be protected */
+ kal_uint32 gpt_handle; /* gpt handle to query device status */
+ kal_uint32 sleep_timer_handle; /* use timer to check whether App need to use Device or not */
+ kal_uint16 sleep_time;
+
+ /* CBW, DATA CSW state information*/
+ kal_uint32 CBWdata[32/4]; /* CBW data */
+ UsbMs_CSW CSW; /* CSW data*/
+ kal_uint8* data; /* DATA stage buffer address*/
+ kal_uint32 data_length; /* DATA stage size */
+ USB_HOST_MS_DATA_DIR data_dir; /* DATA stage direction */
+ /* DATA stage parameters. If data length application request is larger than DMA can support,
+ CBW, DATA, CSW state machine should divide it to multiple request */
+ kal_uint32 remain_data_length;
+ kal_uint32 sending_data_length;
+ kal_uint32 sent_data_length;
+ USBH_Ms_Cmd_Struct ms_cmd_data; /* Used to store all CBW, DATA related information */
+ USB_HOST_MS_STATE ms_state; /* State in the state machine of CBW, DATA, CSW */
+ USB_HOST_MS_RESULT result; /* CBW, DATA, CSW state result */
+ kal_bool b_rw_result; /* read/write result for READ and WRITE action */
+
+ /* EP0 information*/
+ USB_HOST_MS_EP0_CMD ms_cmd; /* Current EP0 command */
+
+ kal_uint8 *buffer_address; // transfer data if using cacheable buffer
+
+ /* media information */
+ kal_uint8 total_lun; /* total lun number in the attached device */
+// kal_uint8 support_lun; /* supported lun defined in custom */
+ USBH_Ms_Media_Struct *media_info; /* media information for each LUN*/
+ kal_uint8 *media_handle; /* media handle communicated with file system */
+ kal_uint32 *media_msg_array; /* message array communicated with FMT */
+ kal_uint32 media_state_change; /* keep information about whether each lun state is changed or not */
+
+ /* device information*/
+ USB_HOST_MS_DEV_STATE dev_state; /* device status*/
+ kal_bool dev_attatch;
+ kal_uint8 dev_error_count; /* device error count */
+ kal_bool b_sending_change_ilm; /* Check it can send message to indicate FMT*/
+ kal_bool b_sending_plugout_ilm;
+
+ USB_EP_DIRECTION stall_ep_dir;
+
+
+#ifdef __USB_OTG_RX_TEST__
+ kal_bool host_ms_rx_test_flag;
+#endif
+
+#ifdef __USB_OTG_TX_TEST__
+ kal_bool host_ms_tx_test_flag;
+#endif
+// kal_bool b_sending_disconn_ilm;
+}USB_Host_Ms_Struct;
+
+
+/************************************************************
+ extern variables and functions
+*************************************************************/
+
+ extern USBD_ClassDriver_Struct USB_Host_Ms_Drv;
+extern USB_Host_Ms_Struct g_UsbHostMs[USB_MAX_MS_NUM];
+
+extern kal_uint8 USB_MS_Check_index(kal_uint8 usb_ip_port);
+extern void USB_Host_Ms_Sleep_Timeout(void *parameter);
+extern kal_uint8 USB_MS_IP_Query(kal_uint8 lun);
+extern void USB_Host_Ms_SendInd(kal_uint8 ms_index,USB_HOST_MS_MSG_TYPE msg);
+extern void USB_Host_Ms_Get_Media_Resource(kal_uint8 ms_index);
+extern void USB_Host_Ms_Free_Media_Resource(kal_uint8 ms_index);
+extern void USB_Host_Ms_En_Device(USBH_Common_Struct common_str);
+extern void USB_Host_Ms_Check_Media_State(kal_uint8 ms_index);
+extern void USB_Host_Ms_Get_LUN(kal_uint8 ms_index);
+extern void USB_Host_Ms_Reset(kal_uint8 ms_index);
+extern void USB_Host_Ms_Clear_Stall(kal_uint8 ms_index);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Request_Sense(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Inquiry(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Read_Format_Capacity(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Read_Capacity(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Test_Unit_Ready(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Mode_Sense6(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Mode_Sense6_All_Mode(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Mode_Sense10_All_Mode(kal_uint8 lun);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Read(kal_uint8 lun, kal_uint32 sec_start, kal_uint16 sec_num, kal_uint8* data);
+extern USB_HOST_MS_RESULT USB_Host_Ms_Write(kal_uint8 lun, kal_uint32 sec_start, kal_uint16 sec_num, kal_uint8* data);
+
+#endif /* USB_HOST_MS_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_host_ms_state.h b/mcu/driver/connectivity/usb_class/include/usb_host_ms_state.h
new file mode 100644
index 0000000..3d7a8e8
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_host_ms_state.h
@@ -0,0 +1,82 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_host_ms_state.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for host mass storage class state machine definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_HOST_MS_STATE_H
+#define USB_HOST_MS_STATE_H
+
+
+extern void USB_Host_Ms_State_Start(kal_uint8 usb_ip_port);
+extern void USB_Host_Ms_State_Main(kal_uint8 usb_ip_port);
+
+
+#endif /* USB_HOST_MS_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_mode.h b/mcu/driver/connectivity/usb_class/include/usb_mode.h
new file mode 100644
index 0000000..4fe6fec
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_mode.h
@@ -0,0 +1,341 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_mode.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb mode selection definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_MODE_H
+#define USB_MODE_H
+
+
+#include "usb_comm.h"
+#include "usb.h"
+#ifdef __OTG_ENABLE__
+#include "otg.h"
+#endif
+#include "kal_general_types.h"
+
+#define USB_MAX_COMPOSITE_DEVICES 10
+
+typedef enum
+{
+ USB_MODE_NONE = 0,
+ USB_MODE_NVRAM_READ_DONE,
+ USB_MODE_BMT_READ_DONE,
+ USB_MODE_FT_START_DONE
+}USB_MODE_PRARM;
+
+typedef enum
+{
+ USBDL_MODE_NONE = 0,
+ USBDL_MODE_USB_DOWNLOAD,
+ USBDL_MODE_FAST_META
+}USBDL_MODE_PRARM;
+
+
+typedef enum
+{
+ USB_MODE_CABLE_PLUGOUT,
+ USB_MODE_CABLE_A_PLUGIN,
+ USB_MODE_CABLE_B_PLUGIN,
+ USB_MODE_CABLE_ERROR,
+ USB_MODE_CABLE_UNSUPPORT
+}USB_MODE_CABLE_TYPE;
+
+
+typedef struct
+{
+ USB_Comport_Boot_Status usb_comport_boot; /* a flag to check if usb boot as com port */
+ USB_Comport_OS_Driver_Status usb_comport_driver; /* a flag to check OS version for usb comport usage */
+ kal_uint8 mode_param;
+ kal_uint8 com_port_num;
+ USB_MODE_CABLE_TYPE cable_type;
+ USB_MODE_CABLE_TYPE previous_cable_type;
+#if defined(__USB_MASS_STORAGE_ENABLE__)||defined(__MTP_ENABLE__)
+ kal_bool b_ms_first_plugin; /*whether it is first plug in or not in ms mode */
+ kal_bool b_usb_boot_with_ms;
+#endif
+#ifdef __OTG_ENABLE__
+ kal_bool b_start_srp; /* set in OTG_Start_SRP */
+ kal_bool b_start_hnp; /* Check if start HNP */
+ kal_bool b_usb_pdnmode; /* Check if phy power down or not */
+#endif
+#ifdef __IC_USB_ENABLE__
+ kal_bool b_int_usb_detect; // ICUSB enter Host mode
+#endif
+#if defined(__DM_LAWMO_SUPPORT__)
+ kal_bool b_lock_usb_boot;
+#endif
+ kal_bool usb_config_result; /* configure may be fail */
+ kal_bool usb_boot; /* is in usb boot mode */
+ kal_bool usb_menu_en; // pop up menu or not
+ kal_bool usb_cdrom_en;//config as cd rom or not
+}Usb_Mode_Struct;
+
+
+extern Usb_Mode_Struct g_UsbMode;
+
+extern void USB_Init_Mode(void);
+#ifdef __OTG_ENABLE__
+extern void OTG_Mode_Selection(void);
+#else
+extern void USB_Mode_Selection(void);
+#endif
+
+extern void USB_Config_Type(USB_DEVICE_TYPE type, kal_bool b_enable, kal_uint32 *parameter);
+extern void USB_Release_Type(kal_bool b_enable, kal_bool b_plugout);
+extern void USB_Init_Normal_Mode_Ms(void);
+extern kal_bool USB_Check_Composite_With_COM(USB_DEVICE_TYPE type);
+
+//extern void USB_Init_Normal_Mode_Ms(kal_uint32* mem_addr);
+extern void USB_End_Normal_Mode_Ms(void);
+
+#ifdef __OTG_ENABLE__
+extern void OTG_Hdlr_Select(OTG_HDLR_TASK_TYPE type, kal_uint32 *parameter);
+#endif
+
+extern void USB_Init_Ms(kal_bool bFirst);
+extern void USB_Init_ACM_In_Meta(void);
+extern void USB_Init_ACM_In_AT_Mode(void);
+
+extern USBDL_MODE_PRARM USBDL_Mode_Type(void);
+extern kal_bool USB_Exception_Check(void);
+
+
+extern kal_bool USB_Boot_With_MS(void);
+#ifdef __MTP_ENABLE__
+extern void USB_Init_MTP(kal_bool bFirst);
+#endif
+
+extern void USB_Mode_Switch(USB_DEVICE_TYPE type);
+extern void USB_Composite_Device_Table_Reset(void);
+extern void USB_Composite_Device_Table_Register(USB_COMPOSITE_DEVICE_TYPE type);
+
+#endif //USB_MODE_H
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_resource.h b/mcu/driver/connectivity/usb_class/include/usb_resource.h
new file mode 100644
index 0000000..f457ee2
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_resource.h
@@ -0,0 +1,190 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_resource.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb resource management definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_RESOURCE_H
+#define USB_RESOURCE_H
+
+
+#include "usb.h"
+#include "drv_comm.h"
+#include "kal_general_types.h"
+
+/***********************************************
+ implement enum and structure
+************************************************/
+
+/* interface create infomration structrue, use this information to create interface */
+typedef struct
+{
+ kal_char *if_name_ptr;
+ usb_create_if_func_ptr if_create_func;
+ usb_void_func if_init_func;
+ usb_void_func if_enable_func;
+ usb_void_func if_resume_func;
+} Usb_IfCreate_Info;
+
+
+typedef struct
+{
+ kal_uint8 device_code; /*device class*/
+ kal_uint8 subclass_code;
+ kal_uint8 protocol_code;
+ kal_uint16 product_code;
+ kal_bool b_registerd;
+} Usb_Device_Code;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+
+extern void USB_Software_Create(void);
+extern void USB_Software_Speed_Init(kal_bool b_other_speed);
+extern void USB_Software_Init(void);
+extern void USB_Software_Resume(void);
+extern void USB_Software_Enable(void);
+
+
+
+#endif /* USB_RESOURCE_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_task.h b/mcu/driver/connectivity/usb_class/include/usb_task.h
new file mode 100644
index 0000000..4b14da2
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_task.h
@@ -0,0 +1,180 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_task.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb task definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_TASK_H
+#define USB_TASK_H
+
+#include "syscomp_config.h"
+#include "usb_comm.h"
+#include "kal_general_types.h"
+
+
+
+/* cable status, plugin/plugout */
+typedef enum
+{
+ USB_CABLE_PLUGOUT,
+ USB_CABLE_PLUGIN
+} USB_CABLE_STATUS;
+
+/* messages sent to other tasks */
+typedef enum
+{
+#ifdef __P_PROPRIETARY_COPYRIGHT__
+ USB_SEND_MSG_MS_INIT_DONE,
+#endif
+
+ USB_SEND_BMT_START_CHARGE,
+ USB_SEND_BMT_STOP_CHARGE,
+ USB_SEND_BMT_CHARGE_MIN,
+ USB_SEND_BMT_CHARGE_MAX,
+ USB_SEND_MSG_PLUG_IN,
+ USB_SEND_MSG_PLUG_OUT,
+ USB_SEND_MSG_READ_UNIQUE_STRING,
+ USB_SEND_MSG_USB_SUSPEND
+}USB_SEND_MSG_TYPE;
+
+
+extern kal_bool usb_create(comptask_handler_struct **handle);
+extern void USB_Send_Msg(USB_SEND_MSG_TYPE usb_msg_type);
+extern void USB_Send_Config_Cnf_Msg(USB_DEVICE_TYPE mode, kal_bool result);
+extern void USB_Get_Serial_Value(void);
+
+#endif //USB_TASK_H
+
diff --git a/mcu/driver/connectivity/usb_class/include/usb_trc.h b/mcu/driver/connectivity/usb_class/include/usb_trc.h
new file mode 100644
index 0000000..6be891f
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usb_trc.h
@@ -0,0 +1,624 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usb_trc.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file defines the index trace of USB module
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef _USB_TRC_H
+#define _USB_TRC_H
+
+#include "kal_trace.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+
+#ifdef __TST_MODULE__
+ #ifndef GEN_FOR_PC
+ #ifndef _STACK_CONFIG_H
+ #error "stack_config.h should be included before tst_config.h"
+ #endif
+ #endif /* GEN_FOR_PC */
+
+ #ifndef _KAL_TRACE_H
+ #error "kal_trace.h should be included before tst_trace.h"
+ #endif
+
+#if !defined(GEN_FOR_PC)
+#if defined(__TST_MODULE__) || defined(__CUSTOM_RELEASE__)
+ #include "usb_trc_gen.h"
+#endif /* TST Trace Defintion */
+#endif
+ BEGIN_TRACE_MAP(MOD_UART1_HISR)
+
+ TRC_MSG(USB_RESET_TIMES, "USB reset %d times")
+ TRC_MSG(USB_IS_SUSPEND, "USB is suspend")
+ TRC_MSG(USB_IS_RESUME, "USB is resume")
+ TRC_MSG(USB_IS_DISCONN, "USB is disconnect")
+ TRC_MSG(USB_IS_CONFIGURE, "USB is configured")
+ TRC_MSG(USB_CONFIG_NUM, "USB configure number is %d , USB support current table index is %d")
+ TRC_MSG(USB_CURRENT_TABLE, "USB support current is %x")
+ TRC_MSG(USB_EP0_SetFeature, "USB cmd clear/set Feature")
+ TRC_MSG(USB_EP0_Clear_Stall,"USB Clear EndPoint")
+ TRC_MSG(USB_EP0_SET_ADDR,"USB Set Address")
+ TRC_MSG(USB_EP0_GET_DESCRIPT,"USB Get Descriptor")
+ TRC_MSG(USB_EP0_SET_CONFIG,"USB Set Configuration")
+ TRC_MSG(USB_EP0_GET_CONFIG,"USB Get Configuration")
+ TRC_MSG(USB_EP0_SET_INTER,"USB Set Interface")
+ TRC_MSG(USB_EP0_GET_INTER,"USB Get Interface")
+ TRC_MSG(USB_EP0_GET_STAT,"USB Get Status")
+ TRC_MSG(USB_EP0_UNSUPPORT,"USB ep0 un-expected Command")
+ TRC_MSG(USB_PLUG_OUT, "USB is plugged out")
+ TRC_MSG(USB_GET_MEMORY_ADDR, "USB memory left: %x , Memory length : %d")
+ TRC_MSG(USB_HISR_State, "USB interrupt state %x ,USB mode %x , Line_State %x , OP_State %x")
+ TRC_MSG(USB_EP_UNEXPECTED_TX_HISR, "USB TX ep %d have a unexpected interrupt with TXCSR %d")
+ TRC_MSG(USB_EP_UNEXPECTED_RX_HISR, "USB RX ep %d have a unexpected interrupt with RXCSR %d")
+ TRC_MSG(USB_DRV_IS_ERROR_1, "HW ERROR: error status is %d, fast mode status is %d")
+ TRC_MSG(USB_DRV_IS_ERROR_2, "HW ERROR in host mode")
+ TRC_MSG(USB_DRV_IS_ERROR_3, "HW ERROR D+ down")
+ TRC_MSG(USB_Register, "USB Register Address: 0x%x , Value: 0x%x ")
+ TRC_MSG(USB_DRV_RX_ERROR, "USB received a RX endpoint intr no %d with status %x")
+ TRC_MSG(USBACM_DMA_Setup, "USB DMA Setup %d bytes by USB port %d")
+ TRC_MSG(USBACM_DMA_Running, "USB DMA Running on endpoint %d by USB port %d")
+ TRC_MSG(USB_RESET_Data_Toggle, "USB DMA Running just before Clear Feature on endpoint %d")
+ TRC_MSG(USB_HW_State, "USB OP state %x Line state %x")
+ TRC_MSG(USB_TX_DEBUG, "USB TXCSR %x DMA State %x")
+ TRC_MSG(USB_RX_DEBUG, "USB RXCSR %x DMA State %x")
+ TRC_MSG(USB_DMA_DEBUG, "USB DMA Count %d Real Count %d")
+ TRC_MSG(USB_REMOTE_WAKEUP, "USB REMOTE WAKEUP %d")
+ TRC_MSG(USB_DMA_HW_Intr,"USB DMA Interrupt %d")
+ TRC_MSG(USBACM_DMA_CALLBACK, "USB DMA TX callback %d bytes by USB port %d")
+ TRC_MSG(USBACM_DMA_Setup2, "USB DMA Setup Again by USB port %d")
+ TRC_MSG(USBACM_DMA_Setup0, "DMA with no Data and doesn't setup by USB port %d")
+ TRC_MSG(USB_UTMI_SIGNAL, "UTMI Signal 61A = %x 61B = %x 61C = %x 61D = %x")
+ TRC_MSG(USB_TXCSR_SET2, "USB TXCSR Setup with USB_TXCSR_TXPKTRDY already set")
+ TRC_MSG(USB_TXCSR_SET, "USB DMA Callback and set TXCSR for short packet")
+ TRC_MSG(USBACM_CTRL_DCD, "USB COMPORT: Ctrl DCD to USB port %d")
+ TRC_MSG(USBACM_CTRL_BREAK, "USB COMPORT: Ctrl Break to USB port %d")
+ TRC_MSG(USBACM_SET_BAUDRATE, "USB COMPORT: Set BaudRate to USB port %d")
+ TRC_MSG(USBACM_SET_AUTO_BAUDRATE, "USB COMPORT: Set AutoBaud Div to USB port %d")
+ TRC_MSG(USBACM_CTRL_RI, "USB COMPORT: Ctrl RI to USB port %d")
+ TRC_MSG(USBACM_CTRL_DTR, "USB COMPORT: Ctrl DTR to USB port %d")
+ TRC_MSG(USBACM_THRESHOLD_ON, "Set threshold is ON to USB port %d")
+ TRC_MSG(USBACM_THRESHOLD_OFF, "Set threshold is OFF to USB port %d")
+ TRC_MSG(USBACM_PC_SENT, "PC sent %d bytes to USB port %d")
+ TRC_MSG(USBACM_RESET_READY_TO_READ_FLAG, "reset ready to read flag by USB port %d")
+ TRC_MSG(USBACM_INIT_READY_TO_READ_FLAG, "initialize ready to read flag by USB port %d")
+ TRC_MSG(USBACM_OPEN_READY_TO_READ_FLAG, "open by %d owner reset ready to read flag by USB port %d")
+ TRC_MSG(USBACM_CLEAR_RX_BUF_READY_TO_READ_FLAG, "Clear RX buf by %d owner reset ready to read flag to USB port %d")
+ TRC_MSG(USBACM_CLEAR_TX_BUF_READY_TO_READ_FLAG, "Clear TX buf by %d owner reset ready to read flag to USB port %d")
+ TRC_MSG(USBACM_INTR, "ACM intr pipe sent %d bytes by USB port %d")
+ TRC_MSG(USBACM_CLEAR_TX_ISR_BUF, "Clear TX ISR buffer to USB port %d")
+ TRC_MSG(USBACM_OPEN, "USB ACM UART OPEN to USB port %d")
+ TRC_MSG(USBACM_CLOSE, "USB ACM UART close by %d owner to USB port %d")
+ TRC_MSG(USBACM_SET_OWNER, "USB ACM set %d owner to USB port %d")
+// TRC_MSG(USBACM_SEND_ISR_DATA, "USB ACM send ISR data %d bytes by USB port %d")
+// TRC_MSG(USBACM_PUT_ISR_BYTES, "USB ACM put ISR bytes %d bytes by USB port %d")
+ TRC_MSG(USBACM_PUT_BYTES, "USB ACM put bytes %d bytes to USB port %d")
+ TRC_MSG(USBACM_PUT_BYTES_FAIL, "USB ACM put bytes fail due to USB wrong state")
+ TRC_MSG(USBACM_PUT_BYTES_BUF_FULL, "USB ACM buffer is full because put bytes by %d owner to USB port %d")
+ TRC_MSG(USBACM_CLEAR_RX_BUF, "USB ACM clear RX buffer by USB port %d")
+ TRC_MSG(USBACM_GET_BYTES_BUF_EMPTY, "USB ACM buffer is empty because get bytes by %d owner to USB port %d")
+ TRC_MSG(USBACM_FAIL_NOT_UNMASK, "USB ACM not unmask because USB fail by USB port %d")
+ TRC_MSG(USBACM_GET_BYTES, "USB ACM get bytes %d bytes to USB port %d")
+ TRC_MSG(USBACM_CLEAR_TX_BUF, "USB ACM clear TX buffer to USB port %d")
+ TRC_MSG(USBACM_CLEAR_RDY_W, "USB ACM clear readt to write flag by %d owner to USB port %d")
+ TRC_MSG(USBACM_EP0_COMMAND, "USB ACM EP0 Command %d by USB port %d")
+// TRC_MSG(USBACM_TX_CLEAR_UNDERRUN, "USB Clear TX UnderRun by USB port %d")
+ TRC_MSG(USBACM_SET_DMA_LIMITER, "%d owner set DMA Limiter as %d to USB port %d")
+ TRC_MSG(USBACM_CLEAR_DMA_LIMITER, "%d owner Clear DMA Limiter to USB port %d")
+ TRC_MSG(USBIMAGE_GET, "Printer send %d bytes")
+ TRC_MSG(USBIMAGE_ERROR_CMDS, "PTP receive an error command %d")
+ TRC_MSG(USBMS_RX_WRONG_CBW_LENGTH, "USB MS receive a wrong length (%d) CBW cmd packet")
+ TRC_MSG(USBMS_RESET,"USB MS Receive Reset")
+ TRC_MSG(USBMS_ERROR_CMD, "USB MS %d error cmd")
+ TRC_MSG(USBMS_LOCKFAT_FAIL, "USB MS lock FAT fail")
+ TRC_MSG(USBVIDEO_INIT, "USB video is init")
+ TRC_MSG(USBVIDEO_RELEASE, "USB video is released")
+ TRC_MSG(USBVIDEO_VC_ERROR_CMD, "USB video VC %d error cmd")
+ TRC_MSG(USBVIDEO_VS_ERROR_CMD, "USB video VS %d error cmd")
+ TRC_MSG(USBVIDEO_STILL_PROBE_NONE, "USB video reset still commit index because video commit doen")
+ TRC_MSG(USBVIDEO_SET_COMMIT_VIDEO_STATE, " USB video Set commit video state %d")
+ TRC_MSG(USBVIDEO_SET_PROB_CONTROL_ERROR, "USB video Set Probe control command received %d, and total length is %d > 26")
+ TRC_MSG(USBVIDEO_STILL_COMMIT_DONE, "USB video still commit %d index")
+ TRC_MSG(USBVIDEO_SET_STILL_PROB_CONTROL_ERROR, "USB video Set Still Probe control command received %d, and total length is %d > 11")
+ TRC_MSG(USBVIDEO_GET_BUFFER, "USB video get video buffer buff r %d, w%d, f %d ")
+ TRC_MSG(USBVIDEO_COMPLETE_BUFFER, "USB video complete video buffer buff r %d, w%d, f %d ")
+ TRC_MSG(USBVIDEO_DMA_DONE, "USB video DMA done buff r %d, w%d, f %d ")
+ TRC_MSG(USBVIDEO_STILL_ERROR, "WARNING: state is still but commit is 0")
+ TRC_MSG(USB_HCD_BABBLE_INTR, "USB hcd detect babble")
+ TRC_MSG(USB_HCD_CONN_INTR, "USB hcd detect connection")
+ TRC_MSG(USB_HCD_DISCONN_INTR, "USB hcd detect disconnection")
+ TRC_MSG(USB_HCD_CONN_AND_DISCONN_INTR, "USB hcd detect connection and disconnection at the same time")
+ TRC_MSG(USB_HCD_TX_EPN_TIMEOUT, "USB hcd TX ep %d time out")
+ TRC_MSG(USB_HCD_RX_EPN_TIMEOUT, "USB hcd RX ep %d time out")
+ TRC_MSG(USB_HCD_TX_EPN_ERROR, "USB hcd TX ep %d error")
+ TRC_MSG(USB_HCD_RX_EPN_ERROR, "USB hcd RX ep %d error")
+ TRC_MSG(USB_HCD_TX_EPN_STALL, "USB hcd TX ep %d stall")
+ TRC_MSG(USB_HCD_RX_EPN_STALL, "USB hcd RX ep %d stall")
+ TRC_MSG(USB_HCD_RX_EPN_PID_ERROR, "USB hcd RX ep %d PID error")
+ TRC_MSG(USB_HCD_EP0,"USB hcd ep0 data length,already received %d, required length %d")
+ TRC_MSG(USB_HCD_EP0_RX,"USB hcd ep0 rx data done,already received %d, required length %d, max packet %d")
+ TRC_MSG(USB_HCD_RX_DMA_TIMEOUT, "USB hcd RX DMA is timeout")
+ TRC_MSG(USB_HCD_TEST_UN_SUPPORT, "USB hcd test for un-support device.")
+ TRC_MSG(USB_HCD_RESPONSE_ERROR, "USB hcd get stall from device and doesn't support HNP")
+ TRC_MSG(USB_HCD_ENUM_FAIL, "USB hcd enumeration fail")
+ TRC_MSG(USB_HCD_COMMAND_FAIL, "USB hcd get response length error")
+ TRC_MSG(USB_HCD_UN_SUPPORT, "USB hcd dones't support the class driver")
+ TRC_MSG(USB_OTG_SESSION_REQUEST, "USB A device detects B device issue session request, and USB interrupt state %x ,USB mode %x , Line_State %x , OP_State %x")
+ TRC_MSG(USB_OTG_VBUS_FALL_DOWN, "USB B device drag too much current than expected.A device going to trun off Vbus")
+ TRC_MSG(USB_OTG_DMA_STATUS, "OTG DMA Status Real Count: %d Count: %d host channel: %d device channel: %d")
+ TRC_MSG(USB_HOST_MS_STATE_START_FAIL, "USB host ms state start fail")
+ TRC_MSG(USB_HOST_MS_STATE_MAIN_FAIL, "USB host ms state main fail")
+ TRC_MSG(USB_HOST_MS_REQUEST_SENSE_OK, "USB lun %d sense ok")
+ TRC_MSG(USB_HOST_MS_REQUEST_SENSE_MEDIA_CHANGE, "USB lun %d sense media change")
+ TRC_MSG(USB_HOST_MS_REQUEST_SENSE_ABSENT, "USB lun %d sense absent")
+ TRC_MSG(USB_HOST_MS_REQUEST_SENSE_ERROR, "USB lun %d sense error")
+ TRC_MSG(USB_HOST_MS_READ_CAPACITY_FAIL, "USB lun %d read capacity is fail because its sector number is %d and sector size is %d")
+ TRC_MSG(USB_HOST_MS_READ_CAPACITY_OK, "USB lun %d read capacity is OK and its sector number is %d and sector size is %d")
+ TRC_MSG(USB_HOST_MS_CHECK_MEDIA_STATE, "USB MS host check media state %x")
+ TRC_MSG(USB_HOST_MS_MEDIA_STATE_CHANGE, "USB MS host lun %d has state change")
+ TRC_MSG(USB_HOST_MS_READ_FAIL, "USB MS host lun %d read fail")
+ TRC_MSG(USB_HOST_MS_WRITE_FAIL, "USB MS host lun %d write fail")
+ TRC_MSG(USB_HOST_MS_READ_SECTOR_FAIL, "USB MS host lun %d read sector %d with numbers %d fail because of reason %d")
+ TRC_MSG(USB_HOST_MS_READ_SECTOR_OK, "USB MS host lun %d read sector %d with numbers %d is OK")
+ TRC_MSG(USB_HOST_MS_WRITE_SECTOR_FAIL, "USB MS host lun %d write sector %d with numbers %d fail because of reason %d")
+ TRC_MSG(USB_HOST_MS_WRITE_SECTOR_OK, "USB MS host lun %d write sector %d with numbers %d is OK")
+ TRC_MSG(USB_HOST_MS_READ_SECTOR_TIMEOUT_FAIL, "USB MS host lun %d read sector fail because of timeout")
+ TRC_MSG(USB_HOST_MS_WRITE_SECTOR_TIMEOUT_FAIL, "USB MS host lun %d write sector fail because of timeout")
+ TRC_MSG(USB_HOST_ICCD_POWER_ON_OK, "IC USB ICCD power on")
+ TRC_MSG(USB_HOST_ICCD_POWER_ON_Fail,"IC USB ICCD power on fail")
+ TRC_MSG(USB_HOST_ICCD_POWER_OFF_OK, "IC USB ICCD power off")
+ TRC_MSG(USB_HOST_ICCD_XFR_BLOCK_OK, "IC USB ICCD TX Command: %d length")
+ TRC_MSG(USB_HOST_ICCD_DATA_BLOCK_OK, "IC USB ICCD RX Command: %d length")
+ TRC_MSG(USB_HOST_ICCD_SLOT_STATUS_OK, "IC USB ICCD Status %x")
+ TRC_MSG(USB_HOST_EEM_START, "IC USB EEM Start")
+ TRC_MSG(USB_HOST_EEM_END,"IC USB EEM Finish")
+ TRC_MSG(USB_HOST_EEM_SEND_FRAME, "IC USB EEM Send Frame: length : %d")
+ TRC_MSG(USB_HOST_EEM_SEND_FRAME_BUFFER, "IC USB EEM Send out buffer %d, waiting buffer %d")
+ TRC_MSG(USB_HOST_EEM_TX_DMA_Callback, "IC USB EEM TX DMA Callback buffer %d ,length: %d")
+ TRC_MSG(USB_HOST_EEM_GET_RX_BUFFER, "IC USB EEM Get RX buffer %d")
+ TRC_MSG(USB_HOST_EEM_RECEIVE_DATA, "IC USB EEM Receive Frame: length %d")
+ TRC_MSG(USB_HOST_EEM_RECEIVE_DATA_BUFFER, "IC USB EEM Receive buffer %d,waiting buffer %d")
+ TRC_MSG(USB_HOST_EEM_RX_DMA_Callback, "IC USB EEM RX DMA Callback buffer %d,length: %d")
+ TRC_MSG(USB_HOST_EEM_RX_FIFO_Read, "IC USB EEM RX FIFO Read buffer %d, length: %d")
+ TRC_MSG(USB_HOST_EEM_RECEIVE_DATA_ERROR, "IC USB EEM RX Data Error reason %d")
+ TRC_MSG(USB_PDN_LOOP_FAIL, "USB pdnmode function's while loop count is overflow")
+ TRC_MSG(USB_HOST_HIGH_RX_WRONG_MAX_PKT_SIZE, "USB host RX high endpoint max packet size is wrong")
+ TRC_MSG(USB_HOST_FULL_RX_WRONG_MAX_PKT_SIZE, "USB host RX full endpoint max packet size is wrong")
+ TRC_MSG(USB_HOST_HIGH_TX_WRONG_MAX_PKT_SIZE, "USB host TX high endpoint max packet size is wrong")
+ TRC_MSG(USB_HOST_FULL_TX_WRONG_MAX_PKT_SIZE, "USB host TX full endpoint max packet size is wrong")
+ TRC_MSG(USB_PTP_HREQUEST_ERROR, "WARNING!! 2 HREQUEST")
+ TRC_MSG(USB_PTP_DREQUEST_ERROR, "WARNING!! 2 DREQUEST")
+ TRC_MSG(USB_MTP_RESPONSE_WARNING, "USB receive MTP response message, but USB is in %d state")
+ TRC_MSG(USB_MTP_RESPONSE_UNEXPECTED_ZERO_WARNING, "USB receive MTP response message with a zero length")
+ TRC_MSG(USBIMAGE_EP0_RESET, "USB image receive ep0 reset command")
+ TRC_MSG(USBIMAGE_EP0_CANCEL, "USB image receive ep0 cancel command")
+ TRC_MSG(USBIMAGE_EP0_GET_STATUS_BUSY, "USB image response ep0 get status command with busy")
+ TRC_MSG(USBIMAGE_EP0_GET_STATUS_OK, "USB image response ep0 get status command with OK")
+ TRC_MSG(USBIMAGE_EP0_GET_STATUS_CANCEL, "USB image response ep0 get status command with transaction cancelled")
+ TRC_MSG(USBIMAGE_EP0_CANCEL_ERROR, "USB ep0 cancel command with wrong transaction ID %d, but current ID is %d")
+ TRC_MSG(USB_MTP_TX_RESPONSE_INVAILD_MTP_MSG, "USB in TX direction receive invalid MTP meaasge with result code %d and response code %x")
+ TRC_MSG(USB_MTP_RX_RESPONSE_INVAILD_MTP_MSG, "USB in RX direction receive invalid MTP meaasge with result code %d and response code %x")
+ TRC_MSG(USB_MTP_PC_SEND_WRONG_PACKET, "USB MTP receive a packet with %d length at wrong state %d")
+ TRC_MSG(USB_HW_ERROR_STATUS, "USB HW ERROR: %d, fast mode: %d")
+ TRC_MSG(USB_HOST_HW_ERROR, "USB HW ERROR in host mode")
+ TRC_MSG(USB_PULL_DOWN_DP, "USB HW ERROR D+ down")
+ TRC_MSG(USBACM_ENABLE_HIGH_SPEED_IF, "USB PPP enables high speed IF and current RX buffer write index is %d")
+ TRC_MSG(USBACM_DISABLE_HIGH_SPEED_IF, "USB PPP disables high speed IF and current RX ring buffer read pointer is %d")
+ TRC_MSG(USBACM_DISABLE_HIGH_SPEED_IF_TIMEOUT, "USB PPP disables high speed timeout, timeout count is %d")
+ TRC_MSG(USBACM_MOVE_RC_INDEX, "USB move read clear index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_MOVE_R_INDEX, "USB move read index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_MOVE_W_INDEX, "USB move write index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_HIGHSPEED_GETBYTES, "USB ACM high speed IF get bytes with %d bytes from USB port %d")
+ TRC_MSG(USBACM_HIGHSPEED_GETBYTES_NO_DATA, "USB ACM high speed IF get bytes no data by %d owner from USB port %d")
+ TRC_MSG(USBACM_HIGHSPEED_PUTBYTES, "USB ACM high speed IF put bytes with %d bytes from USB port %d")
+ TRC_MSG(USBACM_HIGHSPEED_PUTBYTES_SETUP_DMA, "USB ACM high speed IF put bytes ser up DMA with %d bytes from USB port %d")
+ TRC_MSG(USBACM_HIGHSPEED_PUTBYTES_DMA_IS_RUNNING, "USB ACM high speed IF put bytes and DMA is running")
+ TRC_MSG(USBACM_HIGHSPEED_PUTBYTES_FAIL, "USB ACM high speed IF put bytes fail due to USB wrong state")
+ TRC_MSG(USB_ISD_ENABLE_HIGH_SPEED_IF, "USB RNDIS enables high speed IF and current RX buffer write index is %d")
+ TRC_MSG(USB_ISD_DISABLE_HIGH_SPEED_IF, "USB RNDIS disables high speed IF and current RX ring buffer read pointer is %d")
+ TRC_MSG(USB_ISD_DISABLE_HIGH_SPEED_IF_TIMEOUT, "USB RNDIS disables high speed timeout, timeout count is %d")
+ TRC_MSG(USBACM_FLC_MOVE_RC_INDEX, "USB control pipe move read clear index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_FLC_MOVE_R_INDEX, "USB control pipe move read index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_FLC_MOVE_W_INDEX, "USB control pipe move write index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_GETBYTES, "USB control pipe get bytes with %d bytes from USB port %d")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_GETBYTES_NO_DATA, "USB control pipe get bytes no data by %d owner from USB port %d")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_PUTBYTES, "USB control pipe put bytes with %d bytes from USB port %d")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_PUTBYTES_SETUP_DMA, "USB control pipe put bytes ser up DMA with %d bytes from USB port %d")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_PUTBYTES_DMA_IS_RUNNING, "USB control pipe put bytes and DMA is running")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_PUTBYTES_FAIL, "USB control pipe put bytes fail due to USB wrong state")
+ TRC_MSG(USBACM_FLC_HIGHSPEED_PUTBYTES_BUSY, "USB control pipe put bytes fail due to USB last data didn't send out")
+ TRC_MSG(USBACM_RX_HIGHSPEED_BULK_OUT, "USB RX pipe : previous data len %d previous buffer addr %x current buffer addr %x")
+ TRC_MSG(USBACM_RX_INDEX, "USB data RX index, and current RX buffer write index is %d, buffer count is %d, read clear index is %d, and read index is %d")
+ TRC_MSG(USBACM_RX_DATA_HEADER,"USB RX pipe header : %x %x %x %x")
+ TRC_MSG(USBACM_RX_PUSH,"USB RX buffer push, index %d")
+ TRC_MSG(USBACM_RX_POP,"USB RX buffer pop, index %d")
+ TRC_MSG(USBACM_RX_NO_BUFFER,"USB RX no buffer , data count: %d")
+ TRC_MSG(USBACM_RX_FLC_DATA_HEADER,"USB control pipe rx header : %x %x %x %x")
+ TRC_MSG(USBACM_RX_FLC_PUSH,"USB control pipe rx buffer push, index %d")
+ TRC_MSG(USBACM_RX_FLC_POP,"USB control pipe rx buffer pop, index %d")
+ TRC_MSG(USBACM_RX_FLC_NO_BUFFER,"USB control pipe rx no buffer , data count: %d")
+ TRC_MSG(USBACM_Drop,"USB drop data , ep: %d , buffer index : %d")
+ TRC_MSG(USBACM_RX_FLC_HIGHSPEED_BULK_OUT, "USB RX pipe : previous data len %d previous buffer addr %x current buffer addr %x")
+ TRC_MSG(USBMS_READ_PERFORMANCE, "USB read performance %dKB/s")
+ TRC_MSG(USBMS_WRITE_PERFORMANCE, "USB write performance %dKB/s")
+ TRC_MSG(USBMS_CBWCMD, "USB CBW CMD 0x%x")
+ TRC_MSG(USB_TEST_LOAD, "USB compliance test load")
+ TRC_MSG(USB_MS_WRITE_SECTOR_FAIL, "USB MS Write Sector Fail!")
+ TRC_MSG(USB_DMAQ_RXGPD_SETUP, "USB RGPD SETUP: 0x%x header:0x%x")
+ TRC_MSG(USB_DMAQ_TXGPD_SETUP, "USB TGPD SETUP: 0x%x header:0x%x")
+ TRC_MSG(USB_DMAQ_RXGPD_FLUSH, "USB RGPD Flush")
+ TRC_MSG(USB_DMAQ_TXGPD_FLUSH, "USB TGPD Flush")
+ TRC_MSG(USB_DMAQ_RXGPD_INSERT, "USB RGPD INSERT: header: 0x%x; insert: 0x%x")
+ TRC_MSG(USB_DMAQ_TXGPD_INSERT, "USB TGPD INSERT: header: 0x%x; insert: 0x%x")
+ TRC_MSG(USB_DMAQ_RXGPD_INFO, "USB RGPD INFO: header:0x%x; next:0x%x, hwo=1")
+ TRC_MSG(USB_DMAQ_TXGPD_INFO, "USB TGPD INFO: header:0x%x; next:0x%x, hwo=1")
+ TRC_MSG(USB_DMAQ_RXGPD_EMPTY, "USB RGPD RX EMPTY: 0x%x 0x%x 0x%x 0x%x")
+ TRC_MSG(USB_DMAQ_TXGPD_EMPTY, "USB TGPD TX EMPTY: 0x%x 0x%x 0x%x 0x%x")
+ END_TRACE_MAP(MOD_UART1_HISR)
+
+
+#endif /*__TST_MODULE__*/
+
+#endif /* _USB_TRC_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbacm_adap.h b/mcu/driver/connectivity/usb_class/include/usbacm_adap.h
new file mode 100644
index 0000000..42c47e2
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbacm_adap.h
@@ -0,0 +1,166 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbacm_adap.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb adaption layer for UART API definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBACM_ADAP_H
+#define USBACM_ADAP_H
+
+//#include "uart_sw.h"
+#include "dcl.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_msgs.h"
+//#include "kal_non_specific_general_types.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+
+
+typedef enum
+{
+ CDC_ONLY_PUSH = 0, //Only push buffer ( initial sate: prepare buffer for USB )
+ CDC_ONLY_GET, // Only get data ( there might be no FLC buffer anymore )
+ CDC_GET_DATA, // normal state ( get data & push another buffer )
+ CDC_POP_BUFF // Get empty buffer (leave RNDIS mode „³ release FLC buffer )
+}USB_Requ_type;
+
+
+extern void USB2UART_Sendilm(UART_PORT port, msg_type msgid);
+extern void USB2UART_init(void);
+extern void USB2UART_Switch_Mapping(UART_PORT port,kal_uint8 new_port,kal_bool open);
+extern void USB2UART_Clear_Tx_Buffer(UART_PORT port);
+extern void USB2UART_Clear_Tx_ISR_Buffer(UART_PORT port);
+extern void USB2UART_Clear_Rx_Buffer(UART_PORT port);
+
+
+//#ifdef __USB_TETHERING__
+//extern kal_bool USB_Get_RNDIS_Mode(void);
+//extern kal_bool USB_Set_RNDIS_Mode(kal_bool set);
+//#endif
+
+
+#endif /* USBACM_ADAP_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbacm_drv.h b/mcu/driver/connectivity/usb_class/include/usbacm_drv.h
new file mode 100644
index 0000000..08bbcda
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbacm_drv.h
@@ -0,0 +1,914 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbacm_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb CDC ACM class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBACM_DRV_H
+#define USBACM_DRV_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usb.h"
+#include "dcl.h"
+#include "usb_comm.h"
+#include "kal_public_defs.h" //MSBB change #include "stack_config.h"
+//#include "uart_sw.h"
+#include "bmd.h"
+#include "usb_custom.h"
+#include "usb_custom_def.h"
+
+/***********************************************
+ acm class specific command definition
+************************************************/
+
+#define USB_ACM_DEVICE_CODE 0x02
+#define USB_ACM_SUBCLASS_CODE 0x00
+#define USB_ACM_PROTOCOL_CODE 0x00
+
+#define USB_ACM_COMM_INTERFACE_CLASS_CODE 0x02
+#define USB_ACM_COMM_INTERFACE_SUBCLASS_CODE 0x02
+#define USB_ACM_COMM_INTERFACE_PROTOCOL_CODE 0x01
+
+#define USB_ACM_DATA_INTERFACE_CLASS_CODE 0x0a
+#define USB_ACM_DATA_INTERFACE_SUBCLASS_CODE 0x00
+#define USB_ACM_DATA_INTERFACE_PROTOCOL_CODE 0x00
+
+#define USB_CDC_IF_LENGTH 28 /* standard plus class */
+
+/* Class-Specfic Codes ,EP0*/
+#define USB_ACM_SEND_ENCAPSULATED_COMMAND 0x00
+#define USB_ACM_GET_ENCAPSULATED_RESPONSE 0x01
+#define USB_ACM_SET_COMM_FEATURE 0x02
+#define USB_ACM_GET_COMM_FEATURE 0x03
+#define USB_ACM_CLEAR_COMM_FEATURE 0x04
+#define USB_ACM_SET_LINE_CODING 0x20
+#define USB_ACM_GET_LINE_CODING 0x21
+#define USB_ACM_SET_CONTROL_LINE_STATE 0x22
+#define USB_ACM_SEND_BREAK 0x23
+
+/* Class-Specfic Codes ,EP0 - NCM*/
+#define USB_NCM_SEND_ENCAPSULATED_COMMAND 0x00
+#define USB_NCM_GET_ENCAPSULATED_RESPONSE 0x01
+#define USB_NCM_GET_NTB_PARAMETERS 0x80
+#define USB_NCM_GET_NET_ADDRESS 0x81
+#define USB_NCM_SET_NET_ADDRESS 0x82
+#define USB_NCM_GET_NTB_INPUT_SIZE 0x85
+#define USB_NCM_SET_NTB_INPUT_SIZE 0x86
+#define USB_NCM_RESET 0x05
+
+
+/*Notifications, interrupt pipe*/
+#define USB_ACM_NOTIF_NETWORK_CONNECTION 0x00
+#define USB_ACM_NOTIF_RESPONSE_AVAILABLE 0x01
+#define USB_ACM_NOTIF_SERIAL_STATE 0x20
+
+/* UART state bitmap values */
+#define SERIAL_STATE_BRXCARRIER 0x01
+
+
+/*USB_ACM_SET_CONTROL_LINE_STATE*/ /* not use anywhere */
+#define CONTROL_LINE_SIGNAL_RTS 0x02 /*DCE's RTS,DTE's CTS*/
+#define CONTROL_LINE_SIGNAL_DTR 0x01 /*DCE's DTR,DTE's DSR*/
+
+
+// RNDIS Spec //
+#define USB_ISD_DEVICE_CODE 0xE0 //0x02 //0xE0
+#define USB_ISD_SUBCLASS_CODE 0x01 //0x00 //0x01
+#define USB_ISD_PROTOCOL_CODE 0x03 //0x00 //0x03
+
+#define USB_ISD_COMM_INTERFACE_CLASS_CODE 0xE0 //0x02 //0xE0
+#define USB_ISD_COMM_INTERFACE_SUBCLASS_CODE 0x01 //0x02 //0x01
+#define USB_ISD_COMM_INTERFACE_PROTOCOL_CODE 0x03 //0xff //0x03
+
+#define USB_ISD_DATA_INTERFACE_CLASS_CODE 0x0A
+#define USB_ISD_DATA_INTERFACE_SUBCLASS_CODE 0x00
+#define USB_ISD_DATA_INTERFACE_PROTOCOL_CODE 0x00
+
+#define USB_RNDIS_RESPONSE_AVAILABL 0x01
+
+#define RNDIS_RX_BUFFER_NUM USB_ACM_RX_BUFFER_NUM // UPS : put 8 buffer
+#define RNDIS_RX_FLC_BUFFER_NUM 3 // UPS : use 3 buffer
+#define RNDIS_MAX_FRAME 1560
+
+#define USB_RNDIS_RX_LOOP_COUNT 16
+
+
+
+//MBIM
+#define USB_MBIM_IF_LENGTH 31 /* standard plus class */
+
+#define USB_MBIM_DEVICE_CODE 0xEF
+#define USB_MBIM_SUBCLASS_CODE 0x02
+#define USB_MBIM_PROTOCOL_CODE 0x01
+#define USB_MBIM_DESCRIPTOR_CODE 0x1B //MBIM functional descriptor
+
+
+#define USB_MBIM_COMM_INTERFACE_CLASS_CODE 0x02
+#define USB_MBIM_COMM_INTERFACE_SUBCLASS_CODE 0x0E
+#define USB_MBIM_COMM_INTERFACE_PROTOCOL_CODE 0x00
+
+#define USB_MBIM_DATA_INTERFACE_CLASS_CODE 0x0A
+#define USB_MBIM_DATA_INTERFACE_SUBCLASS_CODE 0x00
+#define USB_MBIM_DATA_INTERFACE_PROTOCOL_CODE 0x02
+
+// MBIM Functional Descriptor
+#define MBIM_MAX_CONTROL_MESSAGE 512
+#define MBIM_NUMBER_FILTERS 16
+#define MBIM_MAX_FILTER_SIZE 64
+#define MBIM_MAX_SEGMENT_SIZE 2048
+
+
+
+/***********************************************
+ Implement definition
+************************************************/
+
+#define USB_CDC_ACM_IF_NUMBER 2
+
+#define USB_CDC_ACM_COMM_EP_NUMBER 1 /*interrupt pipe*/
+#define USB_CDC_ACM_DATA_EP_NUMBER 2
+
+#define USBACM_RING_BUFFER_TIMEOUT 25
+
+#define USBACM_HIGH_SPEED_LOOP 100
+#define USBACM_DIRECT_PATH_LOOP 500
+
+
+#define USB_ACM_RX_HDLR_PACKET_NUM 16
+
+
+/***********************************************
+ UART SW Implement definition
+************************************************/
+#define UART_STAT_EscDet 0x01
+#define UART_STAT_Break 0x02
+
+#define UART_RecNormal 0
+#define UART_Get3EscChar 1
+#define UART_StartCheckESC 2
+
+typedef void (*UART_TX_FUNC)(UART_PORT port);
+typedef void (*UART_RX_FUNC)(UART_PORT port) ;
+
+/***********************************************
+ acm class specific descriptor structure
+************************************************/
+
+/* CDC ACM communication interface descriptor element */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bInterfaceNumber;
+ kal_uint8 bAlternateSetting;
+ kal_uint8 bNumEndpoints;
+ kal_uint8 bInterfaceClass;
+ kal_uint8 bInterfaceSubClass;
+ kal_uint8 bInterfaceProtocol;
+ kal_uint8 iInterface;
+
+ kal_uint8 HFbFunctionLength; /*Header Functional Descriptor*/
+ kal_uint8 HFbDescriptorType;
+ kal_uint8 HFbDescriptorSubtype;
+ kal_uint16 bcdCDC;
+
+ kal_uint8 ACMFbFunctionLength; /*Abstract Control Management Functional Descriptor*/
+ kal_uint8 ACMFbDescriptorType;
+ kal_uint8 ACMFbDescriptorSubtype;
+ kal_uint8 ACMFbmCapabilities;
+
+ kal_uint8 UFbFunctionLength; /*Union Functional Descriptor*/
+ kal_uint8 UFbDescriptorType;
+ kal_uint8 UFbDescriptorSubtype;
+ kal_uint8 bMasterInterface;
+ kal_uint8 bSlaveInterface0;
+
+ kal_uint8 CMFbFunctionLength; /*Call Management Descriptor*/
+ kal_uint8 CMFbDescriptorType;
+ kal_uint8 CMFbDescriptorSubtype;
+ kal_uint8 CMFbmCapabilities;
+ kal_uint8 bDataInterface;
+} Usb_Cdc_If_Dscr;
+
+
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bInterfaceNumber;
+ kal_uint8 bAlternateSetting;
+ kal_uint8 bNumEndpoints;
+ kal_uint8 bInterfaceClass;
+ kal_uint8 bInterfaceSubClass;
+ kal_uint8 bInterfaceProtocol;
+ kal_uint8 iInterface;
+
+ kal_uint8 HFbFunctionLength; /*Header Functional Descriptor*/
+ kal_uint8 HFbDescriptorType;
+ kal_uint8 HFbDescriptorSubtype;
+ kal_uint16 bcdCDC;
+
+ kal_uint8 UFbFunctionLength; /*Union Functional Descriptor*/
+ kal_uint8 UFbDescriptorType;
+ kal_uint8 UFbDescriptorSubtype;
+ kal_uint8 bMasterInterface;
+ kal_uint8 bSlaveInterface0;
+
+ kal_uint8 MBIMbFunctionLength; /*MBIM Functional Descriptor*/
+ kal_uint8 MBIMbDescriptorType;
+ kal_uint8 MBIMbDescriptorSubtype;
+ kal_uint16 MBIMbcdMBIMVersion;
+ kal_uint16 MBIMwMaxControlMessage;
+ kal_uint8 MBIMbNumberFiliters;
+ kal_uint8 MBIMbMaxFiliterSize;
+ kal_uint16 MBIMwMaxSegmentSize;
+ kal_uint8 MBIMbmNetworkCapabilities;
+} Usb_MBIM_If_Dscr;
+
+
+/* ACM line coding element */
+typedef struct
+{
+ kal_uint32 dwDTERate;
+ kal_uint8 bCharFormat;
+ kal_uint8 bParityType;
+ kal_uint8 bDataBits;
+} UsbAcm_Line_Coding;
+
+
+/* ACM interrupt packet structure */
+typedef struct
+{
+ kal_uint8 bmRequestType;
+ kal_uint8 bRequest;
+ kal_uint16 wValue;
+ kal_uint16 wIndex;
+ kal_uint16 wLength;
+ kal_uint16 Data;
+}UsbAcm_Intr_Pkt;
+
+
+/***********************************************
+ implement enum and structure
+************************************************/
+
+/* transmit buffer type */
+typedef enum
+{
+ USBTRX_MEM_UNKOWN = 0,
+ USBTRX_MEM_ISR,
+ USBTRX_MEM_TASK,
+ USBTRX_MEM_MAX_TYPE
+} USBTRX_MEM_TYPE;
+
+typedef enum
+{
+ ACM_INTR_IDLE = 0,
+ ACM_INTR_SEND_ONE_PKT,
+ ACM_INTR_SEND_LAST_PKT
+}USB_ACM_INTR_PIPE_STATE;
+
+
+/* Current ACM driver owner application */
+typedef enum
+{
+ USB_ACM_OWNER_UART = 0,
+ USB_ACM_OWNER_FT
+// USB_ACM_OWNER_LOGGING
+}USB_ACM_OWNER_TYPE;
+
+
+
+typedef enum
+{
+ CDC_NORMAL = 0, // old transfer type, save data in ring buffer, and copy data to buffer by single interrupt ex:USB2UART_GetBytes
+ CDC_HIGH_SPEED, // Only get data ( there might be no FLC buffer anymore)
+ CDC_HIGH_SPEED_FRAME, // use transfer as unit
+ CDC_HIGH_SPEED_FRAME_DMAQ // use transfer as unit with DMAQ
+}USB_Transfer_type;
+
+/**
+ * TGPD
+ */
+typedef struct _TGPD
+{
+ kal_uint8 flag;
+ kal_uint8 chksum;
+ kal_uint16 DataBufferLen; /*Rx Allow Length*/
+ struct _TGPD* pNext;
+ kal_uint8* pBuf;
+ kal_uint16 bufLen;
+ kal_uint8 ExtLength;
+ kal_uint8 ZTepFlag;
+}TGPD, *PGPD;
+
+#define RXGPD_FLAGS_HWO 0x01
+#define RXGPD_FLAGS_BDP 0x02
+#define RXGPD_ENDPOINT 0x0F
+#define RXGPD_TGL 0x10
+#define RXGPD_ZLP 0x20
+#define RXGPD_FLAGS_IOC 0x80
+
+
+#define TXGPD_FLAGS_HWO 0x01
+#define TXGPD_FORMAT_BDP 0x02
+#define TXGPD_FORMAT_TGL 0x10
+#define TXGPD_FORMAT_ZLP 0x20
+#define TXGPD_FLAG_IOC 0x40
+
+
+typedef void (*usb_acm_rx_ptr)(void);
+
+/* ACM device structure */
+typedef struct
+{
+ kal_uint8 data_interface_id;
+ kal_bool send_Txilm;
+ kal_bool send_Rxilm;
+ kal_bool send_UARTilm;
+ kal_bool config_send_Txilm;
+ kal_bool ring_buffer_timer_counting; /* flag to check ring buffer timer running or not */
+ kal_bool threshold_enable; /* enable ring buffer threshold and time out mechanism */
+ kal_bool setup_dma; /* a flag to record DMA is triggered or not */
+ kal_bool is_intr_pending_pkt; /* interrupt pipe has pending packet */
+ kal_bool dma_txcb_just_done; /*DMA TX Callback Function just done. It's clear by putbyte funtion*/
+ kal_bool break_detect;
+ kal_bool put_start;
+ kal_uint16 dmaf_setmember; /* Who set dma_false after putbyte and it does not finsih*/
+ kal_uint16 line_state;
+ UsbAcm_Intr_Pkt intr_pkt;
+
+ kal_uint32 handle; /*GPT handle*/
+ kal_uint32 dma_handle; /*for DMA timeout handle*/
+ kal_uint32 ring_buffer_handle; /* ring buffer's GPT handle */
+ kal_uint32 break_number;
+ UsbAcm_Line_Coding line_coding; /* current line coding, just used to reply to host */
+
+ Usb_EpBIn_Status *txpipe; /* bulk in EP, Data interface */
+ Usb_EpBOut_Status *rxpipe; /* bulk out EP, Data interface */
+ Usb_EpBIn_Status *intrpipe; /* interrupt EP, Communication Interface */
+
+ USB_ACM_INTR_PIPE_STATE intr_state; /* interrupt pipe state machine */
+ Usb_Ep_Info *comm_ep_intr_info;
+ Usb_Ep_Info *data_ep_in_info;
+ Usb_Ep_Info *data_ep_out_info;
+ Usb_Interface_Info *comm_if_info;
+ Usb_Interface_Info *data_if_info;
+
+ USB_Transfer_type transfer_type;
+
+
+ kal_uint32 data_addr;
+ kal_uint32 rx_buf_data_len[USB_ACM_RX_BUFFER_NUM];
+ kal_uint16 tx_count; /* To store the TX count, debug only*/
+ kal_bool b_data_left; // left data due to 512N
+ kal_bool b_is_high_speed_enable;
+ kal_bool b_rc_index_move;
+ kal_uint16 b_rc_get_count;
+ kal_uint8 rx_buf_rc_index; /* read clear pointer */
+ kal_uint8 rx_buf_r_index; /* read pointer */
+ kal_uint8 rx_buf_w_index; /* write pointer */
+ kal_uint8 rx_buf_count; /* the buffer count with data */
+#ifdef DRV_USB_DMA_QUEUE_SUPPORT
+ kal_bool ppp_txdmaq_first;
+ kal_uint32 ppp_rdmaq_idx;
+ kal_uint32 ppp_tdmaq_idx;
+#endif
+//#endif
+
+//#ifdef __USB_TETHERING__
+ kal_uint8 *rx_buf_addr[RNDIS_RX_BUFFER_NUM+1]; //9 : 0 ~ 8
+ kal_uint32 isd_rx_buf_data_len[RNDIS_RX_BUFFER_NUM+1];
+ kal_uint8 *rx_flc_buf_addr[RNDIS_RX_FLC_BUFFER_NUM+1]; //3 //3: 0~2
+ kal_uint32 rx_flc_buf_data_len[RNDIS_RX_FLC_BUFFER_NUM+1];
+ kal_uint16 tx_flc_count; /* To store the TX count, debug only*/
+ kal_uint8 *tx_flc_data_addr;
+ kal_bool rx_full_data;
+ kal_bool halt_flag;
+ kal_bool ctrl_data_done;
+ kal_bool send_ctrl_Txilm; // Ctrl pipe --> TX message
+ kal_bool send_ctrl_Rxilm; // ctrl pipe --> RX message
+
+// kal_bool dma_rx_running; //use FIFO Read first
+// kal_bool dma_tx_running; //the dame as setup_dma
+
+ kal_uint8 rx_full_buff_index; // receive Data
+ kal_uint8 rx_empty_buff_index; // empty buffer
+ kal_uint8 rx_flc_full_buff_index; // receive Data
+ kal_uint8 rx_flc_empty_buff_index; // empty buffer
+// kal_bool b_flc_rc_index_move;
+ kal_uint8 rx_flc_buf_rc_index; /* read clear pointer */
+ kal_uint8 rx_flc_buf_r_index; /* read pointer */
+ kal_uint8 rx_flc_buf_w_index; /* write pointer: data write (bulk out handler) */
+ kal_uint8 rx_flc_buf_count; /* the buffer count with data */
+ kal_uint8 rx_flc_temp_length; /* for first time PC send data just before buffer push (initial message) */
+ kal_bool rx_flc_temp; /* for first time PC send data just before buffer push (initial message) */
+ kal_uint8 *rx_flc_temp_buf_addr;
+
+#ifdef __USB_SW_DMA_DIV__
+ kal_uint8 *tx_temp_buf_addr;
+#endif
+ kal_bool b_is_tx_direct_path_enable;
+
+}UsbAcm_Struct;
+
+
+
+typedef struct
+{
+ /* FT mode param */
+ USB_ACM_OWNER_TYPE acm_owner;
+ kal_uint8 *rx_buf_addr[RNDIS_RX_BUFFER_NUM+1]; //9 : 0 ~ 8
+ kal_uint8 ft_port_num;
+
+ kal_uint8 ft_data[USB_EP_BULK_MAXP];
+
+ kal_uint16 ft_data_len;
+ usb_acm_rx_ptr ft_rx_cb;
+
+ /* Customizable variables */
+ const USB_ACM_PARAM *acm_param;
+}UsbAcm_Common_Struct;
+
+
+typedef struct
+{
+ UART_PORT port_no;
+ kal_bool initialized;
+ kal_bool power_on;
+ module_type ownerid;
+ module_type UART_id;
+ kal_bool breakDet;
+ kal_bool EscFound;
+ IO_level DSR;
+
+ kal_uint8 EscCount;
+ kal_uint8 Rec_state; /**/
+
+ /*detect Escape*/
+ kal_uint32 handle; /*GPT handle*/
+ UARTDCBStruct DCB;
+
+ UART_ESCDetectStruct ESCDet;
+ UART_RingBufferStruct RingBuffers;
+ BUFFER_INFO Rx_Buffer; /* receive buffer */
+ BUFFER_INFO Tx_Buffer; /* transmit buffer */
+ BUFFER_INFO Tx_Buffer_ISR; /* receive buffer */
+
+ UART_TX_FUNC tx_cb;
+ UART_RX_FUNC rx_cb;
+
+
+// kal_hisrid hisr;
+//#ifdef __DMA_UART_VIRTUAL_FIFO__
+// kal_uint8 Rx_DMA_Ch;
+// kal_uint8 Tx_DMA_Ch;
+//#endif
+//#ifdef DCM_ENABLE
+// UART_BAUD_AUTO conflict with rate fix, need to disable DCM
+// kal_uint32 DCMHandle;
+// kal_bool AutobaudDetection;
+//#endif
+//#if defined(DRV_UART_COMPENSATE_AT)
+// UART_Compensate_enum CompensateAT;
+//#endif
+// UART_SLEEP_ON_TX sleep_on_tx;
+// kal_bool EnableTX;
+
+} UsbUARTStruct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern UsbUARTStruct USB2UARTPort[MAX_USB_PORT_NUM];
+extern UsbAcm_Struct g_UsbACM[MAX_USB_PORT_NUM];
+extern UsbAcm_Common_Struct g_UsbACM_Comm;
+extern kal_uint8 USB_PORT[uart_max_port];
+extern kal_bool USB_IS_LOGGING_PORT[uart_max_port];
+
+extern void usb_drv_trace4(module_type ownerid, kal_uint32 msg_index,const char *arg_type, kal_uint32 data1, kal_uint32 data2,kal_uint32 data3, kal_uint32 data4);
+extern void usb_drv_trace2(module_type ownerid, kal_uint32 msg_index,const char *arg_type, kal_uint32 data1, kal_uint32 data2);
+extern void usb_drv_trace1(module_type ownerid, kal_uint32 msg_index,const char *arg_type, kal_uint32 data1);
+extern void usb_drv_trace0(module_type ownerid, kal_uint32 msg_index,const char *arg_type);
+extern void USB_Acm_Exception_Check(void);
+
+extern void USB_Check_Owner(module_type ownerid,module_type current_ownerid);
+
+extern void USB_UnMask_COM_Intr(UART_PORT port);
+extern void USB_Mask_COM_Intr(UART_PORT port);
+
+extern void UART2USB_DCB2LineCoding(UARTDCBStruct *pDCB, UsbAcm_Line_Coding *pline_coding);
+
+extern void USB2UART_Timeout(void *parameter);
+
+extern void USB2UART_Dafault_Tx_Callback(UART_PORT port);
+extern void USB2UART_Dafault_Rx_Callback(UART_PORT port);
+extern void USB_Acm_Ring_Buffer_Threshold_Enable(UART_PORT port, kal_bool bset, module_type ownerid);
+
+extern void USB2UART_Polling_Flush_Transmit_Data(UART_PORT port);
+extern void USB2UART_Polling_Recv_Data(UART_PORT port);
+
+#if defined(__USB_LIMIT__)
+extern void USB2UART_Set_DMA_Limiter(kal_uint32 dma_limit_num);
+extern void USB2UART_Clear_DMA_Limiter(void);
+#endif
+
+extern void USB2UART_DMATransmit(UART_PORT port, kal_bool b_force_isr_buffer);
+extern void USB2UART_Tx_DMA1_Callback(void);
+
+extern void USB_Acm_Rx_ClrFifo(UART_PORT port);
+extern void USB_Acm1_CommIf_Create(void *ifname);
+extern void USB_Acm1_CommIf_Reset(void);
+extern void USB_Acm1_CommIf_Enable(void);
+extern void USB_Acm1_CommIf_Speed_Reset(kal_bool b_other_speed);
+extern void USB_Acm1_DataIf_Create(void *ifname);
+extern void USB_Acm1_DataIf_Reset(void);
+extern void USB_Acm1_DataIf_Enable(void);
+extern void USB_Acm1_DataIf_Speed_Reset(kal_bool b_other_speed);
+
+extern void USB_Acm_VendorIf_Create(void *ifname);
+extern void USB_Acm_VendorIf_Reset(void);
+extern void USB_Acm_VendorIf_Enable(void);
+extern void USB_Acm_VendorIf_Speed_Reset(kal_bool b_other_speed);
+
+
+
+
+extern void USB_Init_Acm_Status(void);
+extern void USB_Release_Acm_Status(void);
+
+extern void USB2UART_Tx_DMA2_Callback(void);
+extern void USB_Acm2_CommIf_Create(void *ifname);
+extern void USB_Acm2_CommIf_Reset(void);
+extern void USB_Acm2_CommIf_Enable(void);
+extern void USB_Acm2_CommIf_Speed_Reset(kal_bool b_other_speed);
+extern void USB_Acm2_DataIf_Create(void *ifname);
+extern void USB_Acm2_DataIf_Reset(void);
+extern void USB_Acm2_DataIf_Enable(void);
+extern void USB_Acm2_DataIf_Speed_Reset(kal_bool b_other_speed);
+
+
+extern void USB_Acm_FT_Register_Rx_Cb(usb_acm_rx_ptr cb);
+
+#if defined (DRV_USB_DMA_QUEUE_SUPPORT)
+extern void USB_DMAQ_Setup(kal_uint32 ep_num, USB_EP_DIRECTION direction, kal_bool first, kal_uint32 addr, usb_dmaq_callback callback, usb_dmaq_callback empty_callback);
+extern void USB_DMAQ_Stop(kal_uint32 ep_num, USB_EP_DIRECTION direction);
+extern void USB_TxEP_DMAQ_En(kal_uint8 epno, kal_bool bQMU);
+extern void USB_RxEP_DMAQ_En(kal_uint8 epno, kal_bool bQMU);
+
+extern void USB2UART_PPPRX_DMAQ_Callback(kal_uint32 usb_port);
+extern void USB2UART_PPPTX_DMAQ_Callback(kal_uint32 usb_port);
+#endif
+
+#endif /* USBACM_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbacm_echo.h b/mcu/driver/connectivity/usb_class/include/usbacm_echo.h
new file mode 100644
index 0000000..4cc18d6
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbacm_echo.h
@@ -0,0 +1,104 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbacm_echo.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file implements USB DVT or Throughput test
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBACM_DRV_H
+#define USBACM_DRV_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usb_custom.h"
+
+
+/***********************************************
+ function and global variable
+************************************************/
+
+extern void USB_ECHO_TEST(void);
+
+
+#endif /* USBACM_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbacm_ft.h b/mcu/driver/connectivity/usb_class/include/usbacm_ft.h
new file mode 100644
index 0000000..640ecb9
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbacm_ft.h
@@ -0,0 +1,98 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbacm_ft.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb adaption layer for factory mode definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBACM_FT_H
+#define USBACM_FT_H
+
+//#include "kal_non_specific_general_types.h"
+
+#define USB2UART_METX_TX_MAX_LEN ((1<<16)-1)
+
+extern void USB_Acm_FT_Init(void);
+extern kal_uint8 USB_Acm_FT_Port(void);
+
+extern kal_uint16 USB2UART_FT_Get_Max_Len(void);
+extern void USB2UART_FT_Tx_Byte(kal_uint8* addr, kal_uint16 len);
+extern void USB2UART_FT_Tx_Word(kal_uint32* addr, kal_uint16 len);
+extern void USB2UART_FT_Tx_Stop(void);
+extern kal_uint16 USB2UART_FT_Rx_Byte(kal_uint8* addr, kal_uint16 len);
+
+#endif /* USBACM_FT_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbacm_logging.h b/mcu/driver/connectivity/usb_class/include/usbacm_logging.h
new file mode 100644
index 0000000..1a76a6e
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbacm_logging.h
@@ -0,0 +1,192 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbacm_logging.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for USB logging tool API definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBACM_LOGGING_H
+#define USBACM_LOGGING_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usblog_drv.h"
+#include "drv_features_usb.h"
+
+
+typedef enum
+{
+ USBACM_LOGGING_DMA_OWNER_NONE,
+ USBACM_LOGGING_DMA_OWNER_DMA,
+ USBACM_LOGGING_DMA_OWNER_LOG_SRC,
+ USBACM_LOGGING_DMA_OWNER_MAX
+}USBACM_LOGGING_DMA_OWNER;
+
+
+
+typedef struct
+{
+ USBACM_LOGGING_DMA_OWNER dma_owner;
+#if (defined(DRV_USB_LOGGING_V6)||defined(DRV_USB_LOGGING_V5)||defined(DRV_USB_LOGGING_V8))
+ kal_uint32 buff_size[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+ /* Debug info */
+ kal_uint32 buffer_transmitted_times[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+ kal_uint32 buffer_transmitted_num[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+ kal_uint32 full_times;
+ kal_uint8 buff_num[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+ kal_uint8 dma_read_index[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+
+ kal_uint8 transmitting_buf_index; /* buffer source which transmitting */
+ kal_uint8 buffer_full_index[USBACM_LOGGING_TOTAL_SOURCE_NUM];
+ kal_uint8 empty_buf_count[USBACM_LOGGING_TOTAL_SOURCE_NUM]; /* the empty buffer number */
+#endif
+
+ kal_uint8 transmitting_count;
+ kal_bool b_not_first_time; /* used for IRDBG only */
+ kal_bool b_reset;
+ kal_bool b_enable;
+}USBACM_LOGGING_Struct;
+
+
+extern kal_uint8 L1D_IRDMA_Power_GetHandle(void);
+extern void L1D_IRDMA_Power_On(kal_uint8 handle);
+extern void L1D_IRDMA_Power_Off(kal_uint8 handle);
+
+#if (defined(DRV_USB_LOGGING_V5)||defined(DRV_USB_LOGGING_V5))
+extern void USBACM_LOGGING_3G_Reset(void);
+extern void USBACM_LOGGING_Reset_Hdlr(void);
+#endif
+extern void USBACM_LOGGING_Init(void);
+extern void USBACM_LOGGING_Start_Hdlr(void);
+extern void USBACM_LOGGING_Stop(void);
+extern void USBACM_LOGGING_Connect_Hdlr(void);
+extern void USBACM_LOGGING_Discon_Hdlr(void);
+//extern void USBACM_LOGGING_Flush_Data(void);
+extern void USB_DSPIRDBG_Flush_Data(void);
+
+#endif /* USBACM_LOGGING_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbd.h b/mcu/driver/connectivity/usb_class/include/usbd.h
new file mode 100644
index 0000000..015357f
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbd.h
@@ -0,0 +1,437 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbd.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb1.1 host definitions.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBD_H
+#define USBD_H
+
+//#include "usb_hcd.h"
+#include "dcl.h"
+//#include "kal_non_specific_general_types.h"
+#include "usb.h"
+#include "usb_drv.h"
+#include "usb_custom_def.h"
+
+
+#define USBD_MAX_CFG_NUM 8
+#define USBD_MAX_IF_PER_CFG 4
+#define USBD_MAX_INTERFACE_NUM (USBD_MAX_CFG_NUM * USBD_MAX_IF_PER_CFG)
+#define USBD_MAX_EP_PER_IF 3
+#define USBD_MAX_EP_NUM (USBD_MAX_INTERFACE_NUM * USBD_MAX_EP_PER_IF)
+#define USBD_MAX_CLASS_DRIVER 2
+
+#define USBD_EP0_MAX_PKT_SIZE 64
+
+#define USBD_ERROR_DELAY 35 /* 10ms unit*/
+
+#define USBD_SET_ADDRESS_RECOVERY_DELAY 1
+
+#define USBD_TEST_MODE_DELAY 1500
+//#define USBD_TEST_MODE_DELAY 300
+
+
+#ifdef __OTG_ENABLE__
+#define USB_EXT_HOST_NUM 1
+#else
+#define USB_EXT_HOST_NUM 0
+#endif
+
+#ifdef __IC_USB_ENABLE__
+#define USB_INT_HOST_NUM 1
+#else
+#define USB_INT_HOST_NUM 0
+#endif
+
+
+#define USB_HOST_NUM (USB_EXT_HOST_NUM + USB_INT_HOST_NUM)
+
+
+/* USBD test mode */
+#define USBD_TEST_SE0_NAK 0x0101
+#define USBD_TEST_J 0x0102
+#define USBD_TEST_K 0x0103
+#define USBD_TEST_PACKET 0x0104
+#define USBD_TEST_HS_HOST_PORT_SUSPEND_RESUME 0x0106
+#define USBD_TEST_SINGLE_STEP_GET_DEV_DESC 0x0107
+#define USBD_TEST_SINGLE_STEP_SET_FEATURE 0x0108
+#define USBD_TEST_UNSUPPORTED_DEVICE 0xBADD
+
+
+
+
+#define EVENT_USBD_EP0_DONE ((kal_uint32)0x00000001)
+#define EVENT_USBD_EP0_DETACH ((kal_uint32)0x00000002)
+#define EVENT_USBD_EP0_ENUMERATION ((kal_uint32)0x00000004)
+#define EVENT_USBD_RESUME_DONE ((kal_uint32)0x00000008)
+
+typedef enum
+{
+ USBD_CH9_START,
+ USBD_CH9_STOP,
+ USBD_CH9_DELAY_SET_ADDR,
+ USBD_CH9_SET_ADDR,
+ USBD_CH9_GET_DEV_DESC_8,
+ USBD_CH9_GET_DEV_DESC,
+ USBD_CH9_GET_CONF_DESC_9,
+ USBD_CH9_GET_CONF_DESC,
+ USBD_CH9_SET_CONF,
+ USBD_CH9_SET_HNP_ENABLE,
+ USBD_CH9_ENUM_OK,
+ USBD_CH9_ENUM_FAIL
+}USBD_CH9_STATE;
+
+
+typedef enum
+{
+ USBD_EP0_SETUP,
+ USBD_EP0_DATA,
+ USBD_EP0_STATUS,
+ USBD_EP0_NONE
+}USBD_EP0_STATE;
+
+
+typedef enum
+{
+ USBD_EP0_DATA_RECV,
+ USBD_EP0_DATA_SEND,
+ USBD_EP0_DATA_NULL /* no data phase is needed */
+}USBD_EP0_DATA_DIR;
+
+
+typedef enum
+{
+ USBD_HNP_NOT_SUPPORT,
+ USBD_HNP_SUPPORT,
+ USBD_HNP_ENABLE_STALL
+}USBD_HNP_SUPPORT_TYPE;
+
+
+typedef enum
+{
+ USBD_TEST_MODE_NONE = 0,
+ USBD_TEST_MODE_TYPE_SE0,
+ USBD_TEST_MODE_TYPE_J,
+ USBD_TEST_MODE_TYPE_K,
+ USBD_TEST_MODE_TYPE_TEST_PACKET,
+ USBD_TEST_MODE_TYPE_HS_HOST_PORT_SUSPEND_RESUME,
+ USBD_TEST_MODE_TYPE_SINGLE_STEP_GET_DEV_DESC,
+ USBD_TEST_MODE_TYPE_SINGLE_STEP_SET_FEATURE,
+ USBD_TEST_MODE_TYPE_UNSUPPORTED_DEVICE
+}USBD_TEST_MODE_TYPE;
+
+
+/* EP0 status */
+typedef struct
+{
+ kal_uint8 device_addr; /* new function address */
+// kal_uint8 max_packet_size;
+ Usb_Command setup_cmd; /* setup packet address */
+ kal_uint8 *data_ptr; /* data packet address */
+ USBD_EP0_DATA_DIR ep0_data_dir; /* data phase direction */
+ kal_uint32 sofar; /* number of bytes sent/recv'd so far */
+ kal_uint32 todo; /* number of bytes to send/recv */
+}USBD_EP0_Status;
+
+
+/* Bulk IN endpoint status */
+typedef struct
+{
+ kal_uint8 max_packet_size;
+ kal_uint8 *data_ptr; /* data packet address */
+ kal_uint32 sofar; /* number of bytes sent/recv'd so far */
+ kal_uint32 todo; /* number of bytes to send/recv */
+}USBD_EPIN_Status;
+
+
+/* Bulk OUT endpoint status */
+typedef struct
+{
+ kal_uint8 max_packet_size;
+ kal_uint8 *data_ptr; /* data packet address */
+ kal_uint32 sofar; /* number of bytes sent/recv'd so far */
+ kal_uint32 todo; /* number of bytes to send/recv */
+}USBD_EPOUT_Status;
+
+/* endpoint information, including endpoint status */
+typedef struct
+{
+ Usb_Ep_Dscr *p_stdep; /* ep descriptor */
+ union
+ {
+ USBD_EPIN_Status epin_status;
+ USBD_EPOUT_Status epout_status;
+ }ep_status;
+}USBD_EP_Info;
+
+
+typedef struct
+{
+ Usb_If_Dscr *p_interface_desc;
+ USBD_EP_Info *p_ep_info[USBD_MAX_EP_PER_IF];
+ kal_uint8 ep_number;
+}USBD_IF_Info;
+
+
+typedef struct
+{
+ Usb_Cfg_Dscr *p_cfg_desc;
+ USBD_IF_Info *p_interface_info[USBD_MAX_IF_PER_CFG];
+ kal_uint8 match_class_driver_index[USBD_MAX_IF_PER_CFG]; /* To store the class driver index for each interface */
+ kal_uint8 match_class_driver_point; /* To store the weighting of class driver index for each configuration */
+ kal_uint8 active_if_index_map; /* the index mapping that the active interface */
+ kal_uint8 interface_number;
+ kal_uint8 match_class_num; /* the number that match class drivers, exclude default driver */
+}USBD_CFG_Info;
+
+
+typedef struct
+{
+ Usb_Dev_Dscr dev_desc;
+ USBD_CFG_Info cfg_info[USBD_MAX_CFG_NUM];
+// Usb_IAD_Dscr *iad_desc;
+ USBD_IF_Info interface_info[USBD_MAX_INTERFACE_NUM];
+ USBD_EP_Info ep_info[USBD_MAX_EP_NUM];
+ Usb_String_Dscr *string_desc;
+ Usb_Otg_Dscr *p_otg_desc[USBD_MAX_CFG_NUM];
+ Usb_Dev_Qual_Dscr *dev_qual_dscr;
+ Usb_Other_Speed_Cfg_Dscr *other_speed_cfg_dscr;
+// Usb_OS_String_Dscr *os_string_desc;
+// Usb_Ext_Compat_ID_OS_Feature_Dscr *os_feature_desc;
+ kal_uint8 *p_conf_data[USBD_MAX_CFG_NUM];
+ kal_uint8 cfg_number;
+}USBD_Desc_Info;
+
+
+typedef struct
+{
+ kal_bool (* match)(kal_uint8 usb_ip_port, USBD_Desc_Info *p_desc_info, kal_uint32 cfg_num, kal_uint32 if_num);
+ void (* startup)(kal_uint8 usb_ip_port, USBD_Desc_Info *p_desc_info, kal_uint32 cfg_num, kal_uint32 if_num);
+ void (* detach)(kal_uint8 usb_ip_port);
+ void (* suspend)(kal_uint8 usb_ip_port);
+ void (* resume)(kal_uint8 usb_ip_port);
+}USBD_ClassDriver_Struct;
+
+
+typedef void (*usbd_ep0_callback)(kal_uint8 usb_ip_port, USB_HCD_STATUS result, kal_uint32 param);
+
+
+typedef struct
+{
+ USBD_Desc_Info desc_info;
+ USBD_EP0_STATE ep0_state; //states machine
+ USBD_EP0_Status ep0_status;
+ USBD_CH9_STATE ch9_state;
+ USBD_ClassDriver_Struct *class_driver_ptr[USBD_MAX_CLASS_DRIVER];
+ usbd_ep0_callback ep0_callback;
+ kal_uint8 ch9_error_count;
+ USBD_HNP_SUPPORT_TYPE support_hnp;
+ kal_uint8 default_class_driver_index;
+ kal_bool b_is_match_hub;
+ kal_uint32 gpt_handle; /*GPT handle*/
+ kal_mutexid usbd_ep0_mutex_id; /* mutex used to protect ep0 setup command. */
+ kal_mutexid usbd_resume_mutex_id; /* mutex used to protect ep0 setup command. */
+ kal_eventgrpid usbd_ep0_event_id; /* event used for ep0 command */
+ kal_eventgrpid usbd_resume_event_id; /* event used for ep0 command */
+ kal_bool b_suspend_mode;
+ kal_uint8 set_cfg_number;
+ kal_uint8 usb_ip_port;
+}USBD_Struct;
+
+
+typedef struct
+{
+ kal_mutexid usbd_com_ep0_mutex_id; /* mutex used to let multiple IPs can be enumerated one by one*/
+ kal_eventgrpid usbd_com_ep0_event_id; /* event used for waiting enumeration done */
+ /* Customizable variables */
+ const USB_HOST_MATCH_PARAM *host_match_param;
+}USBD_Common_Struct;
+
+
+
+//extern void USBD_Deregister_Port_Info(kal_uint8 *usb_ip_port_ptr);
+extern void USBD_Init_Status(kal_uint8 usb_ip_port);
+extern void USBD_Init(kal_uint8 usb_ip_port);
+extern void USBD_Release_Status(kal_uint8 usb_ip_port);
+extern void USBD_Release(kal_uint8 usb_ip_port);
+extern void USBD_Attatch_Hdlr(kal_uint8 usb_ip_port, USB_HCD_STATUS result, kal_uint32 param);
+extern void USBD_Detach_Hdlr(kal_uint8 usb_ip_port, USB_HCD_STATUS result, kal_uint32 param);
+extern void USBD_Suspend_Hdlr(kal_uint8 usb_ip_port, USB_HCD_STATUS result, kal_uint32 param);
+extern USBD_HNP_SUPPORT_TYPE USBD_Get_HNP_Support(kal_uint8 usb_ip_port);
+extern kal_bool USBD_Is_Match_Hub(kal_uint8 usb_ip_port);
+extern void ICUSB_Drv_Init(void);
+extern void USBD_Register_Port_Info(kal_uint8 usb_ip_port, kal_bool b_is_ext_ip);
+
+// Class layer usage API
+extern void USBD_Clear_Feature(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str,kal_bool b_is_from_class_drv, usbd_ep0_callback callback);
+extern void USBD_Start_Setup_Cmd(USBH_Common_Struct common_str, Usb_Command *usbd_cmd, kal_uint8* data_ptr, USBD_EP0_DATA_DIR direction, kal_uint32 length, kal_bool b_is_from_class_drv, usbd_ep0_callback callback);
+extern kal_bool USBD_Send_Req(USBH_Common_Struct common_str,USBH_EP_Struct ep_str, kal_uint16 nBytes, void *pSrc);
+extern kal_bool USBD_Recv_Req(USBH_Common_Struct common_str,USBH_EP_Struct ep_str, kal_uint16 nBytes, void *pDst);
+extern void USBD_Suspend_Req(USBH_Common_Struct common_str);
+extern void USBD_Reset_Req(USBH_Common_Struct common_str);
+extern void USBD_Register_Drv_Info(USBH_Common_Struct common_str,USB_HCD_HDLR_TYPE type, USBH_EP_Struct usb_ep_str, usb_hcd_intr_handler_ptr hdlr);
+extern kal_uint8 USBD_HW_Mapping_EP(USBH_Common_Struct common_str,USB_EP_DIRECTION direction);
+extern void USBD_Dis_Attach(USBH_Common_Struct common_str);
+extern void USBD_En_Attach(USBH_Common_Struct common_str);
+extern void USBD_Config_TxEP_Type(USBH_Common_Struct common_str,USBH_EP_Struct ep_str,kal_bool b_is_switch_to_dma);
+extern void USBD_Config_RxEP_Type(USBH_Common_Struct common_str,USBH_EP_Struct ep_str,kal_bool b_is_switch_to_dma);
+extern void USBD_EP_Interval(USBH_Common_Struct common_str,USBH_EP_Struct ep_str,kal_uint8 interval);
+extern void USBD_RxEPInit(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str);
+extern void USBD_TxEPInit(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str);
+extern void USBD_RxEPEn(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_uint8 interval, kal_bool bDMA);
+extern void USBD_TxEPEn(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_uint8 interval, kal_bool bDMA);
+extern void USBD_TxEPDis(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_bool bDMA);
+extern void USBD_RxEPDis(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_bool bDMA);
+extern void USBD_EPFIFORead(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_uint16 nBytes, void *pDst);
+extern void USBD_EPFIFOWrite(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str, kal_uint16 nBytes, void *pDst);
+extern kal_uint16 USBD_EP0_Data_Length(USBH_Common_Struct common_str);
+extern kal_uint32 USBD_EP_Rx_Pkt_Len(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str);
+extern void USBD_Clear_Data01(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str);
+extern void USBD_Get_DMA_Channel(USBH_Common_Struct common_str,USBH_EP_Struct usb_tx_str, USBH_EP_Struct usb_rx_str, USB_EP_DIRECTION direction, kal_bool same_chan);
+extern void USBD_Free_DMA_Channel(USBH_Common_Struct common_str,USBH_EP_Struct usb_tx_str, USBH_EP_Struct usb_rx_str, USB_EP_DIRECTION direction, kal_bool same_chan);
+extern void USBD_DMA_Setup(USBH_Common_Struct common_str,USBH_EP_Struct ep_str,kal_uint32 addr, kal_uint32 length,usb_dma_callback callback,kal_bool callback_upd_run, kal_bool known_size, USB_DMA_TYPE dma_type);
+extern void USBD_Set_EP_Max_Pkt(USBH_Common_Struct common_str,USBH_EP_Struct usb_ep_str);
+extern kal_bool USBD_Get_UnMask_Irq(USBH_Common_Struct common_str);
+extern kal_bool USBD_Is_High_Speed(USBH_Common_Struct common_str);
+extern void USBD_VBusEnable(USBH_Common_Struct common_str,kal_bool enable);
+extern kal_bool USBD_Bootup_Mode(void);
+
+
+#endif /* USBD_H*/
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbimage_drv.h b/mcu/driver/connectivity/usb_class/include/usbimage_drv.h
new file mode 100644
index 0000000..f110541
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbimage_drv.h
@@ -0,0 +1,627 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbimage_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb IMAGE class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBIMAGE_DRV_H
+#define USBIMAGE_DRV_H
+
+#include "usb_adap.h"
+#include "usb.h"
+#include "usb_custom.h"
+#include "usb_msdisk.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+#include "kal_general_types.h"
+#include "usb_custom_def.h"
+
+
+
+/***********************************************
+ image class specific command definition
+************************************************/
+#define USB_IMAGE_DEVICE_CODE 0x00
+#define USB_IMAGE_SUBCLASS_CODE 0x00
+#define USB_IMAGE_PROTOCOL_CODE 0x00
+#define USB_IMAGE_INTERFACE_CLASS_CODE 0x06
+#define USB_IMAGE_INTERFACE_SUBCLASS_CODE 0x01
+#define USB_IMAGE_INTERFACE_PROTOCOL_CODE 0x01
+
+/* Class-Specific Requset Code, EP0 command*/
+#define USB_IMAGE_CANCEL 0x64
+#define USB_IMAGE_GET_EXTENDED_EVENT_DATA 0x65
+#define USB_IMAGE_RESET 0x66
+#define USB_IMAGE_GET_DEVICE_STATUS 0x67
+
+/* Class-Specific Container Type */
+#define USB_IMAGE_UNDEFINED 0x00
+#define USB_IMAGE_COMMAND_BLOCK 0x01
+#define USB_IMAGE_DATA_BLOCK 0x02
+#define USB_IMAGE_RESPONSE_BLOCK 0x03
+#define USB_IMAGE_EVENT_BLOCK 0x04
+
+/***********************************************
+ Implement definition
+************************************************/
+#define USB_IMAGE_EP_NUMBER 3
+
+
+/* For PTP */
+//#define USB_IMAGE_PTP_MAX_BUFFERSIZE (2*1024)
+#define USB_IMAGE_PTP_MAX_BUFFERSIZE (28*1024)
+#define USB_IMAGE_PTP_MAX_TX_BUFFERSIZE (USB_IMAGE_PTP_MAX_BUFFERSIZE/2)
+//#define USB_IMAGE_PTP_MAX_RX_BUFFERSIZE (USB_IMAGE_PTP_MAX_BUFFERSIZE/2)
+
+#define USB_IMAGE_PTP_MAX_XMLBUFFERSIZE (1024)
+#define USB_IMAGE_PTP_MAX_XMLHREQUESTSIZE (1040)
+#define USB_IMAGE_PTP_MAX_XMLHRSPONSESIZE (1008)
+
+#define USB_IMAGE_PTP_MAX_OBJECT_INFO (1024)
+/* For start job XML buffer */
+#define USB_IMAGE_PTP_MAX_START_JOB_XMLBUFFERSIZE (USB_IMAGE_PTP_MAX_BUFFERSIZE + USB_IMAGE_PTP_MAX_XMLBUFFERSIZE - USB_IMAGE_PTP_MAX_OBJECT_INFO)
+
+
+/* For MTP */
+#define USB_IMAGE_MTP_MAX_TX_BUFFERSIZE (USB_IMAGE_MTP_MAX_BUFFERSIZE/2)
+#define USB_IMAGE_MTP_MAX_RX_BUFFERSIZE (USB_IMAGE_MTP_MAX_BUFFERSIZE/2)
+
+
+
+
+#define USB_IMAGE_CONTAINER_LENGTH 12
+#define USB_IMAGE_RES_1_PARA 16
+#define USB_IMAGE_RES_3_PARA 24
+#define USB_IMAGE_RES_5_PARA 32
+
+/* Interrupt packet buffer */
+#define USB_IMAGE_MAX_INTERRUPT_PKT 5
+
+
+/***********************************************
+ Implement enum and structure
+************************************************/
+typedef struct
+{
+ kal_uint32 ContainerLength;
+ kal_uint16 ContainerType;
+ kal_uint16 Code;
+ kal_uint32 TransactionID;
+ kal_uint32 Parameter1;
+ kal_uint32 Parameter2;
+ kal_uint32 Parameter3;
+#ifdef __MTP_ENABLE__
+ kal_uint32 Parameter4;
+ kal_uint32 Parameter5;
+#endif
+}USB_IMAGE_CONTAINER;
+
+
+typedef struct
+{
+ kal_uint32 ContainerLength;
+ kal_uint16 ContainerType;
+ kal_uint16 Code;
+ kal_uint32 TransactionID;
+}USB_IMAGE_CONTAINER_HEADER;
+
+
+typedef struct
+{
+ kal_uint32 ContainerLength;
+ kal_uint16 ContainerType;
+ kal_uint16 Code;
+ kal_uint32 TransactionID;
+ kal_uint32 Parameter1;
+}USB_IMAGE_EVENT_CONTAINER;
+
+
+typedef enum
+{
+ /* msg from USB to MMI */
+ USB_IMAGE_MSG_MMI_DISCOVERY_IND,
+ USB_IMAGE_MSG_MMI_HREQUEST_IND,
+ USB_IMAGE_MSG_MMI_HRESPONSE_IND,
+ USB_IMAGE_MSG_MMI_DREQUEST_CONF,
+ USB_IMAGE_MSG_MMI_DRESPONSE_CONF,
+// USB_IMAGE_MSG_MMI_CONNECT_TO_PC_IND,
+ USB_IMAGE_MSG_MMI_OPEN_FILE_FAIL_IND,
+ USB_IMAGE_MSG_MMI_HOST_RESET_IND
+}USB_IMAGE_MSG_TYPE;
+
+
+typedef enum
+{
+ /* msg from USB to MTP */
+ USB_MTP_IMAGE_MSG_ENABLE_REQ,
+ USB_MTP_IMAGE_MSG_DISABLE_REQ,
+ USB_MTP_IMAGE_MSG_OPERATION_REQ,
+ USB_MTP_IMAGE_MSG_HOST_ABORT_IND,
+// USB_MTP_IMAGE_MSG_DEVICE_ABORT_IND,
+// USB_MTP_IMAGE_MSG_HOST_CANCEL_IND,
+ USB_MTP_IMAGE_MSG_HOST_SUSPEND_IND
+// USB_MTP_IMAGE_MSG_HOST_RESET_IND
+}USB_MTP_IMAGE_MSG_TYPE;
+
+
+typedef struct {
+ LOCAL_PARA_HDR
+ kal_uint8 *xml_address; /* address of xml packet*/
+ kal_uint32 xml_packet_size; /*xml packet size*/
+}usb_image_xml_struct;
+
+
+typedef struct {
+ LOCAL_PARA_HDR
+ kal_uint8 *dps_xml_request_address; /* address of xml packet*/
+ kal_uint32 dps_xml_request_buffer_size;
+ kal_uint32 dps_xml_start_job_buffer_size;
+ kal_uint8 *dps_xml_response_address;
+ kal_uint32 dps_xml_response_buffer_size;
+}usb_mmi_dps_discovery_ind_struct;
+
+
+typedef struct {
+ LOCAL_PARA_HDR
+ kal_uint32 rx_data_size;
+}usb_ptpimage_data_rx_done_conf_struct, usb_mtpimage_data_rx_done_conf_struct;
+
+
+typedef struct
+{
+ kal_uint8 data_buffer[2][USB_IMAGE_PTP_MAX_BUFFERSIZE/2];
+}USB_IMAGE_PTP_BUFFER;
+
+
+typedef struct
+{
+ kal_uint8 data_buffer[2][USB_IMAGE_MTP_MAX_BUFFERSIZE/2];
+}USB_IMAGE_MTP_BUFFER;
+
+
+typedef struct
+{
+ kal_uint16 Cancellation_Code;
+ kal_uint16 TransactionID[2];
+}USB_IMAGE_BLOCK_STRUCT;
+
+typedef struct
+{
+ kal_uint16 wLength;
+ kal_uint16 Code;
+ kal_uint32 TxEndPoint;
+ kal_uint32 RxEndPoint;
+}USB_IMAGE_DEVICE_STATUS_STRUCT;
+
+
+typedef enum
+{
+ USB_IMAGE_CMD_RX = 0, /* Initial Idle Phase, Receive Command */
+ USB_IMAGE_DATA_TX, /* Transmit Data Phase */
+ USB_IMAGE_DATA_RX, /* Receive Data Phase */
+ USB_IMAGE_RESPONSE /* Transmit Response phase */
+}USB_IMAGE_STATE;
+
+
+typedef enum
+{
+ IMAGE_INTR_IDLE = 0,
+ IMAGE_INTR_SEND_ONE_PKT,
+ IMAGE_INTR_SEND_TWO_PKT,
+ IMAGE_INTR_SEND_LAST_PKT
+}USB_IMAGE_INTR_PIPE_STATE;
+
+
+typedef enum
+{
+ IMAGE_MTP_DISABLE = 0,
+// IMAGE_MTP_DEVICE_ABORT,
+ IMAGE_MTP_HOST_CANCEL, /* When USB receive ep0 cancel command, USB will enter this state,
+ and exit this state to enable when USB receive MTP send the event msg */
+ IMAGE_MTP_HOST_SUSPEND, /* Only USB is waiting for MTP's request response and target receive suspend signal, USB will enter this state,
+ and exit this state to enable when USB receive MTP send the event msg, too. */
+ IMAGE_MTP_ENABLE /* state is enable after MTP response the enable request */
+}USB_IMAGE_MTP_STATE;
+
+
+typedef struct
+{
+ USB_IMAGE_STATE state; /* USB image class state machine */
+ USB_IMAGE_INTR_PIPE_STATE intr_state; /* interrupt pipe state machine */
+ Usb_EpBIn_Status *txpipe;
+ Usb_EpBOut_Status *rxpipe;
+ Usb_EpBIn_Status *intrpipe;
+
+ Usb_Ep_Info *image_ep_in_info;
+ Usb_Ep_Info *image_ep_out_info;
+ Usb_Ep_Info *image_ep_intr_info;
+ Usb_Interface_Info *image_if_info;
+
+ /* the PTP container */
+ USB_IMAGE_CONTAINER image_cmd;
+// USB_IMAGE_CONTAINER image_response;
+ USB_IMAGE_EVENT_CONTAINER image_event;
+
+#ifdef PICTBRIDGE_SUPPORT
+ /* buffer for data/image transmission operation*/
+ USB_IMAGE_PTP_BUFFER *image_buffer;
+
+ /* buffer for data/image's info transmission operation */
+ kal_uint8 *image_info_buffer;
+#endif
+
+#ifdef __MTP_ENABLE__
+ /* buffer for data/image transmission operation*/
+ USB_IMAGE_MTP_BUFFER *mtp_image_buffer;
+
+ /* message content for data phase */
+ kal_uint32 data_total_size; /* size of total data, 0 means no Data phase */
+ kal_uint8 *data_pool_ptr; /* data pool */
+ kal_uint32 data_pool_size; /* size of data pool */
+ kal_uint32 data_size; /* size of real data */
+
+ kal_bool b_is_first_rsp; /* a flag to check if it is the first rsp msg from MTP task */
+
+ kal_bool b_is_mtp_abnormal_msg; /* a flag to check if there is a abnormal (result is not OK) msg from MTP task */
+#endif
+
+ /* Image class ep0 cmd structure */
+ USB_IMAGE_BLOCK_STRUCT cancel_block;
+ USB_IMAGE_DEVICE_STATUS_STRUCT device_status;
+
+ USB_IMAGE_EVENT_CONTAINER image_event_array[USB_IMAGE_MAX_INTERRUPT_PKT];
+
+ kal_uint32 current_transactionID;
+ kal_uint32 total_rx_bytes; /* total RX data phase length with 12 bytes header (PTP only) */
+ kal_uint32 current_rx_bytes; /* current RX data phase length with 12 bytes header (PTP only) */
+ kal_uint32 total_tx_bytes; /* total TX data phase length with 12 bytes header (PTP only) */
+ kal_uint32 current_tx_bytes; /* current TX data phase length with 12 bytes header (PTP only) */
+#ifdef PICTBRIDGE_SUPPORT
+ kal_uint8 rw_buffer_index; /* buffer index for double buffer */
+#endif
+#ifdef __MTP_ENABLE__
+ USB_IMAGE_MTP_STATE mtp_state;
+ kal_uint32 buffer_rw_bytes[2]; /* buffer data load for double buffer, no header */
+ kal_uint8 buffer_read_index; /* buffer read index for double buffer */
+ kal_uint8 buffer_write_index; /* buffer write index for double buffer */
+ kal_bool b_wait_enable_rsp;
+ kal_bool b_wait_disable_rsp;
+ kal_bool b_wait_req_rsp;
+ kal_bool b_is_pending_disable_mtp_msg; /* pending disable mtp due to MTP does not response enable request */
+ kal_bool b_delay_disable_mtp_msg_for_req; /* delay to disable mtp due to MTP is processing a request and USB go into suspend state */
+ kal_bool b_mtp_release_type; /* MTP is disabled due to cable out */
+ kal_bool b_mtp_stop_type; /* MTP is disabled due to user wants to stop */
+ kal_bool b_delay_mtp_stop_config; /* a flag to delay disable MTP in USB boot mode when USB receives STOP_MTP msg */
+ kal_bool b_host_suspend; /* When suspend, USB will send a close session operation to MTP task automatically.
+ This flag is to prevent that USB task handles this close session response msg from MTP due to suspend */
+ kal_bool b_device_cancel; /* When RX cmd, user may hot plug out the memory card, so USB can not continue to receive data.
+ USB will send stall to host, and set this flag to response MTP_TRANSACTION_CANCELLED
+ when PC send USB_IMAGE_GET_DEVICE_STATUS ep0 cmd */
+#endif
+ kal_uint8 intr_read_ptr;
+ kal_uint8 intr_write_ptr;
+
+// kal_bool host_cancel_flag; /* a flag for ep0 get device status cmd to return response code */
+ kal_bool send_usb_image_reset_ilm; /* a flag to check whether it needs to send the reset message */
+ kal_bool usb_reset;
+ kal_bool image_ep0_reset;
+
+ kal_bool usb_image_stop; /* Upper layer is slower than USB task, if user plug cable in/out quickly,
+ USB task's state machine will not sync with upper layer.
+ Use this flag to let USB task wait for upper layer */
+ kal_bool is_suspend_state;
+ kal_bool is_session_open;
+
+#ifdef PICTBRIDGE_SUPPORT
+ /* Customizable variables */
+ const USB_IMAGE_PARAM *image_param;
+#endif
+#ifdef __MTP_ENABLE__
+ /* Customizable variables */
+ const USB_MTP_IMAGE_PARAM *mtp_image_param;
+#endif
+}USBImage_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern USBImage_Struct g_USBImage;
+extern USB_IMAGE_CONTAINER g_USB_Image_Response;
+
+extern void USB_Image_Copy_Unicode_String(kal_uint8 *pdest, const kal_uint16 *source_string, kal_uint8 string_num);
+extern void USB_Image_If_Create(void *ifname);
+extern void USB_Image_If_Reset(void);
+extern void USB_Image_If_Enable(void);
+extern void USB_Image_If_Speed_Reset(kal_bool b_other_speed);
+extern void USB_Init_Image_Status(void);
+#ifdef PICTBRIDGE_SUPPORT
+extern void USB_Init_PTP_Status(void);
+#endif
+#ifdef __MTP_ENABLE__
+extern void USB_Init_MTP_Status(void);
+#endif
+extern void USB_Release_Image_Status(void);
+#ifdef __MTP_ENABLE__
+extern void USB_Release_MTP_Status(void);
+#endif
+
+extern void USB_Image_Suspend_Hdlr(void);
+extern void USB_Image_Reset_Hdlr(void);
+#ifdef PICTBRIDGE_SUPPORT
+extern void USB_Image_Reset_PTP_Hdlr(void);
+#endif
+extern void USB_Image_BuildRx(void *addr, kal_uint32 len);
+extern void USB_Image_BuildTx(void *addr, kal_uint32 len);
+extern void USB_Image_ReturnTx(void *addr, kal_uint32 len);
+extern void USB_Send_Null_Packet(kal_uint8 no);
+#ifdef __MTP_ENABLE__
+extern void USB_Send_Header_Packet(kal_uint8 ep_num, void *pSrc);
+extern kal_uint16* USB_MTP_Image_Get_Storage_Description_String_1_Ptr(void);
+extern kal_uint16* USB_MTP_Image_Get_Storage_Description_String_2_Ptr(void);
+#endif
+extern void USB_Image_Send_Intr(void);
+extern void USB_Image_Cancel_By_Device(void);
+extern void USB_Image_Send_Msg(USB_IMAGE_MSG_TYPE usb_msg_type);
+extern void USB_MTP_Image_Send_Msg(USB_MTP_IMAGE_MSG_TYPE usb_msg_type);
+
+
+#endif /* USBIMAGE_DRV_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbimage_mtp_state.h b/mcu/driver/connectivity/usb_class/include/usbimage_mtp_state.h
new file mode 100644
index 0000000..8f58ff6
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbimage_mtp_state.h
@@ -0,0 +1,423 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+* A. Patent Notice:
+* The software delivered hereunder, including any and all updates and upgrades,
+* might be subject to patent rights of standard-setting organizations, patent pools
+* or their respective patent owners, that will be necessarily infringed by the use
+* and distribution of the products incorporating all or part of this software.
+* According to the licensing terms of these patent holders, it is your sole
+* obligation to obtain the necessary patent licenses from these patent holders
+* before you can use or distribute the products incorporating all or part of this
+* software. MediaTek shall not be liable for your failure to obtain or maintain such
+* licenses.
+*
+* As a courtesy to our customers, the following are some of the software that might
+* contain such patent licenses, but MediaTek does not warrant the accuracy or
+* completeness of the information below.
+* (1) MPEG4/AAC/AACPLUS/AACVPLUSV2: essential patents license must be obtained
+* from Via Licensing: <www.vialicensing.com>
+* (2) WAP/MMS security RC5 algorithm belongs to RSA Data Security:
+* <www.rsasecurity.com>
+* Notice: Please contact RSA to get this license before shipping the products to
+* USA which include RC5 security algorithm.
+*
+* B. In addition, customers must contact the respective licensors to obtain
+* necessary software licenses before it can use or distribute the licensed
+* products.
+*
+* As a courtesy to our customers, the following are some of the software licensers
+* and the notice or disclaimer required by their licenses, but MediaTek does not
+* warrant the accuracy or completeness of the information below.
+* (1) Microsoft Windows Media (WMA software):
+* Microsoft: <www.microsoft.com>
+* Approved OEM Manufacturers: <wmlicense.smdisp.net/oem_approved/>
+* Sample Windows Media Licensing Agreements:
+* <www.microsoft.com/windows/windowsmedia/licensing/agreements.aspx>
+* Notice in header or documentation: "This product is protected by certain
+* intellectual property rights of Microsoft and cannot be used or further
+* distributed without a license from Microsoft."
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbimage_mtp_state.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file implements the MEDIA TRANSFER PROTOCOL (MTP) definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USB_IMAGE_MTP_STATE_H
+#define USB_IMAGE_MTP_STATE_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usbimage_drv.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+
+
+/***********************************************
+ PTP/MTP specific command definitions
+************************************************/
+/* Operation Codes */
+#define MTP_GET_DEVICE_INFO 0x1001
+#define MTP_OPEN_SESSION 0x1002
+#define MTP_CLOSE_SESSION 0x1003
+#define MTP_GET_STORAGE_IDS 0x1004
+#define MTP_GET_STORAGE_INFO 0x1005
+#define MTP_GET_NUM_OBJECTS 0x1006
+#define MTP_GET_OBJECT_HANDLES 0x1007
+#define MTP_GET_OBJECT_INFO 0x1008
+#define MTP_GET_OBJECT 0x1009
+#define MTP_DELETE_OBJECT 0x100B
+#define MTP_SEND_OBJECT_INFO 0x100C
+#define MTP_SEND_OBJECT 0x100D
+
+#define MTP_FORMAT_STORE 0x100F
+#define MTP_RESET_DEVICE 0x1010
+#define MTP_SET_OBJECT_PROTECTION 0x1012
+
+#define MTP_GET_DEVICE_PROP_DESC 0x1014
+#define MTP_GET_DEVICE_PROP_VALUE 0x1015
+#define MTP_SET_DEVICE_PROP_VALUE 0x1016
+
+#define MTP_RESET_DEVICE_PROP_VALUE 0x1017
+
+#define MTP_GET_PARTIAL_OBJECT 0x101B
+
+/* MTP only */
+#define MTP_GET_OBJECT_PROPS_SUPPORTED 0x9801
+#define MTP_GET_OBJECT_PROP_DESC 0x9802
+#define MTP_GET_OBJECT_PROP_VALUE 0x9803
+#define MTP_SET_OBJECT_PROP_VALUE 0x9804
+
+#define MTP_GET_OBJECT_PROP_LIST 0x9805
+#define MTP_SET_OBJECT_PROP_LIST 0x9806
+#define MTP_GET_INTER_DEPENDENT_PROP_DESC 0x9807
+#define MTP_SEND_OBJECT_PROP_LIST 0x9808
+
+
+#define MTP_GET_OBJECT_REFERENCES 0x9810
+#define MTP_SET_OBJECT_REFERENCES 0x9811
+#define MTP_SKIP 0x9820
+
+
+/* DRM only */
+#define MTP_GET_SECURE_TIME_CHALLENGE 0x9101
+#define MTP_SET_SECURE_TIME_RESPONSE 0x9102
+#define MTP_SET_LICENSE_RESPONSE 0x9103
+#define MTP_GET_SYNC_LIST 0x9104
+#define MTP_SEND_METER_CHALLENGE_QUERY 0x9105
+#define MTP_GET_METER_CHALLENGE 0x9106
+#define MTP_SET_METER_RESPONSE 0x9107
+#define MTP_CLEAN_DATA_STORE 0x9108
+#define MTP_GET_LICENSE_STATE 0x9109
+#define MTP_DRM_CMD_1 0x910A
+#define MTP_DRM_CMD_2 0x910B
+#define MTP_DRM_CMD_3 0x9001
+#define MTP_DRM_CMD_4 0x9002
+
+
+
+
+/* Response Codes */
+#define MTP_OK 0x2001
+#define MTP_GENERAL_ERROR 0x2002
+#define MTP_SESSION_NOT_OPEN 0x2003
+#define MTP_OPERATION_NOT_SUPPORTED 0x2005
+#define MTP_PARAMETER_NOT_SUPPORTED 0x2006
+#define MTP_NO_THUMBNAIL_PRESENT 0x2010
+#define MTP_STORE_NOT_AVAILABLE 0x2013
+#define MTP_DEVICE_BUSY 0x2019
+#define MTP_SESSION_ALREADY_OPEN 0x201E
+#define MTP_TRANSACTION_CANCELLED 0x201F
+
+
+
+
+/* Event Codes */
+#define MTP_CANCEL_TRANSACTION 0x4001
+#define MTP_OBJECT_ADDED 0x4002
+#define MTP_OBJECT_REMOVED 0x4003
+#define MTP_STORE_ADDED 0x4004
+#define MTP_STORE_REMOVED 0x4005
+#define MTP_DEVICE_PROP_CHAGNED 0x4006
+#define MTP_OBJECT_INFO_CHAGNED 0x4007
+#define MTP_REQUEST_OBJECT_TRANSFER 0x4009
+#define MTP_DEVICE_RESET 0x400B
+#define MTP_STORAGE_INFO_CHANGED 0x400C
+
+
+/* Object Format Codes */
+#define MTP_UNDEFINED 0x3000
+#define MTP_ASSOCIATION 0x3001
+#define MTP_SCRIPT 0x3002
+#define MTP_DPOF 0x3006
+#define MTP_MP3 0x3009
+#define MTP_ASF 0x300C
+#define MTP_DEFINED 0x3800
+#define MTP_EXIF_JPEG 0x3801
+#define MTP_TIFF_EP 0x3802
+#define MTP_BMP 0x3804
+#define MTP_CIFF 0x3805
+#define MTP_GIF 0x3807
+#define MTP_JFIF 0x3808
+#define MTP_PNG 0x380B
+#define MTP_TIFF 0x380D
+#define MTP_TIFF_IT 0x380E
+#define MTP_WMA 0xB901
+#define MTP_WMV 0xB981
+#define MTP_ABSTRACT_AUDIO_ALBUM 0xBA03
+#define MTP_ABSTRACT_AUDIOVIDEO_PLAYLIST 0xBA05
+
+/* Device Properties Codes */
+#define MTP_BATTERY_LEVEL 0x5001
+#define MTP_DATE_TIME 0x5011
+#define MTP_SYNCHRONIZATION_PARTNER 0xD401
+#define MTP_DEVICE_FRIENDLY_NAME 0xD402
+#define MTP_VOLUME 0xD403
+#define MTP_DEVICELCON 0xD405
+#define MTP_SESSION_INITIATOR_VERSION_INFO 0xD406
+#define MTP_PLAYBACK_RATE 0xD410
+#define MTP_PLAYBACK_OBJECT 0xD411
+#define MTP_PLAYBACK_CONTAINER_INDEX 0xD412
+
+/* DRM only */
+#define MTP_SECURE_TIME 0xD101
+#define MTP_DEVICE_CERIFICATE 0xD102
+
+
+
+/* VenderExtensionID */
+#define MTP_VENDER_EXTENSION_ID_093 0x00000006
+#define MTP_VENDER_EXTENSION_ID_10 0xFFFFFFFF
+
+/* Functional Mode Values*/
+#define MTP_STANDARD_MODE 0x0000
+#define MTP_SLEEP_STATE 0x0001
+
+/* ObjectInfo ProtectionStatus Values*/
+#define MTP_NO_PROTECTION 0x0000
+#define MTP_READ_ONLY 0x0001
+
+/* Storage Types */
+#define MTP_FIXED_ROM 0x0001
+#define MTP_REMOVABLE_ROM 0x0002
+#define MTP_FIXED_RAM 0x0003
+#define MTP_REMOVABLE_RAM 0x0004
+
+/* File System Type Values */
+#define MTP_GENERIC_FLAT 0x0001
+#define MTP_GENERIC_HIERARCHICAL 0x0002
+#define MTP_DCF 0x0003
+
+/* StorageInfo AccessCapability Values */
+#define MTP_READ_WRITE 0x0000
+#define MTP_READ_ONLY_WITHOUT_DELETION 0x0001
+#define MTP_READ_ONLY_WITH_DELETION 0x0002
+
+/* Association Types */
+#define MTP_GENERIC_FOLDER 0x0001
+#define MTP_ALBUM 0x0002
+#define MTP_TIME_SEQUENCE 0x0003
+#define MTP_HORIZONTAL_PANORAMIC 0x0004
+#define MTP_VERTICAL_PANORAMIC 0x0005
+#define MTP_2D_PANORAMIC 0x0006
+#define MTP_ANCILLARY 0x0007
+
+/***********************************************
+ Implement definition
+************************************************/
+#define MTP_MAX_OPERATION_CODE_SIZE 21
+//#define MTP_MAX_OPERATION_CODE_SIZE 35
+
+#define MTP_MAX_EVENT_CODE_SIZE 4
+
+//#define MTP_MAX_DEVICE_PROPERTIES_SUPPORTED_SIZE 7
+#define MTP_MAX_DEVICE_PROPERTIES_SUPPORTED_SIZE 2
+
+//#define MTP_MAX_PLAYBACK_FORMAT_CODE_SIZE 7
+#define MTP_MAX_PLAYBACK_FORMAT_CODE_SIZE 2
+
+
+/***********************************************
+ Implement enum and structure
+************************************************/
+typedef struct
+{
+ kal_uint16 StandardVersion;
+ kal_uint16 VenderExtensionID[2];
+ kal_uint16 VenderExtensionVersion;
+ kal_uint8 VendorExtensionDescNum;
+ kal_uint8 VendorExtensionDescString[29][2];
+ kal_uint8 FunctionalMode[2];
+ kal_uint8 OperationsSupportedSize[4];
+ kal_uint8 OperationsSupported[MTP_MAX_OPERATION_CODE_SIZE][2];
+ kal_uint8 EventsSupportedSize[4];
+ kal_uint8 EventsSupported[MTP_MAX_EVENT_CODE_SIZE][2];
+ kal_uint8 DevicePropertiesSupportedSize[4];
+ kal_uint8 DevicePropertiesSupported[MTP_MAX_DEVICE_PROPERTIES_SUPPORTED_SIZE][2];
+ kal_uint8 CaptureFormatsSize[4]; /* empty array*/
+ kal_uint8 PlaybackFormatsSize[4];
+ kal_uint8 PlaybackFormats[MTP_MAX_PLAYBACK_FORMAT_CODE_SIZE][2];
+// kal_uint8 padding;
+}MTP_DeviceInfo_Struct;
+
+
+typedef struct
+{
+ kal_uint16 DevicePropertyCode;
+ kal_uint16 DataType;
+ kal_uint8 GetSet;
+}MTP_DeviceProperty_Struct;
+
+
+
+typedef struct
+{
+ kal_uint16 StorageType;
+ kal_uint16 FilesystemType;
+ kal_uint16 AccessCapability;
+ kal_uint16 MaxCapacity[4];
+ kal_uint16 FreeSpaceInBytes[4];
+ kal_uint16 FreeSpaceInImages[2];
+}MTP_StorageInfo_Struct;
+
+
+typedef struct
+{
+ kal_uint32 StorageID;
+ kal_uint16 ObjectFormat;
+ kal_uint16 ProtectionStatus;
+ kal_uint32 ObjectCompressedSize;
+ kal_uint16 ThumbFormat;
+ kal_uint16 ThumbCompressedSize[2];
+ kal_uint16 ThumbPixWidth[2];
+ kal_uint16 ThumbPixHeight[2];
+ kal_uint16 ImagePixWidth[2];
+ kal_uint16 ImagePixHeight[2];
+ kal_uint16 ImageBitDepth[2];
+ kal_uint16 ParentObject[2];
+ kal_uint16 AssociationType;
+ kal_uint32 AssociationDesc;
+ kal_uint32 SequenceNumber;
+}MTP_ObjectInfo_Struct;
+
+
+typedef struct
+{
+ /* PTP dataset structure */
+ MTP_DeviceInfo_Struct image_deviceinfo;
+ kal_bool is_wait_host_respone;
+}USB_IMAGE_MTP_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern USB_IMAGE_MTP_Struct g_MTPImage;
+extern USB_IMAGE_CONTAINER_HEADER g_USB_Image_Data_Header;
+
+extern kal_bool USB_MTP_Is_RX_Cmd(kal_uint16 cmd_code);
+
+extern void USB_MTP_Parse_MTP_Meg(ilm_struct *p_recv_ilm);
+extern void USB_MTP_Parse_MTP_Event_Meg(ilm_struct *p_recv_ilm);
+extern void USB_MTP_Parse_USB_Meg(ilm_struct *p_recv_ilm);
+
+
+#endif /* USB_IMAGE_MTP_STATE_H */
+
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbms_adap.h b/mcu/driver/connectivity/usb_class/include/usbms_adap.h
new file mode 100644
index 0000000..801fd63
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbms_adap.h
@@ -0,0 +1,137 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbms_adap.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb adaption layer for mass storage definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBMS_ADAP_H
+#define USBMS_ADAP_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usb_msdisk.h"
+#include "usbms_state.h"
+#include "fs_type.h"
+
+/***********************************************
+ function and global variable
+************************************************/
+
+#ifdef __USB_RAMDISK__
+extern USB_DiskDriver_STRUCT USB_RAM_drv;
+void FAT_Init(void);
+#endif
+
+/* translate fd type to usb dev type*/
+extern USB_STORAGE_DEV_TYPE USB_Ms_Trans_Fs_Type(FS_DEVICE_TYPE_ENUM type);
+extern kal_uint8 USB_Ms_Get_Max_LUN(void);
+
+
+extern USB_STORAGE_DEV_STATUS USB_Ms_Checkmedia_Exist(kal_uint8 LUN);
+extern kal_bool USB_Ms_Format(kal_uint8 LUN);
+extern kal_bool USB_Ms_Read_Capacity(kal_uint8 LUN, kal_uint32 *max_lba, kal_uint32 *sec_len);
+extern kal_bool USB_Ms_Read_FormatCapacity(kal_uint8 LUN, kal_uint32 *max_lba, kal_uint32 *sec_len);
+//extern kal_bool USB_Ms_Read(kal_uint8 LUN, void *data, kal_uint32 LBA, kal_uint16 sec_len);
+//extern kal_bool USB_Ms_Write(kal_uint8 LUN, void *data, kal_uint32 LBA, kal_uint16 sec_len);
+extern kal_bool USB_Ms_Read_Write(USB_MS_DIRECTION direct, kal_uint8 LUN, void *data, kal_uint32 LBA, kal_uint16 sec_len);
+extern kal_bool USB_Ms_Prevmedia_Removal(kal_uint8 LUN, kal_bool enable);
+extern USB_STORAGE_DEV_TYPE USB_Ms_Dev_Type(kal_uint8 LUN);
+
+#endif //USBMS_ADAP_H
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbms_drv.h b/mcu/driver/connectivity/usb_class/include/usbms_drv.h
new file mode 100644
index 0000000..9238600
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbms_drv.h
@@ -0,0 +1,470 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbms_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb MASS STORAGE class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBMS_DRV_H
+#define USBMS_DRV_H
+
+//#include "kal_non_specific_general_types.h"
+#include "usb_custom.h"
+#include "usb_msdisk.h"
+#include "usb.h"
+#include "usb_adap.h"
+#include "fs_type.h"
+#include "usb_custom_def.h"
+
+
+
+/***********************************************
+ ms class specific command definition
+************************************************/
+
+#define USB_MS_DEVICE_CODE 0x00
+#define USB_MS_SUBCLASS_CODE 0x00
+#define USB_MS_PROTOCOL_CODE 0x00
+#define USB_MS_INTERFACE_CLASS_CODE 0x08
+#define USB_MS_INTERFACE_SUBCLASS_CODE 0x06
+#define USB_MS_INTERFACE_SUBCLASS_CODE_2 0x05
+#define USB_MS_INTERFACE_PROTOCOL_CODE 0x50
+
+/*Class Requset Code, EP0 command*/
+#define USB_MS_RESET 0xff
+#define USB_MS_GETMAXLUN 0xfe
+
+/*Mass storage command*/
+#define USBMS_FORMAT_UNIT 0x04
+#define USBMS_INQUIRY 0x12
+#define USBMS_MODE_SENSE 0x5a
+#define USBMS_MODE_SENSE6 0x1a
+#define USBMS_MODE_SELECT 0x55
+#define USBMS_MODE_SELECT6 0x15
+#define USBMS_PREVALLOW_MEDIA_REMOVL 0x1e
+#define USBMS_READ10 0x28
+#define USBMS_READ12 0xa8
+#define USBMS_READ_FORMATCAPACITY 0x23
+#define USBMS_REQUESTSENSE 0x03
+#define USBMS_START_STOP_UNIT 0x1b
+#define USBMS_TEST_UNIT_READY 0x00
+#define USBMS_VERIFY 0x2f
+#define USBMS_WRITE10 0x2a
+#define USBMS_WRITE12 0xaa
+#define USBMS_READ_CAPACITY 0x25
+
+
+/*CD-ROM command*/
+#define USBMS_READ_TOC 0x43
+#define USBMS_READ_DISC_INFO 0X51
+
+/*Vendor Command*/
+#define USBMS_VENDOR_READ10 0xD0
+#define USBMS_VENDOR_WRITE10 0xD1
+#define USBMS_VENDOR_CMD 0xF0
+#define USBMS_VENDOR_CMD_SUB_SET 0x01
+#define USBMS_VENDOR_CMD_SUB_GET 0x02
+#define USBMS_VENDOR_CMD_SUB_META 0x03
+#define USBMS_VENDOR_CMD_SUB_SET_WIN 0x01
+#define USBMS_VENDOR_CMD_SUB_SET_MAC 0x02
+#define USBMS_VENDOR_CMD_SUB_SET_LINUX 0x03
+
+
+
+/***********************************************
+ implement definition
+************************************************/
+
+#define USB_MS_EP_NUMBER 2
+
+#define MAX_DISK_DRVER 4
+
+#define USBMS_DMA_TIMEOUT 480
+
+#define USBMS_MAX_SINGLE_BUFFERSIZE (USBMS_MAX_BUFFERSIZE/2)
+
+#define USBMS_TX_THREADHOLD (16*1024)
+
+#define USBMS_RX_MAX_SECTOR (USBMS_MAX_SINGLE_BUFFERSIZE/512)
+
+#if USBMS_MAX_SINGLE_BUFFERSIZE > USBMS_TX_THREADHOLD
+#define USBMS_TX_MAX_SECTOR (USBMS_TX_THREADHOLD/512)
+#else
+#define USBMS_TX_MAX_SECTOR (USBMS_MAX_SINGLE_BUFFERSIZE/512)
+#endif
+
+#define USBMS_READ_FAIL_TIMEOUT 50
+#define USBMS_VENDOR_CMD_TIMEOUT 50
+#define USBMS_UNKNOW_CMD_TIMEOUT 500
+
+#define USBMS_INVALID_MAX_LUN 0xFF
+
+/***********************************************
+ ms class specific descriptor structure
+************************************************/
+
+typedef struct
+{
+ kal_uint32 dCBWSignature;
+ kal_uint32 dCBWTag;
+ kal_uint32 dCBWDataTransferLength;
+ kal_uint8 bmCBWFlags;
+ kal_uint8 bCBWLUN;
+ kal_uint8 bCBWCBLength;
+ kal_uint8 CBWCB[16];
+} UsbMs_CBW;
+
+
+typedef struct
+{
+ kal_uint32 dCSWSignature;
+ kal_uint32 dCSWTag;
+ kal_uint32 dCSWDataResidue;
+ kal_uint8 bmCSWStatus;
+ kal_uint8 padding[3]; /* padding to multiple of 4*/
+} UsbMs_CSW;
+
+
+/***********************************************
+ implement enum and structure
+************************************************/
+
+/*Mass storage state*/
+typedef enum
+{
+ USBMS_IDLE = 0, /*Receive Command*/
+ USBMS_RX, /*Receive Data*/
+ USBMS_TX, /*Transmit Data*/
+ USBMS_ACK /*Transmit Data*/
+// USBMS_GETNEXTCMD,
+// USBMS_RESET_STATE
+}USBMS_STATE;
+
+
+/* read capacity command structure */
+typedef struct
+{
+ kal_uint32 LastBA; /*depend on the target*/
+ kal_uint32 BlkLen; /*512*/
+} Read_Capacity_Info;
+
+
+/* maintain read/write status */
+typedef struct
+{
+ kal_uint32 LBA; /*Logical block address*/
+ kal_uint32 BlkLen; /*512*/
+ kal_uint32 rwindex; /*if (rwindex==BlkLen) transation done.*/
+ kal_uint32 msdc_rwindex;
+ kal_bool rw_error_status;
+ kal_uint8 rw_buffer_index;
+} UsbMs_RW_Cmd;
+
+
+typedef struct
+{
+ kal_uint8 ms_buffer[2][USBMS_MAX_SINGLE_BUFFERSIZE];
+}Usb_Disk_Buffer;
+
+
+typedef struct
+{
+ USBMS_STATE nState;
+ kal_bool cbw_is_vaild;
+ kal_bool ms_is_reset; /* USB ep0 receive reset cmd */
+ kal_bool usb_reset; /* USB receive reset signal */
+ kal_bool ms_read_write_reset; /* USB bus reset vaule=True, After READ/WRITE10(12) = False */
+ kal_uint8 max_LUN;
+ kal_uint8 current_LUN;
+ kal_bool is_send_usb_reset_ilm; /* avoid to send reset messages too many times */
+ kal_bool power_off_state[MAX_DISK_DRVER];
+ kal_bool prev_write_fail[MAX_DISK_DRVER];
+
+#ifdef __USB_OTG_RX_TEST__
+ kal_bool device_ms_rx_test_flag;
+#endif
+#ifdef __USB_OTG_TX_TEST__
+ kal_bool device_ms_tx_test_flag;
+#endif
+ kal_uint8 CSWStatusError;
+ kal_uint32 CSWDataResidue;
+
+ Usb_EpBIn_Status *txpipe;
+ Usb_EpBOut_Status *rxpipe;
+ kal_uint32 CBWdata[32/4];
+// UsbMs_CSW CSW;
+ UsbMs_RW_Cmd rw_cmd;
+
+ Usb_Ep_Info *ms_ep_in_info;
+ Usb_Ep_Info *ms_ep_out_info;
+ Usb_Interface_Info *ms_if_info;
+ kal_uint8 *sensePtr;
+
+
+// kal_uint8 dma_timeout_handle; /* DMA time out timer */
+
+
+ /* buffer for read/write operation*/
+ Usb_Disk_Buffer *disk_buffer;
+
+ /* customizable variables*/
+ const USB_MS_PARAM *ms_param;
+
+#ifdef __P_PROPRIETARY_COPYRIGHT__
+ kal_bool b_read_protect;
+ kal_uint32 *read_protect_items;
+ kal_uint32 *read_protect_second_items;
+ kal_uint32 *read_protect_index;
+ kal_uint32 *read_protect_second_index;
+ kal_uint32 read_protect_num;
+ USB_STORAGE_DEV_TYPE read_protect_dev_type;
+#endif
+
+// kal_bool b_ms_first_plugin; /*whether it is first plug in or not in ms mode */
+} UsbMs_Struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern UsbMs_Struct g_UsbMS;
+
+extern void USB_Ms_BuildRx(void *addr,kal_uint32 len);
+extern void USB_Ms_BuildTx(void *addr, kal_uint32 len);
+
+extern void USB_Ms_If_Create(void *ifname);
+extern void USB_Ms_If_Reset(void);
+extern void USB_Ms_If_Resume(void);
+
+extern void USB_Ms_If_Enable(void);
+extern void USB_Ms_If_Speed_Reset(kal_bool b_other_speed);
+
+extern void USB_Init_Ms_Status(void);
+extern void USB_Release_Ms_Status(void);
+
+#endif /* USBMS_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbms_state.h b/mcu/driver/connectivity/usb_class/include/usbms_state.h
new file mode 100644
index 0000000..8c87852
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbms_state.h
@@ -0,0 +1,152 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbms_state.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb mass storage state machine definitions
+ *
+ * Author:
+ * -------
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBMS_STATE_H
+#define USBMS_STATE_H
+
+//#include "stack_common.h"
+//#include "stack_msgs.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+
+#define USBMS_DIR_OUT 0x00
+#define USBMS_DIR_IN 0x80
+
+typedef enum
+{
+ USB_MS_ERROR_OK = 0,
+ USB_MS_ERROR_RX_GETNEXTCMD,
+ USB_MS_ERROR_RX_ACK,
+ USB_MS_ERROR_RX_TX,
+ USB_MS_ERROR_TX_IDLE,
+ USB_MS_ERROR_TX_RX
+} USB_MS_ERROR;
+
+typedef enum
+{
+ USB_MS_READ = 0,
+ USB_MS_WRITE
+} USB_MS_DIRECTION;
+
+//extern void USB_Ms_State_Main(ilm_struct *p_recv_ilm, kal_bool b_cable_plugin);
+extern void USB_Ms_State_Main(ilm_struct *p_recv_ilm);
+extern void USB_Ms_Cmd(void *data);
+
+#ifdef __P_PROPRIETARY_COPYRIGHT__
+extern void USB_Ms_Sort_Protect_Items(kal_uint32* data_item, kal_uint32* second_data_item);
+#endif
+
+#endif // USBMS_STATE_H
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbvideo_drv.h b/mcu/driver/connectivity/usb_class/include/usbvideo_drv.h
new file mode 100644
index 0000000..4c8aab7
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbvideo_drv.h
@@ -0,0 +1,857 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbvideo_drv.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb video class driver definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBVIDEO_DRV_H
+#define USBVIDEO_DRV_H
+
+
+#include "usbvideo_custom.h"
+#include "usbvideo_if.h"
+//#include "kal_non_specific_general_types.h"
+#include "usb.h"
+#include "usb_custom.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+#include "cal_comm_def.h"
+#include "cal_api.h"
+#include "mm_comm_def.h"
+
+//#define WEBCAM_TEST_DMA_DELAY
+
+
+/***********************************************
+ video class specific command definition
+************************************************/
+
+/* device descriptor parameter */
+#define USBVIDEO_DEVICE_CODE 0xEF
+#define USBVIDEO_SUBCLASS_CODE 0x02
+#define USBVIDEO_PROTOCOL_CODE 0x01
+
+/*Scriptor length*/
+#define USBVIDEO_VC_INTERFACE_LENGTH 13
+#define USBVIDEO_VC_CT_LENGTH 17
+#define USBVIDEO_VC_OT_LENGTH 9
+#define USBVIDEO_VC_PU_LENGTH 11
+//#define USBVIDEO_VC_PU_LENGTH 12 /* for 1.1 version*/
+#define USBVIDEO_VC_INTR_LENGTH 5
+
+#define USBVIDEO_VS_INTERFACE_LENGTH 14
+#define USBVIDEO_VS_MJPEG_FORMAT_LENGTH 11
+#define USBVIDEO_VS_MJPEG_FRAME_LENGTH 38
+#define USBVIDEO_VS_STILL_LENGTH 6
+#define USBVIDEO_VS_COLOR_MATCHING_LENGTH 6
+
+/* video interface class code */
+#define USBVIDEO_CC_VIDEO 0x0e
+
+/* video interface subclass code */
+#define USBVIDEO_SC_UNDEFINED 0x00
+#define USBVIDEO_SC_VIDEOCONTROL 0x01
+#define USBVIDEO_SC_VIDEOSTREAMING 0x02
+#define USBVIDEO_SC_VIDEO_INTERFACE_COLLECTION 0x03
+
+/* video interface protocol code */
+#define USBVIDEO_PC_PROTOCOL_UNDEFINED 0x00
+
+/* class specific descriptor types*/
+#define USBVIDEO_CS_UNDEFINED 0x20
+#define USBVIDEO_CS_DEVICE 0x21
+#define USBVIDEO_CS_CONFIGURATION 0x22
+#define USBVIDEO_CS_STRING 0x23
+#define USBVIDEO_CS_INTERFACE 0x24
+#define USBVIDEO_CS_ENDPOINT 0x25
+
+/* class specifiv VC interface descriptor subtypes*/
+#define USBVIDEO_VC_DESCRIPTOR_UNDEFINED 0x00
+#define USBVIDEO_VC_HEADER 0x01
+#define USBVIDEO_VC_INPUT_TERMINAL 0x02
+#define USBVIDEO_VC_OUTPUT_TERMINAL 0x03
+#define USBVIDEO_VC_SELECTOR_UNIT 0x04
+#define USBVIDEO_VC_PROCESSING_UNIT 0x05
+#define USBVIDEO_VC_EXTENSION_UNIT 0x06
+
+/* class specifiv VS interface descriptor subtypes*/
+#define USBVIDEO_VS_UNDEFINED 0x00
+#define USBVIDEO_VS_INPUT_HEADER 0x01
+#define USBVIDEO_VS_OUTPUT_HEADER 0x02
+#define USBVIDEO_VS_STILL_IMAGE_FRAME 0x03
+#define USBVIDEO_VS_FORMAT_UNCOMPRESSED 0x04
+#define USBVIDEO_VS_FRAME_UNCOMPRESSED 0x05
+#define USBVIDEO_VS_FORMAT_MJPEG 0x06
+#define USBVIDEO_VS_FRAME_MJPEG 0x07
+#define USBVIDEO_VS_FORMAT_MPEG1 0x08
+#define USBVIDEO_VS_FORMAT_MPEG2PS 0x09
+#define USBVIDEO_VS_FORMAT_MPEG2TS 0x0a
+#define USBVIDEO_VS_FORMAT_MPEG4SL 0x0b
+#define USBVIDEO_VS_FORMAT_DV 0x0c
+#define USBVIDEO_VS_COLORFORMAT 0x0d
+#define USBVIDEO_VS_FORMAT_VENDOR 0x0e
+#define USBVIDEO_VS_FRAME_VENDOR 0x0f
+
+/* USB terminal types */
+#define USBVIDEO_TT_VENDOR_SPECIFIC 0x0100
+#define USBVIDEO_TT_STREAMING 0x0101
+
+/* input terminal types */
+#define USBVIDEO_ITT_VENDOR_SPECIFIC 0x0200
+#define USBVIDEO_ITT_CAMERA 0x0201
+#define USBVIDEO_ITT_MEDIA_TANSPORT_INPUT 0x0202
+
+/* still image capture method */
+#define USBVIDEO_STILL_CAPTURE_METHOD_1 1
+#define USBVIDEO_STILL_CAPTURE_METHOD_2 2
+#define USBVIDEO_STILL_CAPTURE_METHOD_3 3
+
+/* hardware trigger usage*/
+#define USBVIDEO_HARDWARE_TRIGGER_NOT_SUPPORT 0
+#define USBVIDEO_HARDWARE_TRIGGER_SUPPORT 1
+#define USBVIDEO_HARDWARE_TRIGGER_STILL 0
+#define USBVIDEO_HARDWARE_TRIGGER_GENERAL 1
+
+/* MJPEG format descriptor param */
+#define USBVIDEO_FIXED_SIZE_SAMPLES 1
+
+/* request code */
+#define USBVIDEO_RC_UNDEFINED 0x00
+#define USBVIDEO_SET_CUR 0x01
+#define USBVIDEO_GET_CUR 0x81
+#define USBVIDEO_GET_MIN 0x82
+#define USBVIDEO_GET_MAX 0x83
+#define USBVIDEO_GET_RES 0x84
+#define USBVIDEO_GET_LEN 0x85
+#define USBVIDEO_GET_INFO 0x86
+#define USBVIDEO_GET_DEF 0x87
+
+/* VideoControl Interface Control Selectors */
+#define USBVIDEO_VC_CONTROL_UNDEFINED 0x00
+#define USBVIDEO_VC_VIDEO_POWER_MODE_CONTROL 0x01
+#define USBVIDEO_VC_REQUEST_ERROR_CODE_CONTROL 0x02
+
+/* RequestErrorCode */
+#define USBVIDEO_VC_REQUEST_ERROR_NO_ERROR 0x00
+#define USBVIDEO_VC_REQUEST_ERROR_NOT_READY 0x01
+#define USBVIDEO_VC_REQUEST_ERROR_WRONG_STATE 0x02
+#define USBVIDEO_VC_REQUEST_ERROR_POWER 0x03
+#define USBVIDEO_VC_REQUEST_ERROR_OUT_OF_RANGE 0x04
+#define USBVIDEO_VC_REQUEST_ERROR_INVALID_UNIT 0x05
+#define USBVIDEO_VC_REQUEST_ERROR_INVALID_CONTROL 0x06
+#define USBVIDEO_VC_REQUEST_ERROR_INVALID_REQUEST 0x07
+#define USBVIDEO_VC_REQUEST_ERROR_UNKNOWN 0xff
+
+/* videostreaming interface control selectors */
+#define USBVIDEO_VS_US_CONTROL_UNDEFINED 0x0000
+#define USBVIDEO_VS_PROBE_CONTROL 0x0100
+#define USBVIDEO_VS_COMMIT_CONTROL 0x0200
+#define USBVIDEO_VS_STILL_PROBE_CONTROL 0x0300
+#define USBVIDEO_VS_STILL_COMMIT_CONTROL 0x0400
+#define USBVIDEO_VS_STILL_IMAGE_TRIGGER_CONTROL 0x0500
+#define USBVIDEO_VS_STREAM_ERROR_CODE_CONTROL 0x0600
+#define USBVIDEO_VS_GENERATE_KEY_FRAME_CONTROL 0x0700
+#define USBVIDEO_VS_UPDATE_FRAME_SEGMENT_CONTROL 0x0800
+#define USBVIDEO_VS_SYNC_DELAY_CONTROL 0x0900
+
+/* payload header info offset */
+#define USBVIDEO_PAYLOAD_FRAME_ID 0
+#define USBVIDEO_PAYLOAD_EOF 1
+#define USBVIDEO_PAYLOAD_PTS 2
+#define USBVIDEO_PAYLOAD_SCR 3
+#define USBVIDEO_PAYLOAD_RESVD 4
+#define USBVIDEO_PAYLOAD_STILL 5
+#define USBVIDEO_PAYLOAD_ERR 6
+#define USBVIDEO_PAYLOAD_EOH 7
+
+/* the setting of still image trigger control */
+#define USBVIDEO_STILL_IMAGE_NORMAL_OPERATION 0
+#define USBVIDEO_STILL_IMAGE_TRANSMIT 1
+#define USBVIDEO_STILL_IMAGE_TRANSMIT_DEDICATED 2
+#define USBVIDEO_STILL_IMAGE_ABORT 3
+
+/* status type for status packet */
+#define USBVIDEO_STATUS_TYPE_RESERVED 0
+#define USBVIDEO_STATUS_TYPE_VC 1
+#define USBVIDEO_STATUS_TYPE_VS 2
+
+#define USBVIDEO_STATUS_VC_ATTRIBUTRE_CONTROL_VALUE_CHANGE 0x00
+#define USBVIDEO_STATUS_VC_ATTRIBUTRE_CONTROL_INFO_CHANGE 0x01
+#define USBVIDEO_STATUS_VC_ATTRIBUTRE_CONTROL_FAILURE_CHANGE 0x02
+
+#define USBVIDEO_STATUS_VS_EVENT_BUTTOM_PRS 0x00
+#define USBVIDEO_STATUS_VS_EVENT_STREAM_ERR 0x01
+
+#define USBVIDEO_STATUS_VS_VALUE_BUTTOM_REL 0x00
+#define USBVIDEO_STATUS_VS_VALUE_BUTTOM_PRS 0x01
+
+/* Attribute information(capability) offset*/
+#define USBVIDEO_ATTR_INFO_SUPPORT_GET 0
+#define USBVIDEO_ATTR_INFO_SUPPORT_SET 1
+#define USBVIDEO_ATTR_INFO_DISBALE 2
+#define USBVIDEO_ATTR_INFO_AUTO_UPDATE 3
+#define USBVIDEO_ATTR_INFO_ASYNC_CTRL 4
+
+/***********************************************
+ implement definition
+************************************************/
+
+#define USBVIDEO_VC_EP_NUMBER 1 /*interrupt pipe*/
+#define USBVIDEO_VS_EP_NUMBER 1
+
+#define USBVIDEO_IF_LENGTH 258
+#define USBVIDEO_IF_NUMBER 2
+
+
+#define USBVIDEO_CLOCK_FREQUENCY 1000
+
+#define USBVIDEO_CT_ID 1
+#define USBVIDEO_OT_ID 2
+#define USBVIDEO_PU_ID 3
+
+
+
+#define USB_VIDEO_EP_ISO_MAXP 512
+
+
+#define USBVIDEO_VIDEO_BUFFER_NUMBER 3
+
+#define USBVIDEO_PAYLOAD_HEADER_LENGTH 12
+
+#define USBVIDEO_MAX_ATTR_VALUE_SIZE 16
+
+/***********************************************
+ video class specific descriptor structure
+************************************************/
+/* class specific VC interface descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bcdUSB[2];
+ kal_uint8 wTotalLength[2];
+ kal_uint8 dwClockFrequency[4];
+ kal_uint8 bInCollection;
+ kal_uint8 baInterfaceNr;
+} USBVideo_Class_VC_If_Dscr;
+
+/* class specific VC input(camera) terminal descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bTerminalID;
+ kal_uint8 wTerminalType[2];
+ kal_uint8 bAssocTerminal;
+ kal_uint8 iTerminal;
+ kal_uint8 wObjectiveFocalLengthMin[2];
+ kal_uint8 wObjectiveFocalLengthMax[2];
+ kal_uint8 wOcularFocalLength[2];
+ kal_uint8 bControlSize;
+ kal_uint8 bmControls[2];
+} USBVideo_CT_Dscr;
+
+/* class specific VC output terminal descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bTerminalID;
+ kal_uint8 wTerminalType[2];
+ kal_uint8 bAssocTerminal;
+ kal_uint8 bSourceID;
+ kal_uint8 iTerminal;
+} USBVideo_OT_Dscr;
+
+/* class specific VC processing unit descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bUintID;
+ kal_uint8 bSourceID;
+ kal_uint8 wMaxMultiplier[2];
+ kal_uint8 bControlSize;
+ kal_uint8 bmControls[2];
+ kal_uint8 iProcessing;
+ //kal_uint8 bmVideoStandards;
+} USBVideo_PU_Dscr;
+
+
+/* class specific interrupt endpoint descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 wMaxTransferSize[2];
+} USBVideo_Intr_Ep_Dscr;
+
+
+/* class specific VS interface descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bNumFormats;
+ kal_uint8 wTotalLength[2];
+ kal_uint8 bEndpointAddress;
+ kal_uint8 bmInfo;
+ kal_uint8 bTerminalLink;
+ kal_uint8 bStillCaptureMethod;
+ kal_uint8 bTriggerSupport;
+ kal_uint8 bTriggerUsage;
+ kal_uint8 bControlSize;
+ kal_uint8 bmaControls;
+} USBVideo_Class_VS_If_Dscr;
+
+/* MJPEG video format descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bFormatIndex;
+ kal_uint8 bNumFrameDescriptors;
+ kal_uint8 bmFlags;
+ kal_uint8 bDefaultFrameIndex;
+ kal_uint8 bAspectRatioX;
+ kal_uint8 bAspectRatioY;
+ kal_uint8 bmInterlaceFlags;
+ kal_uint8 bCopyProtect;
+} USBVideo_MJPEG_Format_Dscr;
+
+/* MJPEG video frame descriptor */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bFrameIndex;
+ kal_uint8 bmCapabilities;
+ kal_uint8 wWidth[2];
+ kal_uint8 wHeight[2];
+ kal_uint8 dwMinBitRate[4];
+ kal_uint8 dwMaxBitRate[4];
+ kal_uint8 dwMaxVideoFrameBufferSize[4];
+ kal_uint8 dwDefaultFrameInterval[4];
+ kal_uint8 bFrameIntervalType;
+ kal_uint8 dwMinFrameInterval[4];
+ kal_uint8 dwMaxFrameInterval[4];
+ kal_uint8 dwFrameIntervalStep[4];
+} USBVideo_MJPEG_Frame_Dscr;
+
+/* still size structure */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 wWidth[2];
+ kal_uint8 wHeight[2];
+}USBVideo_Still_Size;
+
+/* Still image frame descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bEndpointAddress;
+ kal_uint8 bNumImageSizePatterns;
+ USBVideo_Still_Size *p_image_patterns;
+ kal_uint8 bNumCompressionPattern;
+ kal_uint8 *p_compression_patterns;
+} USBVideo_Still_Frame_Dscr;
+
+/* Color matching descriptor */
+typedef struct
+{
+ kal_uint8 bLength;
+ kal_uint8 bDescriptorType;
+ kal_uint8 bDescriptorSubType;
+ kal_uint8 bColorPrimaries;
+ kal_uint8 bTransferCharacteristics;
+ kal_uint8 bMatrixCoefficients;
+} USBVideo_Color_Dscr;
+
+/* video probe and commit setting */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bmHint[2];
+ kal_uint8 bFormatIndex;
+ kal_uint8 bFrameIndex;
+ kal_uint8 dwFrameInterval[4];
+ kal_uint8 wKeyFrameRate[2];
+ kal_uint8 wPFrameRate[2];
+ kal_uint8 wCompQuality[2];
+ kal_uint8 wCompWindowSize[2];
+ kal_uint8 wDelay[2];
+ kal_uint8 dwMaxVideoFrameSize[4];
+ kal_uint8 dwMaxPayloadTransferSize[4];
+ //kal_uint8 dwClockFrequency[4];
+ //kal_uint8 bmFramingInfo;
+ //kal_uint8 bPreferedVersion;
+ //kal_uint8 bMinVersion;
+ //kal_uint8 bMaxVersion;
+}USBVideo_Probe_Commit_Struct;
+
+/* still probe and commit setting */
+/* Note that the kal_uint8[2] array can not modify to kal_uint16
+ It is bacause align issue */
+typedef struct
+{
+ kal_uint8 bFormatIndex;
+ kal_uint8 bFrameIndex;
+ kal_uint8 bCompressionIndex;
+ kal_uint8 dwMaxVideoFrameSize[4];
+ kal_uint8 dwMaxPayloadTransferSize[4];
+}USBVideo_Still_Probe_Commit_Struct;
+
+typedef struct
+{
+ kal_uint8 bHeaderLength;
+ kal_uint8 bmHeaderInfo;
+ kal_uint8 dwPTS[4];
+ kal_uint8 dwSCR[6];
+}USBVideo_Payload_Header;
+
+typedef struct
+{
+ kal_uint8 bStuausType;
+ kal_uint8 bOriginator;
+ kal_uint8 bEvent;
+ kal_uint8 bValue;
+}USBVideo_VS_Status_Pkt_Struct;
+
+typedef struct
+{
+ kal_uint8 bStuausType;
+ kal_uint8 bOriginator;
+ kal_uint8 bEvent;
+ kal_uint8 bSelector;
+ kal_uint8 bAttribute;
+ kal_uint8 bValue;
+}USBVideo_VC_Status_Pkt_Struct;
+
+/***********************************************
+ implement enum and structure
+************************************************/
+
+typedef enum
+{
+ /* msg between media and USB */
+ USBVIDEO_MSG_MED_START_SUCCESS_CNF,
+ USBVIDEO_MSG_MED_START_FAIL_CNF,
+ USBVIDEO_MSG_MED_START_FAIL_CONFIG_CNF,
+ USBVIDEO_MSG_MED_CHANGE_VIDEO_IND,
+ USBVIDEO_MSG_MED_STILL_CAPTURE_IND,
+ USBVIDEO_MSG_MED_START_IND,
+ USBVIDEO_MSG_MED_DEVICE_STILL_CNF,
+ USBVIDEO_MSG_MED_PAUSE_CNF,
+ USBVIDEO_MSG_MED_RESUME_SUCCESS_CNF,
+ USBVIDEO_MSG_MED_RESUME_FAIL_CNF,
+ USBVIDEO_MSG_MED_STOP_IND,
+ USBVIDEO_MSG_MED_STOP_CNF,
+ USBVIDEO_MSG_MED_ABORT_IND,
+
+ /* msg used in internal USB driver */
+ USBVIDEO_MSG_USB_ENUM_DONE,
+ USBVIDEO_MSG_USB_COMPLETE_VIDEO,
+ USBVIDEO_MSG_USB_DMA_DONE,
+ USBVIDEO_MSG_USB_CHANGE_SIZE,
+ USBVIDEO_MSG_USB_STILL_CAPTURE,
+ USBVIDEO_MSG_USB_COMPLETE_STILL,
+ USBVIDEO_MSG_USB_STILL_DMA_DONE,
+ USBVIDEO_MSG_USB_STILL_DMA_PARTIAL,
+ USBVIDEO_MSG_USB_INCALL_DMA_DONE,
+ USBVIDEO_MSG_USB_INCALL_TIMEOUT,
+ USBVIDEO_MSG_USB_INCALL_CHANGE_SIZE,
+ USBVIDEO_MSG_USB_ABORT
+}USBVIDEO_MSG_TYPE;
+
+typedef enum
+{
+ USBVIDEO_STATE_STOP,
+ USBVIDEO_STATE_SEND,
+ USBVIDEO_STATE_DROP,
+ USBVIDEO_STATE_STILL,
+ USBVIDEO_STATE_PRE_PAUSE,
+ USBVIDEO_STATE_PAUSE
+}USBVIDEO_STATE;
+
+typedef enum
+{
+ USBVIDEO_PROBE_NONE,
+ USBVIDEO_PROBE_IN,
+ USBVIDEO_PROBE_DONE,
+ USBVIDEO_COMMIT_IN,
+ USBVIDEO_COMMIT_DONE
+}USBVIDEO_PROBE_STATE;
+
+typedef enum
+{
+ USBVIDEO_START_NONE,
+ USBVIDEO_START_RECV_MED_REQ,
+ USBVIDEO_START_RECV_COMMIT,
+ USBVIDEO_START_DONE
+}USBVIDEO_START_STATE;
+
+typedef enum
+{
+ USBVIDEO_DMA_VIDEO,
+ USBVIDEO_DMA_STILL,
+ USBVIDEO_DMA_INCALL_JPEG,
+ USBVIDEO_DMA_NONE
+}USBVIDEO_DMA_TYPE;
+
+typedef enum
+{
+ USBVIDEO_DMA_DONE_COMPLETE,
+ USBVIDEO_DMA_DONE_STOP /* DMA stop because of timeout, clear halt feature ,or commit but does not change size */
+}USBVIDEO_DMA_DONE_TYPE;
+
+
+typedef enum
+{
+ USBVIDEO_NO_ERROR = 0,
+ USBVIDEO_ERROR_NOT_READY,
+ USBVIDEO_ERROR_WRONG_STATE,
+ USBVIDEO_ERROR_POWER,
+ USBVIDEO_ERROR_OUT_OF_RANGE,
+ USBVIDEO_ERROR_INVALID_UNIT,
+ USBVIDEO_ERROR_INVAILD_CONTROL,
+ USBVIDEO_ERROR_INVAILD_REQUEST,
+ USBVIDEO_ERROR_UNKNOWN
+}USBVideo_ERROR_CODE;
+
+
+typedef struct
+{
+ kal_uint8 subtype;
+ kal_uint8 length;
+}USBVideo_Attr_Sub_Map;
+
+typedef struct
+{
+ USBVIDEO_ATTRIBUTE_TYPE attr_type;
+ kal_uint32 shift;
+ kal_uint8 length;
+ const USBVideo_Attr_Sub_Map *subtype_table;
+}USBVideo_Attr_Map;
+
+typedef struct
+{
+ kal_uint32 video_size[USBVIDEO_VIDEO_BUFFER_NUMBER]; /* complete video size returned by camera */
+ kal_uint8 *video_buffer_addr[USBVIDEO_VIDEO_BUFFER_NUMBER]; /* buffer start address */
+ kal_uint32 video_buffer_size; /* each buffer size */
+ kal_uint8 video_buffer_read_index; /* read pointer */
+ kal_uint8 video_buffer_write_index; /* write pointer */
+ kal_bool video_buffer_full; /* full flag */
+ kal_bool send_video_msg; /* indicate whether complete function should send complete msg to USB task */
+ kal_uint32 sent_video_size; /* already sent size for the current transmitting buffer */
+ kal_uint8 video_frame_id; /* even/odd id filled in payload header */
+
+ kal_uint32 still_size;
+ kal_uint8 still_count;
+
+ kal_uint8 *incall_jpeg_addr;
+ kal_uint32 incall_jpeg_size;
+ kal_uint8 *incall_jpeg_buff;
+
+ USBVIDEO_DMA_TYPE dma_type;
+ USBVIDEO_DMA_DONE_TYPE dma_done_type;
+// kal_bool b_processing_dma; /* be set at DMA callback*/
+
+ kal_uint32 timer_handle;
+ kal_bool b_stop_timer; /* TRUE when clear halt cmd */
+
+ const USBVideo_Video_Size_Info *p_video_size_info; /* be set at USBVideo_VS_If_Create() */
+ const USBVideo_Still_Size_Info *p_still_size_info;
+ kal_uint8 video_size_num;
+ kal_uint8 still_size_num;
+
+ kal_uint32 default_jpeg_max_size[USBVIDEO_VIDEO_SIZE_MAX]; /* be set by MMI */
+ kal_bool b_set_default_jpeg_max_size[USBVIDEO_VIDEO_SIZE_MAX];
+}USBVideo_Control_Struct;
+
+
+typedef struct
+{
+ Usb_EpBIn_Status *intrpipe; /* interrupt EP, VC Interface */
+ Usb_EpBIn_Status *txpipe; /* Bulk IN EP, VS Interface */
+
+ Usb_Ep_Info *vc_ep_intr_info;
+ Usb_Ep_Info *vs_ep_tx_info;
+ Usb_Interface_Info *vc_if_info;
+ Usb_Interface_Info *vs_if_info;
+#ifdef __WEBCAM_SUPPORT_ISO_PIPE__
+ Usb_Alternate_Interface_Info *vs_if_alter_info;
+#endif
+ Usb_IAD_Dscr *iad_desc;
+
+
+ USBVideo_Probe_Commit_Struct vs_probe_control;
+ USBVideo_Probe_Commit_Struct vs_recv_probe_control;
+ kal_uint8 commit_video_index;
+ kal_uint8 video_compression_index;
+ USBVIDEO_PROBE_STATE probe_state;
+
+ USBVideo_Still_Probe_Commit_Struct vs_still_probe_control;
+ USBVideo_Still_Probe_Commit_Struct vs_recv_still_probe_control;
+ kal_uint8 commit_still_index;
+ kal_uint8 commit_still_compression_index;
+ kal_uint8 *descriptor;
+ USBVIDEO_PROBE_STATE still_probe_state;
+ USBVideo_VS_Status_Pkt_Struct vs_status_pkt;
+ USBVideo_VC_Status_Pkt_Struct vc_status_pkt;
+ USBVIDEO_START_STATE video_start_state;
+ USBVideo_Control_Struct video_control;
+ USBVideo_Attr_Value set_attr_value; /* be used at set attr value*/
+ USBVideo_ERROR_CODE error_code;
+ USBVIDEO_STATE state;
+
+ kal_uint32 vc_ct_support;
+ kal_uint32 vc_ct_set;
+ kal_uint32 vc_pu_support;
+ kal_uint32 vc_pu_set;
+ kal_uint8 vc_ct_subtype_cnf[USBVIDEO_ATTRIBUTE_CT_MAX];
+ kal_uint8 vc_pu_subtype_cnf[(kal_uint32)USBVIDEO_ATTRIBUTE_PU_MAX-0x80];
+ kal_uint8 vs_interface_id;
+ kal_bool vc_intr_done; /*decide if issue interrupt */
+ kal_bool vc_set_wbalance_tmp_intr;
+ kal_bool vc_set_hue_intr;
+ kal_bool vc_white_balance_error_setting;
+ kal_bool usb_video_dma_stop;
+ kal_bool is_get_buffer_after_change_size;
+
+ /* default jpeg provided by MMI */
+ usbvideo_default_JPEG_Info *default_jpeg_info; /* incall JPEG, get from media task when pause request */
+ kal_uint8 default_jpeg_num;
+
+ /* customizable variables*/
+ const USB_VIDEO_PARAM *custom_param;
+ const USBVideo_Camera_Param *camera_param;
+
+#ifdef WEBCAM_TEST_DMA_DELAY
+ kal_uint8 test_timer_handle;
+ kal_bool test_enable;
+#endif
+} USBVideo_Struct;
+
+typedef struct
+{
+ LOCAL_PARA_HDR
+ kal_uint8 index;
+}usbvideo_still_dma_struct;
+
+
+/***********************************************
+ function and global variable
+************************************************/
+extern USBVideo_Struct g_USBVideo;
+extern CAL_FEATURE_WEBCAM_GET_VIDEO_SIZE_STRUCT UsbvideoVideoSize; // CAL_FEATURE_WEBCAM_GET_VIDEO_SIZE
+extern CAL_FEATURE_WEBCAM_GET_STILL_SIZE_STRUCT UsbvideoStillSize; // CAL_FEATURE_WEBCAM_GET_STILL_SIZE
+extern CAL_FEATURE_WEBCAM_GET_COMPRESSION_STRUCT UsbvideoCompression; // CAL_FEATURE_WEBCAM_GET_COMPRESSION
+
+
+extern void USBVideo_Send_Msg(USBVIDEO_MSG_TYPE usb_msg_type, kal_uint32 param1, kal_uint32 param2);
+extern kal_bool USBVideo_Get_PU_Attr_Cur_Value(USBVIDEO_ATTRIBUTE_TYPE type);
+extern void USBVideo_VC_If_Create(void *ifname);
+extern void USBVideo_VC_If_Reset(void);
+extern void USBVideo_VC_If_Enable(void);
+extern void USBVideo_VC_If_Speed_Reset(kal_bool b_other_speed);
+extern void USBVideo_VS_If_Create(void *ifname);
+extern void USBVideo_VS_If_Reset(void);
+extern void USBVideo_VS_If_Enable(void);
+extern void USBVideo_VS_If_Speed_Reset(kal_bool b_other_speed);
+extern void USB_Init_Video_Status(void);
+extern void USB_Release_Video_Status(void);
+extern kal_bool USBVideo_Send_Intr(void *addr,kal_uint32 len);
+extern void USBVideo_Send_Incall_JPEG(void);
+extern void USBVideo_Send_Video(void);
+
+
+#endif /* USBVIDEO_DRV_H */
+
diff --git a/mcu/driver/connectivity/usb_class/include/usbvideo_state.h b/mcu/driver/connectivity/usb_class/include/usbvideo_state.h
new file mode 100644
index 0000000..e84afd5
--- /dev/null
+++ b/mcu/driver/connectivity/usb_class/include/usbvideo_state.h
@@ -0,0 +1,106 @@
+/*****************************************************************************
+* Copyright Statement:
+* --------------------
+* This software is protected by Copyright and the information contained
+* herein is confidential. The software may not be copied and the information
+* contained herein may not be used or disclosed except with the written
+* permission of MediaTek Inc. (C) 2005
+*
+* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * usbvideo_state.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file intends for usb video class state machine definitions
+ *
+ * Author:
+ * -------
+ * -------
+ *
+*============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef USBVIDEO_STATE_H
+#define USBVIDEO_STATE_H
+
+//#include "usbvideo_custom.h"
+#include "usb_comm.h"
+#include "kal_public_api.h" //#include "stack_ltlcom.h" //MSBB change #include "app_ltlcom.h"
+
+#define USBVIDEO_PRE_PAUSE_TIMEOUT 100 /* 10ms unit*/
+#define USBVIDEO_INCALL_JPEG_TIMEOUT 100 /* 10ms unit*/
+
+/***********************************************
+ function and global variable
+************************************************/
+extern void USBVideo_Plug_Out_Hdlr(void);
+extern void USBVideo_Parse_Med_Msg(ilm_struct *p_recv_ilm, USB_DEVICE_TYPE device_type);
+
+#endif /* USBVIDEO_STATE_H */
+