/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_VENDOR_H
#define __USB_VENDOR_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include  "usbd_ioreq.h"
#include  "usb/usb_hooks.h"
#include  "usb/usb_config.h"
#include  "core/config.h"
#include  "drivers/usb/class/common/class_common.h"

#define VENDOR_IN_EP                                   0x81  /* EP1 for data IN */
#define VENDOR_OUT_EP                                  0x01  /* EP1 for data OUT */

#define VENDOR_DATAIN_MAX_PACKET_SIZE                  64    // Control-EP size
#define VENDOR_DATAOUT_MAX_PACKET_SIZE                 64    // Control-EP size
#define VENDOR_USE_COMMON_EP0RXREADY                   1
#define VENDOR_USE_COMMON_EP0TXSENT                    1
#define VENDOR_USE_COMMON_SETUP                        1

#if USB_CONTROL_VENDOR_RX_BUFFER < USB_MAX_EP0_SIZE
#error Invalid USB_CONTROL_VENDOR_RX_BUFFER buffer size. Must be at least USB_MAX_EP0_SIZE bytes.
#endif
#if USB_CONTROL_VENDOR_TX_BUFFER < USB_MAX_EP0_SIZE
#error Invalid USB_CONTROL_VENDOR_TX_BUFFER buffer size. Must be at least USB_MAX_EP0_SIZE bytes.
#endif

/*---------------------------------------------------------------------*/
/*  VENDOR definitions                                                 */
/*---------------------------------------------------------------------*/
 
typedef struct
{
  sUSBTransfer_t ep0_tx_transfer;
  sUSBTransfer_t ep0_rx_transfer;
    
  uint8_t ep0_tx_buffer[ USB_CONTROL_VENDOR_TX_BUFFER ];  
  uint8_t ep0_rx_buffer[ USB_CONTROL_VENDOR_RX_BUFFER ];   
  
}
USBD_VENDOR_HandleTypeDef; 

static inline size_t USBD_VENDOR_get_control_tx_transfer_size()
{
   return sizeof(((USBD_VENDOR_HandleTypeDef*)0)->ep0_tx_buffer);
}

static inline size_t USBD_VENDOR_get_control_rx_transfer_size()
{
   return sizeof(((USBD_VENDOR_HandleTypeDef*)0)->ep0_rx_buffer);
}

extern const USBD_COMMON_ItfTypeDef USBD_Interface_Vendor_UsbInterface;
extern const USBD_ClassTypeDef  USBD_VENDOR;
#define USBD_VENDOR_CLASS    &USBD_VENDOR

#ifdef __cplusplus
}
#endif

#endif  /* __USB_VENDOR_H */
