


 /**
 ******************************************************************************
 *
 * @file        MG32_USBD_Descriptor_API.h
 * @brief       The USBD Descriptor's h file.
 *
 * @par         Project
 *              MG32
 * @version     V1.00
 * @date        2021/04/21
 * @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 "MG32.h"

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

//--------------------------------------------------------------------------------
//Defined Class Codes (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 (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    HID_REPORT_LENGTH sizeof(HID_REPORT)

#define    USB_VID          0x0E6A                                        /*!< Vendor ID.*/
#define    USB_PID          0x0316                                        /*!< Product ID.*/
#define    USB_DID          0x0100                                        /*!< Device release number.*/



//#define    PD_STRING                                                      /*!< Supported Product String     .*/
//#define    SN_STRING                                                      /*!< Supported SerialNumber String.*/


#define    EP0_PACKET_SIZE        8                                       /*!< Maximum packet size for EP0.*/
#define    EP1_PACKET_SIZE        64                                      /*!< Maximum packet size for EP1.*/
#define    EP2_PACKET_SIZE        64                                      /*!< Maximum packet size for EP2.*/
#define    EP3_PACKET_SIZE        64                                      /*!< Maximum packet size for EP3.*/ 



#define    HID0_HID_REPORT_LENGTH sizeof(USB_INTERFACE0_HID_REPORT)       /*!< USB HID0 Descriptor data size.*/
#define    HID1_HID_REPORT_LENGTH sizeof(USB_INTERFACE1_HID_REPORT)       /*!< USB HID1 Descriptor data size.*/

    

#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_CONFIGURATION_TOTAOL_INTERFACE  2                                                                                    /*!< Total interface in the configuration.*/

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

   

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

 
extern const uint8_t USB_INTERFACE0_HID_REPORT[];              /*!< HID report of interface0 .*/
extern const uint8_t USB_INTERFACE1_HID_REPORT[];              /*!< HID report of interface1.*/
extern const uint8_t USB_DEVICE_DESCRIPTOR[];                  /*!< Device Descriptor.*/
extern const uint8_t USB_CONFIGURATION_DESCRIPTOR[];           /*!< Configuration Descriptor.*/
extern const uint8_t USB_INTERFACE0_DESCRIPTOR[];              /*!< Interface0 descriptor.*/
extern const uint8_t USB_INTERFACE0_HID_DESCRIPTOR[];          /*!< HID descriptor of interface0.*/
extern const uint8_t USB_INTERFACE0_IN_ENDPOINT_DESCRIPTOR[];  /*!< Endpoint descriptor of interface0.*/
extern const uint8_t USB_INTERFACE1_DESCRIPTOR[];              /*!< Interface1 descriptor.*/
extern const uint8_t USB_INTERFACE1_HID_DESCRIPTOR[];          /*!< HID descriptor of interface1.*/
extern const uint8_t USB_INTERFACE1_IN_ENDPOINT_DESCRIPTOR[];  /*!< Endpoint descriptor of interface1.*/
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
















