usb_config.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // -----------------------------------------------------------------------------
  2. // USB Library "usblib"
  3. // Target: for stm32l151
  4. // Author: Sychov A.
  5. // Date: 19/04/2018
  6. // Version: 1.0
  7. // -----------------------------------------------------------------------------
  8. // File: Configuration file
  9. // Version: 1.0
  10. // -----------------------------------------------------------------------------
  11. #ifndef _USB_CONFIG_H_
  12. #define _USB_CONFIG_H_
  13. #include "usbd_def.h"
  14. // Device Descriptor:
  15. #define USB_VID 0x2226 // 0x2226
  16. #define USB_PID_VENDOR 0x0054 // 0x0054
  17. #define USB_PID_USBTMC 0x0080
  18. #define USB_PID_DEBUG 0xFFFC // 0xFFFC LibUsb debug
  19. #define USBD_MSOS_VENDOR 0x21
  20. // -----------------------------------------------------------------------------
  21. // Note: the device supports two different USB interfaces which are used
  22. // exclusively: only one interface is available at the same time.
  23. // The first interface - Vendor-specific, PLANAR protocol
  24. // The second one - Standard USBTMC.
  25. // The whole memory consumption by both protocols is a maximum between
  26. // the memory consumption of each protocols. So, the memory consumption
  27. // of the one interface should be equal to the other interface.
  28. // So, if the PLANAR protocol REQUIRES at least 4096 bytes for RX operations,
  29. // and 128 bytes for TX operations, the USBTMC can use up to 4224 bytes,
  30. // distributed between the buffer for CONTROL transfers, BULK transfers and
  31. // INTERRUPT transfers. So USBTMC does not use huge transactions neither
  32. // via CONTROL transfers nor via INTERRUPT transfers, 64 bytes is enought
  33. // for each CONTROL buffer and INTERRUPT buffer, the rest memory can be split up
  34. // between BULK-IN and BULK-OUT buffers. The BULK-OUT buffer is more important
  35. // to be extended due to the device tends to send more data to host than receive.
  36. // In the other hand, the BULKIN buffer limits the maximum USBTMC message size
  37. // can be processed by device, at the same time the BULKOUT buffer can be
  38. // compressed up to the BULKOUT Header size, but with loosing the performance.
  39. // So 512 bytes for BULKIN and 3520 bytes for BULKOUT sounds good.
  40. // -----------------------------------------------------------------------------
  41. // USB_CONTROL_VENDOR_RX_BUFFER
  42. // USB LowLevel Receive buffer size (single transaction buffer)
  43. // Purposes: PLANAR protocol, CONTROL transfers
  44. // Default: 4096 (for PLANAR VENDOR WRITE, Flash sector 4k)
  45. #define USB_CONTROL_VENDOR_RX_BUFFER 4096
  46. // USB_CONTROL_VENDOR_TX_BUFFER
  47. // USB LowLevel Transmit buffer size (single transaction buffer)
  48. // Purposes: PLANAR protocol, CONTROL transfers
  49. // Default: 128 (at least 64 bytes)
  50. #define USB_CONTROL_VENDOR_TX_BUFFER 128
  51. // USB_CONTROL_USBTMC_RX_BUFFER
  52. // USB LowLevel Receive buffer size (single transaction buffer)
  53. // Purposes: USBTMC protocol, CONTROL transfers
  54. // Default: 128 (for USBTMC, at least 64 bytes)
  55. #define USB_CONTROL_USBTMC_RX_BUFFER 64
  56. // USB_CONTROL_USBTMC_TX_BUFFER
  57. // USB LowLevel Transmit buffer size (single transaction buffer)
  58. // Purposes: USBTMC protocol, CONTROL transfers
  59. // Default: 128 (for USBTMC, at least 64 bytes)
  60. #define USB_CONTROL_USBTMC_TX_BUFFER 64
  61. // USB_BULK_USBTMC_RX_BUFFER
  62. // USB LowLevel Receive buffer size (single transaction buffer)
  63. // Purposes: USBTMC protocol, BULK transfers
  64. // Default: 128 (for USBTMC, at least 64 bytes)
  65. #define USB_BULK_USBTMC_RX_BUFFER 384
  66. // USB_BULK_USBTMC_TX_BUFFER
  67. // USB LowLevel Transmit buffer size (single transaction buffer)
  68. // Purposes: USBTMC protocol, BULK transfers
  69. // Default: 3520 (for USBTMC, at least 64 bytes)
  70. #define USB_BULK_USBTMC_TX_BUFFER 3520
  71. // USB_INTERRUT_USBTMC_TX_BUFFER
  72. // USB LowLevel Transmit buffer size (single transaction buffer)
  73. // Purposes: USBTMC protocol, INTERRUPT transfers
  74. // Default: 64 (for USBTMC, at least 64 bytes)
  75. #define USB_INTERRUPT_USBTMC_TX_BUFFER 64
  76. #endif