// -----------------------------------------------------------------------------
// USB Library "usblib"
// Target:  for stm32l151
// Author:  Sychov A.
// Date:    19/04/2018
// Version: 1.0
// -----------------------------------------------------------------------------
// File:    Configuration file
// Version: 1.0
// -----------------------------------------------------------------------------
#ifndef  _USB_CONFIG_H_
#define  _USB_CONFIG_H_

#include "usbd_def.h"

// Device Descriptor:
#define USB_VID              0x2226  // 0x2226
#define USB_PID_VENDOR       0x0054  // 0x0054
#define USB_PID_USBTMC       0x0081
#define USB_PID_DEBUG        0xFFFC  // 0xFFFC LibUsb debug
#define USBD_MSOS_VENDOR     0x21

// -----------------------------------------------------------------------------
// Note: the device supports two different USB interfaces which are used
// exclusively: only one interface is available at the same time.
// The first interface - Vendor-specific, PLANAR protocol
// The second one - Standard USBTMC.
// The whole memory consumption by both protocols is a maximum between
// the memory consumption of each protocols. So, the memory consumption
// of the one interface should be equal to the other interface.
// So, if the PLANAR protocol REQUIRES at least 4096 bytes for RX operations,
// and 128 bytes for TX operations, the USBTMC can use up to 4224 bytes,
// distributed between the buffer for CONTROL transfers, BULK transfers and
// INTERRUPT transfers. So USBTMC does not use huge transactions neither
// via CONTROL transfers nor via INTERRUPT transfers, 64 bytes is enought 
// for each CONTROL buffer and INTERRUPT buffer, the rest memory can be split up
// between BULK-IN and BULK-OUT buffers. The BULK-OUT buffer is more important
// to be extended due to the device tends to send more data to host than receive.
// In the other hand, the BULKIN buffer limits the maximum USBTMC message size
// can be processed by device, at the same time the BULKOUT buffer can be 
// compressed up to the BULKOUT Header size, but with loosing the performance.
// So 512 bytes for BULKIN and 3520 bytes for BULKOUT sounds good.
// -----------------------------------------------------------------------------

// USB_CONTROL_VENDOR_RX_BUFFER
// USB LowLevel Receive buffer size (single transaction buffer)
// Purposes: PLANAR protocol, CONTROL transfers
// Default: 4096 (for PLANAR VENDOR WRITE, Flash sector 4k)
#define USB_CONTROL_VENDOR_RX_BUFFER  4096

// USB_CONTROL_VENDOR_TX_BUFFER
// USB LowLevel Transmit buffer size (single transaction buffer)
// Purposes: PLANAR protocol, CONTROL transfers
// Default: 128 (at least 64 bytes)
#define USB_CONTROL_VENDOR_TX_BUFFER  128

// USB_CONTROL_USBTMC_RX_BUFFER
// USB LowLevel Receive buffer size (single transaction buffer)
// Purposes: USBTMC protocol, CONTROL transfers
// Default: 128 (for USBTMC, at least 64 bytes)
#define USB_CONTROL_USBTMC_RX_BUFFER  64

// USB_CONTROL_USBTMC_TX_BUFFER
// USB LowLevel Transmit buffer size (single transaction buffer)
// Purposes: USBTMC protocol, CONTROL transfers
// Default: 128 (for USBTMC, at least 64 bytes)
#define USB_CONTROL_USBTMC_TX_BUFFER  64


// USB_BULK_USBTMC_RX_BUFFER
// USB LowLevel Receive buffer size (single transaction buffer)
// Purposes: USBTMC protocol, BULK transfers
// Default: 128 (for USBTMC, at least 64 bytes)
#define USB_BULK_USBTMC_RX_BUFFER  384

// USB_BULK_USBTMC_TX_BUFFER
// USB LowLevel Transmit buffer size (single transaction buffer)
// Purposes: USBTMC protocol, BULK transfers
// Default: 3520 (for USBTMC, at least 64 bytes)
#define USB_BULK_USBTMC_TX_BUFFER  3520

// USB_INTERRUT_USBTMC_TX_BUFFER
// USB LowLevel Transmit buffer size (single transaction buffer)
// Purposes: USBTMC protocol, INTERRUPT transfers
// Default: 64 (for USBTMC, at least 64 bytes)
#define USB_INTERRUPT_USBTMC_TX_BUFFER  64
#endif


