


 /**
 ******************************************************************************
 *
 * @file        USBD_DSC.h
 * @brief       The USBD Descriptor's h file.
 *
 * @par         Project
 *              MG32x02z
 * @version     V1.02
 * @date        2022/08/10
 * @author      Megawin Software Center
 * @copyright   Copyright (c) 2017 MegaWin Technology Co., Ltd.
 *              All rights reserved.
 * 
 ******************************************************************************* 
 * @par Disclaimer
 * The Demo software is provided "AS IS" without any warranty, either
 * expressed or implied, including, but not limited to, the implied warranties
 * of merchantability and fitness for a particular purpose. The author will
 * not be liable for any special, incidental, consequential or indirect
 * damages due to loss of data or any other reason.
 * These statements agree with the world wide and local dictated laws about
 * authorship and violence against these laws.
 *******************************************************************************
 *******************************************************************************
 */


#ifndef _USB_DSC_H
#define _USB_DSC_H

#include "MG32x02z.h"
#include "MG32x02z_USB_Init.h"


/**
 * @name USB Class Codes
 *   		
 */ 
///@{

//--------------------------------------------------------------------------------
//Defined Class Codes (Descriptor Usage : Device) (USB-IF Last Update: January 7, 2022)
#define bDeviceClass_InterfaceDescriptors          0x00         /*!< Use class information in the Interface Descriptors.*/
#define bDeviceClass_CDC                           0x02         /*!< Communications and CDC Control.*/      
#define bDeviceClass_Hub                           0x09
#define bDeviceClass_BillboardDeviceClass          0x11
#define bDeviceClass_DiagnosticDevice              0xDC
#define bDeviceClass_Miscellaneous                 0xEF
#define bDeviceClass_VendorSpecific                0xFF

//-------------------------------------------------------------------------------- 
//Defined Class Codes (Descriptor Usage : Interface) (USB-IF Last Update: January 7, 2022)                            
#define bInterfaceClass_Audio                      0x01
#define bInterfaceClass_CDC                        0x02         /*!< Communications and CDC Control.*/      
#define bInterfaceClass_HID                        0x03         /*!< HID(Human Interface Device).*/
#define bInterfaceClass_Physical                   0x05
#define bInterfaceClass_Image                      0x06
#define bInterfaceClass_Printer                    0x07
#define bInterfaceClass_MassStorage                0x08
#define bInterfaceClass_CDCData                    0x0A
#define bInterfaceClass_SmartCard                  0x0B
#define bInterfaceClass_ContentSecurity            0x0D
#define bInterfaceClass_Video                      0x0E
#define bInterfaceClass_PersonalHealthcare         0x0F
#define bInterfaceClass_AudioVideoDevices          0x10
#define bInterfaceClass_USBTypeC_BridgeClass       0x12
#define bInterfaceClass_I3CDeviceClass             0x3C
#define bInterfaceClass_DiagnosticDevice           0xDC
#define bInterfaceClass_WirelessController         0xE0
#define bInterfaceClass_Miscellaneous              0xEF
#define bInterfaceClass_ApplicationSpecific        0xFE
#define bInterfaceClass_VendorSpecific             0xFF 

///@}

/**
 * @name Cosumer Descriptor Define.
 *   		
 */ 
///@{

#define FKB_TOTALFUNCTION    0x14


#define    EP0_PACKET_SIZE          64                      /*!< Maximum packet size for EP0.*/
#define    EP1_IN_PACKET_SIZE        8                      /*!< Maximum packet size for EP1.*/
#define    EP2_IN_PACKET_SIZE        8                      /*!< Maximum packet size for EP2.*/
#define    EP3_IN_PACKET_SIZE       10
#define    EP4_IN_PACKET_SIZE       64 
#define    EP4_OUT_PACKET_SIZE      64
#define    EP5_IN_PACKET_SIZE       64
#define    EP5_OUT_PACKET_SIZE      64


#define USB_CONFIGURATION_DESC_SIZE         9                /*!< USB Configuration descriptor data size. */
#define USB_INTERFACE_DESC_SIZE             9                /*!< USB Interface descriptor data size. */
#define USB_HID_DESC_SIZE                   9                /*!< USB HID descriptor data size. */
#define USB_HEADER_DESC_SIZE                5                /*!< USB Header Descriptor data size in CS interface descriptor.*/
#define USB_ABSTRACT_DESC_SIZE              4                /*!< USB Abstract Descriptor data size in CS interface descriptor.*/
#define USB_UNION_DESC_SIZE                 5                /*!< USB Union Descriptor data size in CS interface descriptor.*/
#define USB_CALLMANAGEMENT_DESC_SIZE        5                /*!< USB Call Management Descriptor data size in CS interface descriptor.*/
#define USB_ENDPOINT_DESC_SIZE              7                /*!< USB Endpoint descriptor data size. */
#define USB_INTERFACE_ASSOCIATION_DESC_SIZE 8                /*!< USB Interface Association data size. */ 


