|
1 |
| -/** |
2 |
| - ****************************************************************************** |
3 |
| - * @file : usbd_cdc_if.h |
4 |
| - * @version : v2.0_Cube |
5 |
| - * @brief : Header for usbd_cdc_if.c file. |
6 |
| - ****************************************************************************** |
7 |
| - * This notice applies to any and all portions of this file |
8 |
| - * that are not between comment pairs USER CODE BEGIN and |
9 |
| - * USER CODE END. Other portions of this file, whether |
10 |
| - * inserted by the user or by software development tools |
11 |
| - * are owned by their respective copyright owners. |
12 |
| - * |
13 |
| - * Copyright (c) 2018 STMicroelectronics International N.V. |
14 |
| - * All rights reserved. |
15 |
| - * |
16 |
| - * Redistribution and use in source and binary forms, with or without |
17 |
| - * modification, are permitted, provided that the following conditions are met: |
18 |
| - * |
19 |
| - * 1. Redistribution of source code must retain the above copyright notice, |
20 |
| - * this list of conditions and the following disclaimer. |
21 |
| - * 2. Redistributions in binary form must reproduce the above copyright notice, |
22 |
| - * this list of conditions and the following disclaimer in the documentation |
23 |
| - * and/or other materials provided with the distribution. |
24 |
| - * 3. Neither the name of STMicroelectronics nor the names of other |
25 |
| - * contributors to this software may be used to endorse or promote products |
26 |
| - * derived from this software without specific written permission. |
27 |
| - * 4. This software, including modifications and/or derivative works of this |
28 |
| - * software, must execute solely and exclusively on microcontroller or |
29 |
| - * microprocessor devices manufactured by or for STMicroelectronics. |
30 |
| - * 5. Redistribution and use of this software other than as permitted under |
31 |
| - * this license is void and will automatically terminate your rights under |
32 |
| - * this license. |
33 |
| - * |
34 |
| - * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" |
35 |
| - * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT |
36 |
| - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
37 |
| - * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
38 |
| - * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT |
39 |
| - * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
40 |
| - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
41 |
| - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
42 |
| - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
43 |
| - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
44 |
| - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
45 |
| - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
46 |
| - * |
47 |
| - ****************************************************************************** |
48 |
| - */ |
49 |
| - |
50 |
| -/* Define to prevent recursive inclusion -------------------------------------*/ |
51 | 1 | #ifndef __USBD_CDC_IF_H__
|
52 | 2 | #define __USBD_CDC_IF_H__
|
53 | 3 |
|
54 |
| -#ifdef __cplusplus |
55 |
| - extern "C" { |
56 |
| -#endif |
57 |
| - |
58 |
| -/* Includes ------------------------------------------------------------------*/ |
59 | 4 | #include "usbd_cdc.h"
|
60 | 5 |
|
61 |
| -/* USER CODE BEGIN INCLUDE */ |
62 |
| - |
63 |
| -/* USER CODE END INCLUDE */ |
64 |
| - |
65 |
| -/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY |
66 |
| - * @brief For Usb device. |
67 |
| - * @{ |
68 |
| - */ |
69 |
| - |
70 |
| -/** @defgroup USBD_CDC_IF USBD_CDC_IF |
71 |
| - * @brief Usb VCP device module |
72 |
| - * @{ |
73 |
| - */ |
74 |
| - |
75 |
| -/** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines |
76 |
| - * @brief Defines. |
77 |
| - * @{ |
78 |
| - */ |
79 |
| -/* USER CODE BEGIN EXPORTED_DEFINES */ |
80 |
| - |
81 |
| -/* USER CODE END EXPORTED_DEFINES */ |
82 |
| - |
83 |
| -/** |
84 |
| - * @} |
85 |
| - */ |
86 |
| - |
87 |
| -/** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types |
88 |
| - * @brief Types. |
89 |
| - * @{ |
90 |
| - */ |
91 |
| - |
92 |
| -/* USER CODE BEGIN EXPORTED_TYPES */ |
93 |
| - |
94 |
| -/* USER CODE END EXPORTED_TYPES */ |
| 6 | +// Buffer settings |
| 7 | +#define TX_BUF_SIZE 32 // Linear TX buf size |
| 8 | +#define NUM_RX_BUFS 6 // Number of RX buffers in FIFO |
| 9 | +#define RX_BUF_SIZE CDC_DATA_FS_MAX_PACKET_SIZE // Size of RX buffer item |
95 | 10 |
|
96 |
| -/** |
97 |
| - * @} |
98 |
| - */ |
| 11 | +// Receive buffering: circular buffer FIFO |
| 12 | +typedef struct _usbrx_buf_ |
| 13 | +{ |
| 14 | + // Receive buffering: circular buffer FIFO |
| 15 | + uint8_t buf[NUM_RX_BUFS][RX_BUF_SIZE]; |
| 16 | + uint32_t msglen[NUM_RX_BUFS]; |
| 17 | + uint8_t head; |
| 18 | + uint8_t tail; |
99 | 19 |
|
100 |
| -/** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros |
101 |
| - * @brief Aliases. |
102 |
| - * @{ |
103 |
| - */ |
| 20 | +} usbrx_buf_t; |
104 | 21 |
|
105 |
| -/* USER CODE BEGIN EXPORTED_MACRO */ |
106 | 22 |
|
107 |
| -/* USER CODE END EXPORTED_MACRO */ |
108 |
| - |
109 |
| -/** |
110 |
| - * @} |
111 |
| - */ |
112 |
| - |
113 |
| -/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables |
114 |
| - * @brief Public variables. |
115 |
| - * @{ |
116 |
| - */ |
117 |
| - |
118 |
| -/** CDC Interface callback. */ |
| 23 | +// CDC Interface callback. |
119 | 24 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
|
120 | 25 |
|
121 |
| -/* USER CODE BEGIN EXPORTED_VARIABLES */ |
122 |
| - |
123 |
| -/* USER CODE END EXPORTED_VARIABLES */ |
124 |
| - |
125 |
| -/** |
126 |
| - * @} |
127 |
| - */ |
128 |
| - |
129 |
| -/** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype |
130 |
| - * @brief Public functions declaration. |
131 |
| - * @{ |
132 |
| - */ |
133 | 26 |
|
| 27 | +// Prototypes |
134 | 28 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
|
135 |
| -void usb_process(void); |
136 |
| - |
137 |
| -/* USER CODE BEGIN EXPORTED_FUNCTIONS */ |
138 |
| - |
139 |
| -/* USER CODE END EXPORTED_FUNCTIONS */ |
140 |
| - |
141 |
| -/** |
142 |
| - * @} |
143 |
| - */ |
144 |
| - |
145 |
| -/** |
146 |
| - * @} |
147 |
| - */ |
| 29 | +void cdc_process(void); |
148 | 30 |
|
149 |
| -/** |
150 |
| - * @} |
151 |
| - */ |
152 | 31 |
|
153 |
| -#ifdef __cplusplus |
154 |
| -} |
155 |
| -#endif |
156 | 32 |
|
157 | 33 | #endif /* __USBD_CDC_IF_H__ */
|
158 | 34 |
|
159 |
| -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
0 commit comments