Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

180 Zeilen
4.9 KiB

  1. /**
  2. ******************************************************************************
  3. * @file usbd_cdc.h
  4. * @author MCD Application Team
  5. * @brief header file for the usbd_cdc.c file.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * http://www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __USB_CDC_H
  21. #define __USB_CDC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "usbd_ioreq.h"
  27. /** @addtogroup STM32_USB_DEVICE_LIBRARY
  28. * @{
  29. */
  30. /** @defgroup usbd_cdc
  31. * @brief This file is the Header file for usbd_cdc.c
  32. * @{
  33. */
  34. /** @defgroup usbd_cdc_Exported_Defines
  35. * @{
  36. */
  37. #define CDC_IN_EP 0x81U /* EP1 for data IN */
  38. #define CDC_OUT_EP 0x01U /* EP1 for data OUT */
  39. #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
  40. #ifndef CDC_HS_BINTERVAL
  41. #define CDC_HS_BINTERVAL 0x10U
  42. #endif /* CDC_HS_BINTERVAL */
  43. #ifndef CDC_FS_BINTERVAL
  44. #define CDC_FS_BINTERVAL 0x10U
  45. #endif /* CDC_FS_BINTERVAL */
  46. /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
  47. #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
  48. #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
  49. #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
  50. #define USB_CDC_CONFIG_DESC_SIZ 67U
  51. #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
  52. #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
  53. #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
  54. #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
  55. /*---------------------------------------------------------------------*/
  56. /* CDC definitions */
  57. /*---------------------------------------------------------------------*/
  58. #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
  59. #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
  60. #define CDC_SET_COMM_FEATURE 0x02U
  61. #define CDC_GET_COMM_FEATURE 0x03U
  62. #define CDC_CLEAR_COMM_FEATURE 0x04U
  63. #define CDC_SET_LINE_CODING 0x20U
  64. #define CDC_GET_LINE_CODING 0x21U
  65. #define CDC_SET_CONTROL_LINE_STATE 0x22U
  66. #define CDC_SEND_BREAK 0x23U
  67. /**
  68. * @}
  69. */
  70. /** @defgroup USBD_CORE_Exported_TypesDefinitions
  71. * @{
  72. */
  73. /**
  74. * @}
  75. */
  76. typedef struct
  77. {
  78. uint32_t bitrate;
  79. uint8_t format;
  80. uint8_t paritytype;
  81. uint8_t datatype;
  82. }USBD_CDC_LineCodingTypeDef;
  83. typedef struct _USBD_CDC_Itf
  84. {
  85. int8_t (* Init) (void);
  86. int8_t (* DeInit) (void);
  87. int8_t (* Control) (uint8_t cmd, uint8_t* pbuf, uint16_t length);
  88. int8_t (* Receive) (uint8_t* Buf, uint32_t *Len);
  89. }USBD_CDC_ItfTypeDef;
  90. typedef struct
  91. {
  92. uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
  93. uint8_t CmdOpCode;
  94. uint8_t CmdLength;
  95. uint8_t *RxBuffer;
  96. uint8_t *TxBuffer;
  97. uint32_t RxLength;
  98. uint32_t TxLength;
  99. __IO uint32_t TxState;
  100. __IO uint32_t RxState;
  101. }
  102. USBD_CDC_HandleTypeDef;
  103. /** @defgroup USBD_CORE_Exported_Macros
  104. * @{
  105. */
  106. /**
  107. * @}
  108. */
  109. /** @defgroup USBD_CORE_Exported_Variables
  110. * @{
  111. */
  112. extern USBD_ClassTypeDef USBD_CDC;
  113. #define USBD_CDC_CLASS &USBD_CDC
  114. /**
  115. * @}
  116. */
  117. /** @defgroup USB_CORE_Exported_Functions
  118. * @{
  119. */
  120. uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev,
  121. USBD_CDC_ItfTypeDef *fops);
  122. uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev,
  123. uint8_t *pbuff,
  124. uint16_t length);
  125. uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev,
  126. uint8_t *pbuff);
  127. uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev);
  128. uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev);
  129. /**
  130. * @}
  131. */
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* __USB_CDC_H */
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/