#define USB_CONFIGURATION_TOTAOL_INTERFACE  5                /*!< Total interface in the configuration.*/

/*!< The configuration descriptor total size.*/
#define USB_CONFIGURATION_DESC_TOTAOSIZE   ((USB_CONFIGURATION_DESC_SIZE * 1) +  \
                                            (USB_INTERFACE_ASSOCIATION_DESC_SIZE) + \
                                            (USB_INTERFACE_DESC_SIZE + (USB_HEADER_DESC_SIZE + USB_CALLMANAGEMENT_DESC_SIZE + USB_ABSTRACT_DESC_SIZE + USB_UNION_DESC_SIZE) + USB_ENDPOINT_DESC_SIZE) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 2) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 1) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 1) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 2))          
                                      
#define USB_HID2_DESC_SHIFT                ((USB_CONFIGURATION_DESC_SIZE * 1) +  \
                                            (USB_INTERFACE_ASSOCIATION_DESC_SIZE) + \
                                            (USB_INTERFACE_DESC_SIZE + (USB_HEADER_DESC_SIZE + USB_CALLMANAGEMENT_DESC_SIZE + USB_ABSTRACT_DESC_SIZE + USB_UNION_DESC_SIZE) + USB_ENDPOINT_DESC_SIZE) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 2) +\
                                            (USB_INTERFACE_DESC_SIZE))

#define USB_HID3_DESC_SHIFT                ((USB_CONFIGURATION_DESC_SIZE * 1) +  \
                                            (USB_INTERFACE_ASSOCIATION_DESC_SIZE) + \
                                            (USB_INTERFACE_DESC_SIZE + (USB_HEADER_DESC_SIZE + USB_CALLMANAGEMENT_DESC_SIZE + USB_ABSTRACT_DESC_SIZE + USB_UNION_DESC_SIZE) + USB_ENDPOINT_DESC_SIZE) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 2) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 1) +\
                                            (USB_INTERFACE_DESC_SIZE))

#define USB_HID4_DESC_SHIFT                ((USB_CONFIGURATION_DESC_SIZE * 1) +  \
                                            (USB_INTERFACE_ASSOCIATION_DESC_SIZE) + \
                                            (USB_INTERFACE_DESC_SIZE + (USB_HEADER_DESC_SIZE + USB_CALLMANAGEMENT_DESC_SIZE + USB_ABSTRACT_DESC_SIZE + USB_UNION_DESC_SIZE) + USB_ENDPOINT_DESC_SIZE) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 2) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 1) +\
                                            (USB_INTERFACE_DESC_SIZE + USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE * 1) +\
                                            (USB_INTERFACE_DESC_SIZE))      
   

#define KB_FUNHID_ID_FKB         1                          /*!< HID Multimedia ID.*/
#define KB_FUNHID_ID_SYSTEM      2                          /*!< HID System power control ID.*/


extern const uint16_t HID2_ReportLength;
extern const uint16_t HID3_ReportLength;
extern const uint16_t HID4_ReportLength;
 
extern const uint8_t USB_INTERFACE2_HID_REPORT[];           /*!< HID report of interface 2.*/
extern const uint8_t USB_INTERFACE3_HID_REPORT[];           /*!< HID report of interface 3.*/
extern const uint8_t USB_INTERFACE4_HID_REPORT[];           /*!< HID report of interface 4.*/

extern const uint8_t USB_DEVICE_DESCRIPTOR[];               /*!< Device Descriptor.*/
extern const uint8_t USB_CONFIGURATION_DESCRIPTOR[];        /*!< Configuration Descriptor.*/
extern const uint8_t USB_STRING_DESCRIPTOR[];               /*!< String descriptor.*/

#if MF_STRING == 1
#define MFS_LEN (sizeof(MANUFACTURER_DESCRIPTOR)*2    )     /*!< Manufacture descriptor size.*/

extern  const uint8_t Manufacturer_Descriptor[];            /*!< Manufacture string descriptor.*/

#endif


#if PD_STRING == 1
#define PDS_LEN (sizeof(PRODUCT_DESCRIPTOR)*2)              /*!< Product descriptor size.*/

extern const uint8_t Product_Descriptor[];                  /*!< Product string descriptor.*/

#endif

#if SN_STRING == 1

#define SNS_LEN (sizeof(SERIALNUMBER_DESCRIPTOR)*2)         /*!< Serial number descriptor size.*/
extern const uint8_t SerialNumber_Descriptor[];             /*!< Serial number string descriptor.*/
#endif

#if MG_USB_LPM_EN == 1
extern const uint8_t USB_BOS_DESCRIPTOR[];                  /*!< BOS descriptor.*/
extern const uint8_t USB_EXT_DESCRIPTOR[];                  /*!< Device capability descriptor.*/
#endif

///@}

#endif
















