usbd_cdc_if.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : usbd_cdc_if.h
  5. * @version : v2.0_Cube
  6. * @brief : Header for usbd_cdc_if.c file.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * Copyright (c) 2025 STMicroelectronics.
  11. * All rights reserved.
  12. *
  13. * This software is licensed under terms that can be found in the LICENSE file
  14. * in the root directory of this software component.
  15. * If no LICENSE file comes with this software, it is provided AS-IS.
  16. *
  17. ******************************************************************************
  18. */
  19. /* USER CODE END Header */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __USBD_CDC_IF_H__
  22. #define __USBD_CDC_IF_H__
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "usbd_cdc.h"
  28. /* USER CODE BEGIN INCLUDE */
  29. /* USER CODE END INCLUDE */
  30. /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
  31. * @brief For Usb device.
  32. * @{
  33. */
  34. /** @defgroup USBD_CDC_IF USBD_CDC_IF
  35. * @brief Usb VCP device module
  36. * @{
  37. */
  38. /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
  39. * @brief Defines.
  40. * @{
  41. */
  42. /* Define size for the receive and transmit buffer over CDC */
  43. #define APP_RX_DATA_SIZE 1024
  44. #define APP_TX_DATA_SIZE 1024
  45. /* USER CODE BEGIN EXPORTED_DEFINES */
  46. extern void BSP_USB_printf(char* fmt,...);
  47. #define __USB_LOG_INFO__
  48. #ifdef __USB_LOG_INFO__
  49. #define usb_log_info(format, ...) BSP_USB_printf("|INFO|"format"|(File: "__FILE__", Line: %d)\r\n", ##__VA_ARGS__, __LINE__)
  50. #else
  51. #define usb_log_info(format,...)
  52. #endif
  53. #define __USB_LOG_DEBUG__
  54. #ifdef __USB_LOG_DEBUG__
  55. #define usb_log_debug(format, ...) BSP_USB_printf("|DEBUG|"format"|(File: "__FILE__", Line: %d)\r\n", ##__VA_ARGS__, __LINE__)
  56. #else
  57. #define usb_log_debug(format,...)
  58. #endif
  59. /* USER CODE END EXPORTED_DEFINES */
  60. /**
  61. * @}
  62. */
  63. /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
  64. * @brief Types.
  65. * @{
  66. */
  67. /* USER CODE BEGIN EXPORTED_TYPES */
  68. typedef struct
  69. {
  70. volatile uint16_t recFlag;
  71. volatile uint32_t recLen;
  72. } USB_REC_Typedef;
  73. extern USB_REC_Typedef usb_com;
  74. extern uint16_t tx_len;
  75. /* USER CODE END EXPORTED_TYPES */
  76. /**
  77. * @}
  78. */
  79. /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
  80. * @brief Aliases.
  81. * @{
  82. */
  83. /* USER CODE BEGIN EXPORTED_MACRO */
  84. extern uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
  85. extern uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
  86. /* USER CODE END EXPORTED_MACRO */
  87. /**
  88. * @}
  89. */
  90. /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
  91. * @brief Public variables.
  92. * @{
  93. */
  94. /** CDC Interface callback. */
  95. extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
  96. /* USER CODE BEGIN EXPORTED_VARIABLES */
  97. /* USER CODE END EXPORTED_VARIABLES */
  98. /**
  99. * @}
  100. */
  101. /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
  102. * @brief Public functions declaration.
  103. * @{
  104. */
  105. uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
  106. /* USER CODE BEGIN EXPORTED_FUNCTIONS */
  107. /* USER CODE END EXPORTED_FUNCTIONS */
  108. /**
  109. * @}
  110. */
  111. /**
  112. * @}
  113. */
  114. /**
  115. * @}
  116. */
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* __USBD_CDC_IF_H__ */