├── Build
└── stm32f103_dual_vcp.hex
├── README.md
├── STM32F103_DUAL_VCP
├── Drivers
│ ├── CMSIS
│ │ ├── Device
│ │ │ └── ST
│ │ │ │ └── STM32F1xx
│ │ │ │ └── Include
│ │ │ │ ├── stm32f103xb.h
│ │ │ │ ├── stm32f1xx.h
│ │ │ │ └── system_stm32f1xx.h
│ │ └── Include
│ │ │ ├── cmsis_armcc.h
│ │ │ ├── cmsis_armclang.h
│ │ │ ├── cmsis_compiler.h
│ │ │ ├── cmsis_gcc.h
│ │ │ ├── cmsis_iccarm.h
│ │ │ ├── cmsis_version.h
│ │ │ ├── core_armv8mbl.h
│ │ │ ├── core_armv8mml.h
│ │ │ ├── core_cm0.h
│ │ │ ├── core_cm0plus.h
│ │ │ ├── core_cm1.h
│ │ │ ├── core_cm23.h
│ │ │ ├── core_cm3.h
│ │ │ ├── core_cm33.h
│ │ │ ├── core_cm4.h
│ │ │ ├── core_cm7.h
│ │ │ ├── core_sc000.h
│ │ │ ├── core_sc300.h
│ │ │ ├── mpu_armv7.h
│ │ │ ├── mpu_armv8.h
│ │ │ └── tz_context.h
│ └── STM32F1xx_HAL_Driver
│ │ ├── Inc
│ │ ├── Legacy
│ │ │ └── stm32_hal_legacy.h
│ │ ├── stm32f1xx_hal.h
│ │ ├── stm32f1xx_hal_cortex.h
│ │ ├── stm32f1xx_hal_def.h
│ │ ├── stm32f1xx_hal_dma.h
│ │ ├── stm32f1xx_hal_dma_ex.h
│ │ ├── stm32f1xx_hal_exti.h
│ │ ├── stm32f1xx_hal_flash.h
│ │ ├── stm32f1xx_hal_flash_ex.h
│ │ ├── stm32f1xx_hal_gpio.h
│ │ ├── stm32f1xx_hal_gpio_ex.h
│ │ ├── stm32f1xx_hal_pcd.h
│ │ ├── stm32f1xx_hal_pcd_ex.h
│ │ ├── stm32f1xx_hal_pwr.h
│ │ ├── stm32f1xx_hal_rcc.h
│ │ ├── stm32f1xx_hal_rcc_ex.h
│ │ ├── stm32f1xx_hal_tim.h
│ │ ├── stm32f1xx_hal_tim_ex.h
│ │ ├── stm32f1xx_hal_uart.h
│ │ └── stm32f1xx_ll_usb.h
│ │ └── Src
│ │ ├── stm32f1xx_hal.c
│ │ ├── stm32f1xx_hal_cortex.c
│ │ ├── stm32f1xx_hal_dma.c
│ │ ├── stm32f1xx_hal_exti.c
│ │ ├── stm32f1xx_hal_flash.c
│ │ ├── stm32f1xx_hal_flash_ex.c
│ │ ├── stm32f1xx_hal_gpio.c
│ │ ├── stm32f1xx_hal_gpio_ex.c
│ │ ├── stm32f1xx_hal_pcd.c
│ │ ├── stm32f1xx_hal_pcd_ex.c
│ │ ├── stm32f1xx_hal_pwr.c
│ │ ├── stm32f1xx_hal_rcc.c
│ │ ├── stm32f1xx_hal_rcc_ex.c
│ │ ├── stm32f1xx_hal_tim.c
│ │ ├── stm32f1xx_hal_tim_ex.c
│ │ ├── stm32f1xx_hal_uart.c
│ │ └── stm32f1xx_ll_usb.c
├── Inc
│ ├── main.h
│ ├── stm32f1xx_hal_conf.h
│ ├── stm32f1xx_it.h
│ ├── usb_device.h
│ ├── usbd_cdc_if.h
│ ├── usbd_conf.h
│ └── usbd_desc.h
├── MDK-ARM
│ ├── DebugConfig
│ │ └── STM32F103_DUAL_VCP_STM32F103CB_1.0.0.dbgconf
│ ├── RTE
│ │ └── _STM32F103_DUAL_VCP
│ │ │ └── RTE_Components.h
│ ├── STM32F103_DUAL_VCP.uvoptx
│ ├── STM32F103_DUAL_VCP.uvprojx
│ ├── STM32F103_DUAL_VCP
│ │ └── STM32F103_DUAL_VCP.sct
│ └── startup_stm32f103xb.s
├── Middlewares
│ └── ST
│ │ └── STM32_USB_Device_Library
│ │ ├── Class
│ │ └── CDC
│ │ │ ├── Inc
│ │ │ └── usbd_cdc.h
│ │ │ └── Src
│ │ │ └── usbd_cdc.c
│ │ └── Core
│ │ ├── Inc
│ │ ├── usbd_core.h
│ │ ├── usbd_ctlreq.h
│ │ ├── usbd_def.h
│ │ └── usbd_ioreq.h
│ │ └── Src
│ │ ├── usbd_core.c
│ │ ├── usbd_ctlreq.c
│ │ └── usbd_ioreq.c
└── Src
│ ├── main.c
│ ├── stm32f1xx_hal_msp.c
│ ├── stm32f1xx_it.c
│ ├── system_stm32f1xx.c
│ ├── usb_device.c
│ ├── usbd_cdc_if.c
│ ├── usbd_conf.c
│ └── usbd_desc.c
└── Win7-Dual-VCP-Driver
└── Win7_Dual_VCP_Driver.inf
/README.md:
--------------------------------------------------------------------------------
1 | # STM32F103_DUAL_VCP
2 |
3 | RadioOperator modified:
4 |
5 | - changed new USB lib from STM32CubeMX to improve PC Enum.
6 |
7 | - added LED (PC13) flashing when UART transfering data.
8 |
9 |
10 |
11 |
12 |
13 | An example to show how to use dual CDC VCP USB interfaces.
14 |
15 | ## Hardware configuration
16 |
17 | MCU: STM32F103C6Tx(72MHz, LQFP48, 32KB Flash, 10KB RAM)
18 | Hardware board: BluePill
19 | LED: PC13, low-active
20 |
21 | ## Software Development Environment
22 |
23 | - MDK/Keil v5.xx
24 | - ARMCC v6.xx -O1
25 |
26 | ## Firmware Configureation
27 |
28 | - Memory configuration:
29 | - Heap Size: 0x1000
30 | - Stack Size: 0x400
31 |
32 | - Perpherials
33 | - RCC
34 | - High Speed Clock (HSE): Crystal/Ceramic Resonator
35 | - Low Speed Clock (LSE) : Crystal/Ceramic Resonator
36 | - USB
37 | - Device (FS)
38 |
39 | - USART1
40 | - Mode: Asynchronous
41 |
42 | - USART2
43 | - Mode: Asynchronous
44 |
45 | - MiddleWares
46 | - USB_DEVICE
47 | - Class for FS IP: Communication Device Class (Virtual Port Com)
48 |
49 | - Pin configuration
50 | - USB_DM: PA11
51 | - USB_PM: PA12
52 | - USART1_TX: PA9
53 | - USART1_RX: PA10
54 | - USART2_TX: PA2
55 | - USART2_RX: PA3
56 |
57 |
58 | ```
59 |
60 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RadioOperator/stm32f103_dual_vcp/adafd1046222812067a14db6822ac574b778b8e4/STM32F103_DUAL_VCP/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RadioOperator/stm32f103_dual_vcp/adafd1046222812067a14db6822ac574b778b8e4/STM32F103_DUAL_VCP/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f10x.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | *
© Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /** @addtogroup CMSIS
21 | * @{
22 | */
23 |
24 | /** @addtogroup stm32f10x_system
25 | * @{
26 | */
27 |
28 | /**
29 | * @brief Define to prevent recursive inclusion
30 | */
31 | #ifndef __SYSTEM_STM32F10X_H
32 | #define __SYSTEM_STM32F10X_H
33 |
34 | #ifdef __cplusplus
35 | extern "C" {
36 | #endif
37 |
38 | /** @addtogroup STM32F10x_System_Includes
39 | * @{
40 | */
41 |
42 | /**
43 | * @}
44 | */
45 |
46 |
47 | /** @addtogroup STM32F10x_System_Exported_types
48 | * @{
49 | */
50 |
51 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
52 | extern const uint8_t AHBPrescTable[16U]; /*!< AHB prescalers table values */
53 | extern const uint8_t APBPrescTable[8U]; /*!< APB prescalers table values */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /** @addtogroup STM32F10x_System_Exported_Constants
60 | * @{
61 | */
62 |
63 | /**
64 | * @}
65 | */
66 |
67 | /** @addtogroup STM32F10x_System_Exported_Macros
68 | * @{
69 | */
70 |
71 | /**
72 | * @}
73 | */
74 |
75 | /** @addtogroup STM32F10x_System_Exported_Functions
76 | * @{
77 | */
78 |
79 | extern void SystemInit(void);
80 | extern void SystemCoreClockUpdate(void);
81 | /**
82 | * @}
83 | */
84 |
85 | #ifdef __cplusplus
86 | }
87 | #endif
88 |
89 | #endif /*__SYSTEM_STM32F10X_H */
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
99 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Include/cmsis_compiler.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_compiler.h
3 | * @brief CMSIS compiler generic header file
4 | * @version V5.0.4
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #ifndef __CMSIS_COMPILER_H
26 | #define __CMSIS_COMPILER_H
27 |
28 | #include
29 |
30 | /*
31 | * Arm Compiler 4/5
32 | */
33 | #if defined ( __CC_ARM )
34 | #include "cmsis_armcc.h"
35 |
36 |
37 | /*
38 | * Arm Compiler 6 (armclang)
39 | */
40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
41 | #include "cmsis_armclang.h"
42 |
43 |
44 | /*
45 | * GNU Compiler
46 | */
47 | #elif defined ( __GNUC__ )
48 | #include "cmsis_gcc.h"
49 |
50 |
51 | /*
52 | * IAR Compiler
53 | */
54 | #elif defined ( __ICCARM__ )
55 | #include
56 |
57 |
58 | /*
59 | * TI Arm Compiler
60 | */
61 | #elif defined ( __TI_ARM__ )
62 | #include
63 |
64 | #ifndef __ASM
65 | #define __ASM __asm
66 | #endif
67 | #ifndef __INLINE
68 | #define __INLINE inline
69 | #endif
70 | #ifndef __STATIC_INLINE
71 | #define __STATIC_INLINE static inline
72 | #endif
73 | #ifndef __STATIC_FORCEINLINE
74 | #define __STATIC_FORCEINLINE __STATIC_INLINE
75 | #endif
76 | #ifndef __NO_RETURN
77 | #define __NO_RETURN __attribute__((noreturn))
78 | #endif
79 | #ifndef __USED
80 | #define __USED __attribute__((used))
81 | #endif
82 | #ifndef __WEAK
83 | #define __WEAK __attribute__((weak))
84 | #endif
85 | #ifndef __PACKED
86 | #define __PACKED __attribute__((packed))
87 | #endif
88 | #ifndef __PACKED_STRUCT
89 | #define __PACKED_STRUCT struct __attribute__((packed))
90 | #endif
91 | #ifndef __PACKED_UNION
92 | #define __PACKED_UNION union __attribute__((packed))
93 | #endif
94 | #ifndef __UNALIGNED_UINT32 /* deprecated */
95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; };
96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
97 | #endif
98 | #ifndef __UNALIGNED_UINT16_WRITE
99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
101 | #endif
102 | #ifndef __UNALIGNED_UINT16_READ
103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
105 | #endif
106 | #ifndef __UNALIGNED_UINT32_WRITE
107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
109 | #endif
110 | #ifndef __UNALIGNED_UINT32_READ
111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
113 | #endif
114 | #ifndef __ALIGNED
115 | #define __ALIGNED(x) __attribute__((aligned(x)))
116 | #endif
117 | #ifndef __RESTRICT
118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
119 | #define __RESTRICT
120 | #endif
121 |
122 |
123 | /*
124 | * TASKING Compiler
125 | */
126 | #elif defined ( __TASKING__ )
127 | /*
128 | * The CMSIS functions have been implemented as intrinsics in the compiler.
129 | * Please use "carm -?i" to get an up to date list of all intrinsics,
130 | * Including the CMSIS ones.
131 | */
132 |
133 | #ifndef __ASM
134 | #define __ASM __asm
135 | #endif
136 | #ifndef __INLINE
137 | #define __INLINE inline
138 | #endif
139 | #ifndef __STATIC_INLINE
140 | #define __STATIC_INLINE static inline
141 | #endif
142 | #ifndef __STATIC_FORCEINLINE
143 | #define __STATIC_FORCEINLINE __STATIC_INLINE
144 | #endif
145 | #ifndef __NO_RETURN
146 | #define __NO_RETURN __attribute__((noreturn))
147 | #endif
148 | #ifndef __USED
149 | #define __USED __attribute__((used))
150 | #endif
151 | #ifndef __WEAK
152 | #define __WEAK __attribute__((weak))
153 | #endif
154 | #ifndef __PACKED
155 | #define __PACKED __packed__
156 | #endif
157 | #ifndef __PACKED_STRUCT
158 | #define __PACKED_STRUCT struct __packed__
159 | #endif
160 | #ifndef __PACKED_UNION
161 | #define __PACKED_UNION union __packed__
162 | #endif
163 | #ifndef __UNALIGNED_UINT32 /* deprecated */
164 | struct __packed__ T_UINT32 { uint32_t v; };
165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
166 | #endif
167 | #ifndef __UNALIGNED_UINT16_WRITE
168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
170 | #endif
171 | #ifndef __UNALIGNED_UINT16_READ
172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
174 | #endif
175 | #ifndef __UNALIGNED_UINT32_WRITE
176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
178 | #endif
179 | #ifndef __UNALIGNED_UINT32_READ
180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
182 | #endif
183 | #ifndef __ALIGNED
184 | #define __ALIGNED(x) __align(x)
185 | #endif
186 | #ifndef __RESTRICT
187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
188 | #define __RESTRICT
189 | #endif
190 |
191 |
192 | /*
193 | * COSMIC Compiler
194 | */
195 | #elif defined ( __CSMC__ )
196 | #include
197 |
198 | #ifndef __ASM
199 | #define __ASM _asm
200 | #endif
201 | #ifndef __INLINE
202 | #define __INLINE inline
203 | #endif
204 | #ifndef __STATIC_INLINE
205 | #define __STATIC_INLINE static inline
206 | #endif
207 | #ifndef __STATIC_FORCEINLINE
208 | #define __STATIC_FORCEINLINE __STATIC_INLINE
209 | #endif
210 | #ifndef __NO_RETURN
211 | // NO RETURN is automatically detected hence no warning here
212 | #define __NO_RETURN
213 | #endif
214 | #ifndef __USED
215 | #warning No compiler specific solution for __USED. __USED is ignored.
216 | #define __USED
217 | #endif
218 | #ifndef __WEAK
219 | #define __WEAK __weak
220 | #endif
221 | #ifndef __PACKED
222 | #define __PACKED @packed
223 | #endif
224 | #ifndef __PACKED_STRUCT
225 | #define __PACKED_STRUCT @packed struct
226 | #endif
227 | #ifndef __PACKED_UNION
228 | #define __PACKED_UNION @packed union
229 | #endif
230 | #ifndef __UNALIGNED_UINT32 /* deprecated */
231 | @packed struct T_UINT32 { uint32_t v; };
232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
233 | #endif
234 | #ifndef __UNALIGNED_UINT16_WRITE
235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
237 | #endif
238 | #ifndef __UNALIGNED_UINT16_READ
239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
241 | #endif
242 | #ifndef __UNALIGNED_UINT32_WRITE
243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
245 | #endif
246 | #ifndef __UNALIGNED_UINT32_READ
247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
249 | #endif
250 | #ifndef __ALIGNED
251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
252 | #define __ALIGNED(x)
253 | #endif
254 | #ifndef __RESTRICT
255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
256 | #define __RESTRICT
257 | #endif
258 |
259 |
260 | #else
261 | #error Unknown compiler.
262 | #endif
263 |
264 |
265 | #endif /* __CMSIS_COMPILER_H */
266 |
267 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Include/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.2
5 | * @date 19. April 2017
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef __CMSIS_VERSION_H
32 | #define __CMSIS_VERSION_H
33 |
34 | /* CMSIS Version definitions */
35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
39 | #endif
40 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Include/mpu_armv7.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file mpu_armv7.h
3 | * @brief CMSIS MPU API for Armv7-M MPU
4 | * @version V5.0.4
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef ARM_MPU_ARMV7_H
32 | #define ARM_MPU_ARMV7_H
33 |
34 | #define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes
35 | #define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes
36 | #define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes
37 | #define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes
38 | #define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes
39 | #define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte
40 | #define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes
41 | #define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes
42 | #define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes
43 | #define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes
44 | #define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes
45 | #define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes
46 | #define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes
47 | #define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes
48 | #define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes
49 | #define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte
50 | #define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes
51 | #define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes
52 | #define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes
53 | #define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes
54 | #define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes
55 | #define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes
56 | #define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes
57 | #define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes
58 | #define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes
59 | #define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte
60 | #define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes
61 | #define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes
62 |
63 | #define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access
64 | #define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only
65 | #define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only
66 | #define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access
67 | #define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only
68 | #define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access
69 |
70 | /** MPU Region Base Address Register Value
71 | *
72 | * \param Region The region to be configured, number 0 to 15.
73 | * \param BaseAddress The base address for the region.
74 | */
75 | #define ARM_MPU_RBAR(Region, BaseAddress) \
76 | (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
77 | ((Region) & MPU_RBAR_REGION_Msk) | \
78 | (MPU_RBAR_VALID_Msk))
79 |
80 | /**
81 | * MPU Memory Access Attributes
82 | *
83 | * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
84 | * \param IsShareable Region is shareable between multiple bus masters.
85 | * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
86 | * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
87 | */
88 | #define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
89 | ((((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
90 | (((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
91 | (((IsCacheable ) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
92 | (((IsBufferable ) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk))
93 |
94 | /**
95 | * MPU Region Attribute and Size Register Value
96 | *
97 | * \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
98 | * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
99 | * \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
100 | * \param SubRegionDisable Sub-region disable field.
101 | * \param Size Region size of the region to be configured, for example 4K, 8K.
102 | */
103 | #define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \
104 | ((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
105 | (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
106 | (((AccessAttributes) ) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk)))
107 |
108 | /**
109 | * MPU Region Attribute and Size Register Value
110 | *
111 | * \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
112 | * \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
113 | * \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
114 | * \param IsShareable Region is shareable between multiple bus masters.
115 | * \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
116 | * \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
117 | * \param SubRegionDisable Sub-region disable field.
118 | * \param Size Region size of the region to be configured, for example 4K, 8K.
119 | */
120 | #define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
121 | ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
122 |
123 | /**
124 | * MPU Memory Access Attribute for strongly ordered memory.
125 | * - TEX: 000b
126 | * - Shareable
127 | * - Non-cacheable
128 | * - Non-bufferable
129 | */
130 | #define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
131 |
132 | /**
133 | * MPU Memory Access Attribute for device memory.
134 | * - TEX: 000b (if non-shareable) or 010b (if shareable)
135 | * - Shareable or non-shareable
136 | * - Non-cacheable
137 | * - Bufferable (if shareable) or non-bufferable (if non-shareable)
138 | *
139 | * \param IsShareable Configures the device memory as shareable or non-shareable.
140 | */
141 | #define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
142 |
143 | /**
144 | * MPU Memory Access Attribute for normal memory.
145 | * - TEX: 1BBb (reflecting outer cacheability rules)
146 | * - Shareable or non-shareable
147 | * - Cacheable or non-cacheable (reflecting inner cacheability rules)
148 | * - Bufferable or non-bufferable (reflecting inner cacheability rules)
149 | *
150 | * \param OuterCp Configures the outer cache policy.
151 | * \param InnerCp Configures the inner cache policy.
152 | * \param IsShareable Configures the memory as shareable or non-shareable.
153 | */
154 | #define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U))
155 |
156 | /**
157 | * MPU Memory Access Attribute non-cacheable policy.
158 | */
159 | #define ARM_MPU_CACHEP_NOCACHE 0U
160 |
161 | /**
162 | * MPU Memory Access Attribute write-back, write and read allocate policy.
163 | */
164 | #define ARM_MPU_CACHEP_WB_WRA 1U
165 |
166 | /**
167 | * MPU Memory Access Attribute write-through, no write allocate policy.
168 | */
169 | #define ARM_MPU_CACHEP_WT_NWA 2U
170 |
171 | /**
172 | * MPU Memory Access Attribute write-back, no write allocate policy.
173 | */
174 | #define ARM_MPU_CACHEP_WB_NWA 3U
175 |
176 |
177 | /**
178 | * Struct for a single MPU Region
179 | */
180 | typedef struct {
181 | uint32_t RBAR; //!< The region base address register value (RBAR)
182 | uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
183 | } ARM_MPU_Region_t;
184 |
185 | /** Enable the MPU.
186 | * \param MPU_Control Default access permissions for unconfigured regions.
187 | */
188 | __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
189 | {
190 | __DSB();
191 | __ISB();
192 | MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
193 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
194 | SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
195 | #endif
196 | }
197 |
198 | /** Disable the MPU.
199 | */
200 | __STATIC_INLINE void ARM_MPU_Disable(void)
201 | {
202 | __DSB();
203 | __ISB();
204 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
205 | SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
206 | #endif
207 | MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
208 | }
209 |
210 | /** Clear and disable the given MPU region.
211 | * \param rnr Region number to be cleared.
212 | */
213 | __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
214 | {
215 | MPU->RNR = rnr;
216 | MPU->RASR = 0U;
217 | }
218 |
219 | /** Configure an MPU region.
220 | * \param rbar Value for RBAR register.
221 | * \param rsar Value for RSAR register.
222 | */
223 | __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
224 | {
225 | MPU->RBAR = rbar;
226 | MPU->RASR = rasr;
227 | }
228 |
229 | /** Configure the given MPU region.
230 | * \param rnr Region number to be configured.
231 | * \param rbar Value for RBAR register.
232 | * \param rsar Value for RSAR register.
233 | */
234 | __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
235 | {
236 | MPU->RNR = rnr;
237 | MPU->RBAR = rbar;
238 | MPU->RASR = rasr;
239 | }
240 |
241 | /** Memcopy with strictly ordered memory access, e.g. for register targets.
242 | * \param dst Destination data is copied to.
243 | * \param src Source data is copied from.
244 | * \param len Amount of data words to be copied.
245 | */
246 | __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
247 | {
248 | uint32_t i;
249 | for (i = 0U; i < len; ++i)
250 | {
251 | dst[i] = src[i];
252 | }
253 | }
254 |
255 | /** Load the given number of MPU regions from a table.
256 | * \param table Pointer to the MPU configuration table.
257 | * \param cnt Amount of regions to be configured.
258 | */
259 | __STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
260 | {
261 | const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
262 | while (cnt > MPU_TYPE_RALIASES) {
263 | orderedCpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
264 | table += MPU_TYPE_RALIASES;
265 | cnt -= MPU_TYPE_RALIASES;
266 | }
267 | orderedCpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
268 | }
269 |
270 | #endif
271 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Include/mpu_armv8.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file mpu_armv8.h
3 | * @brief CMSIS MPU API for Armv8-M MPU
4 | * @version V5.0.4
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef ARM_MPU_ARMV8_H
32 | #define ARM_MPU_ARMV8_H
33 |
34 | /** \brief Attribute for device memory (outer only) */
35 | #define ARM_MPU_ATTR_DEVICE ( 0U )
36 |
37 | /** \brief Attribute for non-cacheable, normal memory */
38 | #define ARM_MPU_ATTR_NON_CACHEABLE ( 4U )
39 |
40 | /** \brief Attribute for normal memory (outer and inner)
41 | * \param NT Non-Transient: Set to 1 for non-transient data.
42 | * \param WB Write-Back: Set to 1 to use write-back update policy.
43 | * \param RA Read Allocation: Set to 1 to use cache allocation on read miss.
44 | * \param WA Write Allocation: Set to 1 to use cache allocation on write miss.
45 | */
46 | #define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \
47 | (((NT & 1U) << 3U) | ((WB & 1U) << 2U) | ((RA & 1U) << 1U) | (WA & 1U))
48 |
49 | /** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */
50 | #define ARM_MPU_ATTR_DEVICE_nGnRnE (0U)
51 |
52 | /** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */
53 | #define ARM_MPU_ATTR_DEVICE_nGnRE (1U)
54 |
55 | /** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */
56 | #define ARM_MPU_ATTR_DEVICE_nGRE (2U)
57 |
58 | /** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */
59 | #define ARM_MPU_ATTR_DEVICE_GRE (3U)
60 |
61 | /** \brief Memory Attribute
62 | * \param O Outer memory attributes
63 | * \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes
64 | */
65 | #define ARM_MPU_ATTR(O, I) (((O & 0xFU) << 4U) | (((O & 0xFU) != 0U) ? (I & 0xFU) : ((I & 0x3U) << 2U)))
66 |
67 | /** \brief Normal memory non-shareable */
68 | #define ARM_MPU_SH_NON (0U)
69 |
70 | /** \brief Normal memory outer shareable */
71 | #define ARM_MPU_SH_OUTER (2U)
72 |
73 | /** \brief Normal memory inner shareable */
74 | #define ARM_MPU_SH_INNER (3U)
75 |
76 | /** \brief Memory access permissions
77 | * \param RO Read-Only: Set to 1 for read-only memory.
78 | * \param NP Non-Privileged: Set to 1 for non-privileged memory.
79 | */
80 | #define ARM_MPU_AP_(RO, NP) (((RO & 1U) << 1U) | (NP & 1U))
81 |
82 | /** \brief Region Base Address Register value
83 | * \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned.
84 | * \param SH Defines the Shareability domain for this memory region.
85 | * \param RO Read-Only: Set to 1 for a read-only memory region.
86 | * \param NP Non-Privileged: Set to 1 for a non-privileged memory region.
87 | * \oaram XN eXecute Never: Set to 1 for a non-executable memory region.
88 | */
89 | #define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \
90 | ((BASE & MPU_RBAR_BASE_Msk) | \
91 | ((SH << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \
92 | ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \
93 | ((XN << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk))
94 |
95 | /** \brief Region Limit Address Register value
96 | * \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended.
97 | * \param IDX The attribute index to be associated with this memory region.
98 | */
99 | #define ARM_MPU_RLAR(LIMIT, IDX) \
100 | ((LIMIT & MPU_RLAR_LIMIT_Msk) | \
101 | ((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
102 | (MPU_RLAR_EN_Msk))
103 |
104 | /**
105 | * Struct for a single MPU Region
106 | */
107 | typedef struct {
108 | uint32_t RBAR; /*!< Region Base Address Register value */
109 | uint32_t RLAR; /*!< Region Limit Address Register value */
110 | } ARM_MPU_Region_t;
111 |
112 | /** Enable the MPU.
113 | * \param MPU_Control Default access permissions for unconfigured regions.
114 | */
115 | __STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
116 | {
117 | __DSB();
118 | __ISB();
119 | MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
120 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
121 | SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
122 | #endif
123 | }
124 |
125 | /** Disable the MPU.
126 | */
127 | __STATIC_INLINE void ARM_MPU_Disable(void)
128 | {
129 | __DSB();
130 | __ISB();
131 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
132 | SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
133 | #endif
134 | MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
135 | }
136 |
137 | #ifdef MPU_NS
138 | /** Enable the Non-secure MPU.
139 | * \param MPU_Control Default access permissions for unconfigured regions.
140 | */
141 | __STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control)
142 | {
143 | __DSB();
144 | __ISB();
145 | MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
146 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
147 | SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
148 | #endif
149 | }
150 |
151 | /** Disable the Non-secure MPU.
152 | */
153 | __STATIC_INLINE void ARM_MPU_Disable_NS(void)
154 | {
155 | __DSB();
156 | __ISB();
157 | #ifdef SCB_SHCSR_MEMFAULTENA_Msk
158 | SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
159 | #endif
160 | MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk;
161 | }
162 | #endif
163 |
164 | /** Set the memory attribute encoding to the given MPU.
165 | * \param mpu Pointer to the MPU to be configured.
166 | * \param idx The attribute index to be set [0-7]
167 | * \param attr The attribute value to be set.
168 | */
169 | __STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr)
170 | {
171 | const uint8_t reg = idx / 4U;
172 | const uint32_t pos = ((idx % 4U) * 8U);
173 | const uint32_t mask = 0xFFU << pos;
174 |
175 | if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) {
176 | return; // invalid index
177 | }
178 |
179 | mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask));
180 | }
181 |
182 | /** Set the memory attribute encoding.
183 | * \param idx The attribute index to be set [0-7]
184 | * \param attr The attribute value to be set.
185 | */
186 | __STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr)
187 | {
188 | ARM_MPU_SetMemAttrEx(MPU, idx, attr);
189 | }
190 |
191 | #ifdef MPU_NS
192 | /** Set the memory attribute encoding to the Non-secure MPU.
193 | * \param idx The attribute index to be set [0-7]
194 | * \param attr The attribute value to be set.
195 | */
196 | __STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr)
197 | {
198 | ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr);
199 | }
200 | #endif
201 |
202 | /** Clear and disable the given MPU region of the given MPU.
203 | * \param mpu Pointer to MPU to be used.
204 | * \param rnr Region number to be cleared.
205 | */
206 | __STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr)
207 | {
208 | mpu->RNR = rnr;
209 | mpu->RLAR = 0U;
210 | }
211 |
212 | /** Clear and disable the given MPU region.
213 | * \param rnr Region number to be cleared.
214 | */
215 | __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
216 | {
217 | ARM_MPU_ClrRegionEx(MPU, rnr);
218 | }
219 |
220 | #ifdef MPU_NS
221 | /** Clear and disable the given Non-secure MPU region.
222 | * \param rnr Region number to be cleared.
223 | */
224 | __STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr)
225 | {
226 | ARM_MPU_ClrRegionEx(MPU_NS, rnr);
227 | }
228 | #endif
229 |
230 | /** Configure the given MPU region of the given MPU.
231 | * \param mpu Pointer to MPU to be used.
232 | * \param rnr Region number to be configured.
233 | * \param rbar Value for RBAR register.
234 | * \param rlar Value for RLAR register.
235 | */
236 | __STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar)
237 | {
238 | mpu->RNR = rnr;
239 | mpu->RBAR = rbar;
240 | mpu->RLAR = rlar;
241 | }
242 |
243 | /** Configure the given MPU region.
244 | * \param rnr Region number to be configured.
245 | * \param rbar Value for RBAR register.
246 | * \param rlar Value for RLAR register.
247 | */
248 | __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar)
249 | {
250 | ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar);
251 | }
252 |
253 | #ifdef MPU_NS
254 | /** Configure the given Non-secure MPU region.
255 | * \param rnr Region number to be configured.
256 | * \param rbar Value for RBAR register.
257 | * \param rlar Value for RLAR register.
258 | */
259 | __STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar)
260 | {
261 | ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar);
262 | }
263 | #endif
264 |
265 | /** Memcopy with strictly ordered memory access, e.g. for register targets.
266 | * \param dst Destination data is copied to.
267 | * \param src Source data is copied from.
268 | * \param len Amount of data words to be copied.
269 | */
270 | __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
271 | {
272 | uint32_t i;
273 | for (i = 0U; i < len; ++i)
274 | {
275 | dst[i] = src[i];
276 | }
277 | }
278 |
279 | /** Load the given number of MPU regions from a table to the given MPU.
280 | * \param mpu Pointer to the MPU registers to be used.
281 | * \param rnr First region number to be configured.
282 | * \param table Pointer to the MPU configuration table.
283 | * \param cnt Amount of regions to be configured.
284 | */
285 | __STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
286 | {
287 | const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
288 | if (cnt == 1U) {
289 | mpu->RNR = rnr;
290 | orderedCpy(&(mpu->RBAR), &(table->RBAR), rowWordSize);
291 | } else {
292 | uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U);
293 | uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES;
294 |
295 | mpu->RNR = rnrBase;
296 | while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) {
297 | uint32_t c = MPU_TYPE_RALIASES - rnrOffset;
298 | orderedCpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize);
299 | table += c;
300 | cnt -= c;
301 | rnrOffset = 0U;
302 | rnrBase += MPU_TYPE_RALIASES;
303 | mpu->RNR = rnrBase;
304 | }
305 |
306 | orderedCpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize);
307 | }
308 | }
309 |
310 | /** Load the given number of MPU regions from a table.
311 | * \param rnr First region number to be configured.
312 | * \param table Pointer to the MPU configuration table.
313 | * \param cnt Amount of regions to be configured.
314 | */
315 | __STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
316 | {
317 | ARM_MPU_LoadEx(MPU, rnr, table, cnt);
318 | }
319 |
320 | #ifdef MPU_NS
321 | /** Load the given number of MPU regions from a table to the Non-secure MPU.
322 | * \param rnr First region number to be configured.
323 | * \param table Pointer to the MPU configuration table.
324 | * \param cnt Amount of regions to be configured.
325 | */
326 | __STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
327 | {
328 | ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt);
329 | }
330 | #endif
331 |
332 | #endif
333 |
334 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/CMSIS/Include/tz_context.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file tz_context.h
3 | * @brief Context Management for Armv8-M TrustZone
4 | * @version V1.0.1
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef TZ_CONTEXT_H
32 | #define TZ_CONTEXT_H
33 |
34 | #include
35 |
36 | #ifndef TZ_MODULEID_T
37 | #define TZ_MODULEID_T
38 | /// \details Data type that identifies secure software modules called by a process.
39 | typedef uint32_t TZ_ModuleId_t;
40 | #endif
41 |
42 | /// \details TZ Memory ID identifies an allocated memory slot.
43 | typedef uint32_t TZ_MemoryId_t;
44 |
45 | /// Initialize secure context memory system
46 | /// \return execution status (1: success, 0: error)
47 | uint32_t TZ_InitContextSystem_S (void);
48 |
49 | /// Allocate context memory for calling secure software modules in TrustZone
50 | /// \param[in] module identifies software modules called from non-secure mode
51 | /// \return value != 0 id TrustZone memory slot identifier
52 | /// \return value 0 no memory available or internal error
53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
54 |
55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
56 | /// \param[in] id TrustZone memory slot identifier
57 | /// \return execution status (1: success, 0: error)
58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
59 |
60 | /// Load secure context (called on RTOS thread context switch)
61 | /// \param[in] id TrustZone memory slot identifier
62 | /// \return execution status (1: success, 0: error)
63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
64 |
65 | /// Store secure context (called on RTOS thread context switch)
66 | /// \param[in] id TrustZone memory slot identifier
67 | /// \return execution status (1: success, 0: error)
68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
69 |
70 | #endif // TZ_CONTEXT_H
71 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal.h
4 | * @author MCD Application Team
5 | * @brief This file contains all the functions prototypes for the HAL
6 | * module driver.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2017 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F1xx_HAL_H
23 | #define __STM32F1xx_HAL_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm32f1xx_hal_conf.h"
31 |
32 | /** @addtogroup STM32F1xx_HAL_Driver
33 | * @{
34 | */
35 |
36 | /** @addtogroup HAL
37 | * @{
38 | */
39 |
40 | /* Exported constants --------------------------------------------------------*/
41 |
42 | /** @defgroup HAL_Exported_Constants HAL Exported Constants
43 | * @{
44 | */
45 |
46 | /** @defgroup HAL_TICK_FREQ Tick Frequency
47 | * @{
48 | */
49 | typedef enum
50 | {
51 | HAL_TICK_FREQ_10HZ = 100U,
52 | HAL_TICK_FREQ_100HZ = 10U,
53 | HAL_TICK_FREQ_1KHZ = 1U,
54 | HAL_TICK_FREQ_DEFAULT = HAL_TICK_FREQ_1KHZ
55 | } HAL_TickFreqTypeDef;
56 | /**
57 | * @}
58 | */
59 | /* Exported types ------------------------------------------------------------*/
60 | extern __IO uint32_t uwTick;
61 | extern uint32_t uwTickPrio;
62 | extern HAL_TickFreqTypeDef uwTickFreq;
63 |
64 | /**
65 | * @}
66 | */
67 | /* Exported macro ------------------------------------------------------------*/
68 | /** @defgroup HAL_Exported_Macros HAL Exported Macros
69 | * @{
70 | */
71 |
72 | /** @defgroup DBGMCU_Freeze_Unfreeze Freeze Unfreeze Peripherals in Debug mode
73 | * @brief Freeze/Unfreeze Peripherals in Debug mode
74 | * Note: On devices STM32F10xx8 and STM32F10xxB,
75 | * STM32F101xC/D/E and STM32F103xC/D/E,
76 | * STM32F101xF/G and STM32F103xF/G
77 | * STM32F10xx4 and STM32F10xx6
78 | * Debug registers DBGMCU_IDCODE and DBGMCU_CR are accessible only in
79 | * debug mode (not accessible by the user software in normal mode).
80 | * Refer to errata sheet of these devices for more details.
81 | * @{
82 | */
83 |
84 | /* Peripherals on APB1 */
85 | /**
86 | * @brief TIM2 Peripherals Debug mode
87 | */
88 | #define __HAL_DBGMCU_FREEZE_TIM2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
89 | #define __HAL_DBGMCU_UNFREEZE_TIM2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM2_STOP)
90 |
91 | /**
92 | * @brief TIM3 Peripherals Debug mode
93 | */
94 | #define __HAL_DBGMCU_FREEZE_TIM3() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
95 | #define __HAL_DBGMCU_UNFREEZE_TIM3() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM3_STOP)
96 |
97 | #if defined (DBGMCU_CR_DBG_TIM4_STOP)
98 | /**
99 | * @brief TIM4 Peripherals Debug mode
100 | */
101 | #define __HAL_DBGMCU_FREEZE_TIM4() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
102 | #define __HAL_DBGMCU_UNFREEZE_TIM4() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM4_STOP)
103 | #endif
104 |
105 | #if defined (DBGMCU_CR_DBG_TIM5_STOP)
106 | /**
107 | * @brief TIM5 Peripherals Debug mode
108 | */
109 | #define __HAL_DBGMCU_FREEZE_TIM5() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
110 | #define __HAL_DBGMCU_UNFREEZE_TIM5() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM5_STOP)
111 | #endif
112 |
113 | #if defined (DBGMCU_CR_DBG_TIM6_STOP)
114 | /**
115 | * @brief TIM6 Peripherals Debug mode
116 | */
117 | #define __HAL_DBGMCU_FREEZE_TIM6() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
118 | #define __HAL_DBGMCU_UNFREEZE_TIM6() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM6_STOP)
119 | #endif
120 |
121 | #if defined (DBGMCU_CR_DBG_TIM7_STOP)
122 | /**
123 | * @brief TIM7 Peripherals Debug mode
124 | */
125 | #define __HAL_DBGMCU_FREEZE_TIM7() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
126 | #define __HAL_DBGMCU_UNFREEZE_TIM7() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM7_STOP)
127 | #endif
128 |
129 | #if defined (DBGMCU_CR_DBG_TIM12_STOP)
130 | /**
131 | * @brief TIM12 Peripherals Debug mode
132 | */
133 | #define __HAL_DBGMCU_FREEZE_TIM12() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
134 | #define __HAL_DBGMCU_UNFREEZE_TIM12() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM12_STOP)
135 | #endif
136 |
137 | #if defined (DBGMCU_CR_DBG_TIM13_STOP)
138 | /**
139 | * @brief TIM13 Peripherals Debug mode
140 | */
141 | #define __HAL_DBGMCU_FREEZE_TIM13() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
142 | #define __HAL_DBGMCU_UNFREEZE_TIM13() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM13_STOP)
143 | #endif
144 |
145 | #if defined (DBGMCU_CR_DBG_TIM14_STOP)
146 | /**
147 | * @brief TIM14 Peripherals Debug mode
148 | */
149 | #define __HAL_DBGMCU_FREEZE_TIM14() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
150 | #define __HAL_DBGMCU_UNFREEZE_TIM14() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM14_STOP)
151 | #endif
152 |
153 | /**
154 | * @brief WWDG Peripherals Debug mode
155 | */
156 | #define __HAL_DBGMCU_FREEZE_WWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
157 | #define __HAL_DBGMCU_UNFREEZE_WWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_WWDG_STOP)
158 |
159 | /**
160 | * @brief IWDG Peripherals Debug mode
161 | */
162 | #define __HAL_DBGMCU_FREEZE_IWDG() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
163 | #define __HAL_DBGMCU_UNFREEZE_IWDG() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_IWDG_STOP)
164 |
165 | /**
166 | * @brief I2C1 Peripherals Debug mode
167 | */
168 | #define __HAL_DBGMCU_FREEZE_I2C1_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
169 | #define __HAL_DBGMCU_UNFREEZE_I2C1_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C1_SMBUS_TIMEOUT)
170 |
171 | #if defined (DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
172 | /**
173 | * @brief I2C2 Peripherals Debug mode
174 | */
175 | #define __HAL_DBGMCU_FREEZE_I2C2_TIMEOUT() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
176 | #define __HAL_DBGMCU_UNFREEZE_I2C2_TIMEOUT() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_I2C2_SMBUS_TIMEOUT)
177 | #endif
178 |
179 | #if defined (DBGMCU_CR_DBG_CAN1_STOP)
180 | /**
181 | * @brief CAN1 Peripherals Debug mode
182 | */
183 | #define __HAL_DBGMCU_FREEZE_CAN1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
184 | #define __HAL_DBGMCU_UNFREEZE_CAN1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN1_STOP)
185 | #endif
186 |
187 | #if defined (DBGMCU_CR_DBG_CAN2_STOP)
188 | /**
189 | * @brief CAN2 Peripherals Debug mode
190 | */
191 | #define __HAL_DBGMCU_FREEZE_CAN2() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
192 | #define __HAL_DBGMCU_UNFREEZE_CAN2() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_CAN2_STOP)
193 | #endif
194 |
195 | /* Peripherals on APB2 */
196 | #if defined (DBGMCU_CR_DBG_TIM1_STOP)
197 | /**
198 | * @brief TIM1 Peripherals Debug mode
199 | */
200 | #define __HAL_DBGMCU_FREEZE_TIM1() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
201 | #define __HAL_DBGMCU_UNFREEZE_TIM1() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM1_STOP)
202 | #endif
203 |
204 | #if defined (DBGMCU_CR_DBG_TIM8_STOP)
205 | /**
206 | * @brief TIM8 Peripherals Debug mode
207 | */
208 | #define __HAL_DBGMCU_FREEZE_TIM8() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
209 | #define __HAL_DBGMCU_UNFREEZE_TIM8() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM8_STOP)
210 | #endif
211 |
212 | #if defined (DBGMCU_CR_DBG_TIM9_STOP)
213 | /**
214 | * @brief TIM9 Peripherals Debug mode
215 | */
216 | #define __HAL_DBGMCU_FREEZE_TIM9() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
217 | #define __HAL_DBGMCU_UNFREEZE_TIM9() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM9_STOP)
218 | #endif
219 |
220 | #if defined (DBGMCU_CR_DBG_TIM10_STOP)
221 | /**
222 | * @brief TIM10 Peripherals Debug mode
223 | */
224 | #define __HAL_DBGMCU_FREEZE_TIM10() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
225 | #define __HAL_DBGMCU_UNFREEZE_TIM10() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM10_STOP)
226 | #endif
227 |
228 | #if defined (DBGMCU_CR_DBG_TIM11_STOP)
229 | /**
230 | * @brief TIM11 Peripherals Debug mode
231 | */
232 | #define __HAL_DBGMCU_FREEZE_TIM11() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
233 | #define __HAL_DBGMCU_UNFREEZE_TIM11() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM11_STOP)
234 | #endif
235 |
236 |
237 | #if defined (DBGMCU_CR_DBG_TIM15_STOP)
238 | /**
239 | * @brief TIM15 Peripherals Debug mode
240 | */
241 | #define __HAL_DBGMCU_FREEZE_TIM15() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
242 | #define __HAL_DBGMCU_UNFREEZE_TIM15() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM15_STOP)
243 | #endif
244 |
245 | #if defined (DBGMCU_CR_DBG_TIM16_STOP)
246 | /**
247 | * @brief TIM16 Peripherals Debug mode
248 | */
249 | #define __HAL_DBGMCU_FREEZE_TIM16() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
250 | #define __HAL_DBGMCU_UNFREEZE_TIM16() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM16_STOP)
251 | #endif
252 |
253 | #if defined (DBGMCU_CR_DBG_TIM17_STOP)
254 | /**
255 | * @brief TIM17 Peripherals Debug mode
256 | */
257 | #define __HAL_DBGMCU_FREEZE_TIM17() SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
258 | #define __HAL_DBGMCU_UNFREEZE_TIM17() CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_TIM17_STOP)
259 | #endif
260 |
261 | /**
262 | * @}
263 | */
264 |
265 | /** @defgroup HAL_Private_Macros HAL Private Macros
266 | * @{
267 | */
268 | #define IS_TICKFREQ(FREQ) (((FREQ) == HAL_TICK_FREQ_10HZ) || \
269 | ((FREQ) == HAL_TICK_FREQ_100HZ) || \
270 | ((FREQ) == HAL_TICK_FREQ_1KHZ))
271 | /**
272 | * @}
273 | */
274 |
275 | /* Exported functions --------------------------------------------------------*/
276 | /** @addtogroup HAL_Exported_Functions
277 | * @{
278 | */
279 | /** @addtogroup HAL_Exported_Functions_Group1
280 | * @{
281 | */
282 | /* Initialization and de-initialization functions ******************************/
283 | HAL_StatusTypeDef HAL_Init(void);
284 | HAL_StatusTypeDef HAL_DeInit(void);
285 | void HAL_MspInit(void);
286 | void HAL_MspDeInit(void);
287 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority);
288 | /**
289 | * @}
290 | */
291 |
292 | /** @addtogroup HAL_Exported_Functions_Group2
293 | * @{
294 | */
295 | /* Peripheral Control functions ************************************************/
296 | void HAL_IncTick(void);
297 | void HAL_Delay(uint32_t Delay);
298 | uint32_t HAL_GetTick(void);
299 | uint32_t HAL_GetTickPrio(void);
300 | HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq);
301 | HAL_TickFreqTypeDef HAL_GetTickFreq(void);
302 | void HAL_SuspendTick(void);
303 | void HAL_ResumeTick(void);
304 | uint32_t HAL_GetHalVersion(void);
305 | uint32_t HAL_GetREVID(void);
306 | uint32_t HAL_GetDEVID(void);
307 | uint32_t HAL_GetUIDw0(void);
308 | uint32_t HAL_GetUIDw1(void);
309 | uint32_t HAL_GetUIDw2(void);
310 | void HAL_DBGMCU_EnableDBGSleepMode(void);
311 | void HAL_DBGMCU_DisableDBGSleepMode(void);
312 | void HAL_DBGMCU_EnableDBGStopMode(void);
313 | void HAL_DBGMCU_DisableDBGStopMode(void);
314 | void HAL_DBGMCU_EnableDBGStandbyMode(void);
315 | void HAL_DBGMCU_DisableDBGStandbyMode(void);
316 | /**
317 | * @}
318 | */
319 |
320 | /**
321 | * @}
322 | */
323 |
324 | /**
325 | * @}
326 | */
327 | /* Private types -------------------------------------------------------------*/
328 | /* Private variables ---------------------------------------------------------*/
329 | /** @defgroup HAL_Private_Variables HAL Private Variables
330 | * @{
331 | */
332 | /**
333 | * @}
334 | */
335 | /* Private constants ---------------------------------------------------------*/
336 | /** @defgroup HAL_Private_Constants HAL Private Constants
337 | * @{
338 | */
339 | /**
340 | * @}
341 | */
342 | /* Private macros ------------------------------------------------------------*/
343 | /* Private functions ---------------------------------------------------------*/
344 | /**
345 | * @}
346 | */
347 |
348 | /**
349 | * @}
350 | */
351 |
352 | #ifdef __cplusplus
353 | }
354 | #endif
355 |
356 | #endif /* __STM32F1xx_HAL_H */
357 |
358 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
359 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_def.h
4 | * @author MCD Application Team
5 | * @brief This file contains HAL common defines, enumeration, macros and
6 | * structures definitions.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2017 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F1xx_HAL_DEF
23 | #define __STM32F1xx_HAL_DEF
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm32f1xx.h"
31 | #include "Legacy/stm32_hal_legacy.h"
32 | #include
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 |
36 | /**
37 | * @brief HAL Status structures definition
38 | */
39 | typedef enum
40 | {
41 | HAL_OK = 0x00U,
42 | HAL_ERROR = 0x01U,
43 | HAL_BUSY = 0x02U,
44 | HAL_TIMEOUT = 0x03U
45 | } HAL_StatusTypeDef;
46 |
47 | /**
48 | * @brief HAL Lock structures definition
49 | */
50 | typedef enum
51 | {
52 | HAL_UNLOCKED = 0x00U,
53 | HAL_LOCKED = 0x01U
54 | } HAL_LockTypeDef;
55 |
56 | /* Exported macro ------------------------------------------------------------*/
57 | #define HAL_MAX_DELAY 0xFFFFFFFFU
58 |
59 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) != 0U)
60 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
61 |
62 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
63 | do{ \
64 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
65 | (__DMA_HANDLE__).Parent = (__HANDLE__); \
66 | } while(0U)
67 |
68 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
69 |
70 | /** @brief Reset the Handle's State field.
71 | * @param __HANDLE__ specifies the Peripheral Handle.
72 | * @note This macro can be used for the following purpose:
73 | * - When the Handle is declared as local variable; before passing it as parameter
74 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
75 | * to set to 0 the Handle's "State" field.
76 | * Otherwise, "State" field may have any random value and the first time the function
77 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed
78 | * (i.e. HAL_PPP_MspInit() will not be executed).
79 | * - When there is a need to reconfigure the low level hardware: instead of calling
80 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
81 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function
82 | * HAL_PPP_MspInit() which will reconfigure the low level hardware.
83 | * @retval None
84 | */
85 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
86 |
87 | #if (USE_RTOS == 1U)
88 | /* Reserved for future use */
89 | #error "USE_RTOS should be 0 in the current HAL release"
90 | #else
91 | #define __HAL_LOCK(__HANDLE__) \
92 | do{ \
93 | if((__HANDLE__)->Lock == HAL_LOCKED) \
94 | { \
95 | return HAL_BUSY; \
96 | } \
97 | else \
98 | { \
99 | (__HANDLE__)->Lock = HAL_LOCKED; \
100 | } \
101 | }while (0U)
102 |
103 | #define __HAL_UNLOCK(__HANDLE__) \
104 | do{ \
105 | (__HANDLE__)->Lock = HAL_UNLOCKED; \
106 | }while (0U)
107 | #endif /* USE_RTOS */
108 |
109 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
110 | #ifndef __weak
111 | #define __weak __attribute__((weak))
112 | #endif
113 | #ifndef __packed
114 | #define __packed __attribute__((packed))
115 | #endif
116 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
117 | #ifndef __weak
118 | #define __weak __attribute__((weak))
119 | #endif /* __weak */
120 | #ifndef __packed
121 | #define __packed __attribute__((__packed__))
122 | #endif /* __packed */
123 | #endif /* __GNUC__ */
124 |
125 |
126 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
127 | #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler V6 */
128 | #ifndef __ALIGN_BEGIN
129 | #define __ALIGN_BEGIN
130 | #endif
131 | #ifndef __ALIGN_END
132 | #define __ALIGN_END __attribute__ ((aligned (4)))
133 | #endif
134 | #elif defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
135 | #ifndef __ALIGN_END
136 | #define __ALIGN_END __attribute__ ((aligned (4)))
137 | #endif /* __ALIGN_END */
138 | #ifndef __ALIGN_BEGIN
139 | #define __ALIGN_BEGIN
140 | #endif /* __ALIGN_BEGIN */
141 | #else
142 | #ifndef __ALIGN_END
143 | #define __ALIGN_END
144 | #endif /* __ALIGN_END */
145 | #ifndef __ALIGN_BEGIN
146 | #if defined (__CC_ARM) /* ARM Compiler V5*/
147 | #define __ALIGN_BEGIN __align(4)
148 | #elif defined (__ICCARM__) /* IAR Compiler */
149 | #define __ALIGN_BEGIN
150 | #endif /* __CC_ARM */
151 | #endif /* __ALIGN_BEGIN */
152 | #endif /* __GNUC__ */
153 |
154 |
155 | /**
156 | * @brief __RAM_FUNC definition
157 | */
158 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
159 | /* ARM Compiler V4/V5 and V6
160 | --------------------------
161 | RAM functions are defined using the toolchain options.
162 | Functions that are executed in RAM should reside in a separate source module.
163 | Using the 'Options for File' dialog you can simply change the 'Code / Const'
164 | area of a module to a memory space in physical RAM.
165 | Available memory areas are declared in the 'Target' tab of the 'Options for Target'
166 | dialog.
167 | */
168 | #define __RAM_FUNC
169 |
170 | #elif defined ( __ICCARM__ )
171 | /* ICCARM Compiler
172 | ---------------
173 | RAM functions are defined using a specific toolchain keyword "__ramfunc".
174 | */
175 | #define __RAM_FUNC __ramfunc
176 |
177 | #elif defined ( __GNUC__ )
178 | /* GNU Compiler
179 | ------------
180 | RAM functions are defined using a specific toolchain attribute
181 | "__attribute__((section(".RamFunc")))".
182 | */
183 | #define __RAM_FUNC __attribute__((section(".RamFunc")))
184 |
185 | #endif
186 |
187 | /**
188 | * @brief __NOINLINE definition
189 | */
190 | #if defined ( __CC_ARM ) || (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || defined ( __GNUC__ )
191 | /* ARM V4/V5 and V6 & GNU Compiler
192 | -------------------------------
193 | */
194 | #define __NOINLINE __attribute__ ( (noinline) )
195 |
196 | #elif defined ( __ICCARM__ )
197 | /* ICCARM Compiler
198 | ---------------
199 | */
200 | #define __NOINLINE _Pragma("optimize = no_inline")
201 |
202 | #endif
203 |
204 | #ifdef __cplusplus
205 | }
206 | #endif
207 |
208 | #endif /* ___STM32F1xx_HAL_DEF */
209 |
210 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
211 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_flash.h
4 | * @author MCD Application Team
5 | * @brief Header file of Flash HAL module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __STM32F1xx_HAL_FLASH_H
22 | #define __STM32F1xx_HAL_FLASH_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f1xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F1xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup FLASH
36 | * @{
37 | */
38 |
39 | /** @addtogroup FLASH_Private_Constants
40 | * @{
41 | */
42 | #define FLASH_TIMEOUT_VALUE 50000U /* 50 s */
43 | /**
44 | * @}
45 | */
46 |
47 | /** @addtogroup FLASH_Private_Macros
48 | * @{
49 | */
50 |
51 | #define IS_FLASH_TYPEPROGRAM(VALUE) (((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \
52 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \
53 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD))
54 |
55 | #if defined(FLASH_ACR_LATENCY)
56 | #define IS_FLASH_LATENCY(__LATENCY__) (((__LATENCY__) == FLASH_LATENCY_0) || \
57 | ((__LATENCY__) == FLASH_LATENCY_1) || \
58 | ((__LATENCY__) == FLASH_LATENCY_2))
59 |
60 | #else
61 | #define IS_FLASH_LATENCY(__LATENCY__) ((__LATENCY__) == FLASH_LATENCY_0)
62 | #endif /* FLASH_ACR_LATENCY */
63 | /**
64 | * @}
65 | */
66 |
67 | /* Exported types ------------------------------------------------------------*/
68 | /** @defgroup FLASH_Exported_Types FLASH Exported Types
69 | * @{
70 | */
71 |
72 | /**
73 | * @brief FLASH Procedure structure definition
74 | */
75 | typedef enum
76 | {
77 | FLASH_PROC_NONE = 0U,
78 | FLASH_PROC_PAGEERASE = 1U,
79 | FLASH_PROC_MASSERASE = 2U,
80 | FLASH_PROC_PROGRAMHALFWORD = 3U,
81 | FLASH_PROC_PROGRAMWORD = 4U,
82 | FLASH_PROC_PROGRAMDOUBLEWORD = 5U
83 | } FLASH_ProcedureTypeDef;
84 |
85 | /**
86 | * @brief FLASH handle Structure definition
87 | */
88 | typedef struct
89 | {
90 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*!< Internal variable to indicate which procedure is ongoing or not in IT context */
91 |
92 | __IO uint32_t DataRemaining; /*!< Internal variable to save the remaining pages to erase or half-word to program in IT context */
93 |
94 | __IO uint32_t Address; /*!< Internal variable to save address selected for program or erase */
95 |
96 | __IO uint64_t Data; /*!< Internal variable to save data to be programmed */
97 |
98 | HAL_LockTypeDef Lock; /*!< FLASH locking object */
99 |
100 | __IO uint32_t ErrorCode; /*!< FLASH error code
101 | This parameter can be a value of @ref FLASH_Error_Codes */
102 | } FLASH_ProcessTypeDef;
103 |
104 | /**
105 | * @}
106 | */
107 |
108 | /* Exported constants --------------------------------------------------------*/
109 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
110 | * @{
111 | */
112 |
113 | /** @defgroup FLASH_Error_Codes FLASH Error Codes
114 | * @{
115 | */
116 |
117 | #define HAL_FLASH_ERROR_NONE 0x00U /*!< No error */
118 | #define HAL_FLASH_ERROR_PROG 0x01U /*!< Programming error */
119 | #define HAL_FLASH_ERROR_WRP 0x02U /*!< Write protection error */
120 | #define HAL_FLASH_ERROR_OPTV 0x04U /*!< Option validity error */
121 |
122 | /**
123 | * @}
124 | */
125 |
126 | /** @defgroup FLASH_Type_Program FLASH Type Program
127 | * @{
128 | */
129 | #define FLASH_TYPEPROGRAM_HALFWORD 0x01U /*!ACR |= FLASH_ACR_HLFCYA)
183 |
184 | /**
185 | * @brief Disable the FLASH half cycle access.
186 | * @note half cycle access can only be used with a low-frequency clock of less than
187 | 8 MHz that can be obtained with the use of HSI or HSE but not of PLL.
188 | * @retval None
189 | */
190 | #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
191 |
192 | /**
193 | * @}
194 | */
195 |
196 | #if defined(FLASH_ACR_LATENCY)
197 | /** @defgroup FLASH_EM_Latency FLASH Latency
198 | * @brief macros to handle FLASH Latency
199 | * @{
200 | */
201 |
202 | /**
203 | * @brief Set the FLASH Latency.
204 | * @param __LATENCY__ FLASH Latency
205 | * The value of this parameter depend on device used within the same series
206 | * @retval None
207 | */
208 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
209 |
210 |
211 | /**
212 | * @brief Get the FLASH Latency.
213 | * @retval FLASH Latency
214 | * The value of this parameter depend on device used within the same series
215 | */
216 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY))
217 |
218 | /**
219 | * @}
220 | */
221 |
222 | #endif /* FLASH_ACR_LATENCY */
223 | /** @defgroup FLASH_Prefetch FLASH Prefetch
224 | * @brief macros to handle FLASH Prefetch buffer
225 | * @{
226 | */
227 | /**
228 | * @brief Enable the FLASH prefetch buffer.
229 | * @retval None
230 | */
231 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE)
232 |
233 | /**
234 | * @brief Disable the FLASH prefetch buffer.
235 | * @retval None
236 | */
237 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
238 |
239 | /**
240 | * @}
241 | */
242 |
243 | /**
244 | * @}
245 | */
246 |
247 | /* Include FLASH HAL Extended module */
248 | #include "stm32f1xx_hal_flash_ex.h"
249 |
250 | /* Exported functions --------------------------------------------------------*/
251 | /** @addtogroup FLASH_Exported_Functions
252 | * @{
253 | */
254 |
255 | /** @addtogroup FLASH_Exported_Functions_Group1
256 | * @{
257 | */
258 | /* IO operation functions *****************************************************/
259 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
260 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
261 |
262 | /* FLASH IRQ handler function */
263 | void HAL_FLASH_IRQHandler(void);
264 | /* Callbacks in non blocking modes */
265 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
266 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
267 |
268 | /**
269 | * @}
270 | */
271 |
272 | /** @addtogroup FLASH_Exported_Functions_Group2
273 | * @{
274 | */
275 | /* Peripheral Control functions ***********************************************/
276 | HAL_StatusTypeDef HAL_FLASH_Unlock(void);
277 | HAL_StatusTypeDef HAL_FLASH_Lock(void);
278 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
279 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
280 | void HAL_FLASH_OB_Launch(void);
281 |
282 | /**
283 | * @}
284 | */
285 |
286 | /** @addtogroup FLASH_Exported_Functions_Group3
287 | * @{
288 | */
289 | /* Peripheral State and Error functions ***************************************/
290 | uint32_t HAL_FLASH_GetError(void);
291 |
292 | /**
293 | * @}
294 | */
295 |
296 | /**
297 | * @}
298 | */
299 |
300 | /* Private function -------------------------------------------------*/
301 | /** @addtogroup FLASH_Private_Functions
302 | * @{
303 | */
304 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
305 | #if defined(FLASH_BANK2_END)
306 | HAL_StatusTypeDef FLASH_WaitForLastOperationBank2(uint32_t Timeout);
307 | #endif /* FLASH_BANK2_END */
308 |
309 | /**
310 | * @}
311 | */
312 |
313 | /**
314 | * @}
315 | */
316 |
317 | /**
318 | * @}
319 | */
320 |
321 | #ifdef __cplusplus
322 | }
323 | #endif
324 |
325 | #endif /* __STM32F1xx_HAL_FLASH_H */
326 |
327 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
328 |
329 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pcd_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_pcd_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of PCD HAL Extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F1xx_HAL_PCD_EX_H
22 | #define STM32F1xx_HAL_PCD_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f1xx_hal_def.h"
30 |
31 | #if defined (USB) || defined (USB_OTG_FS)
32 | /** @addtogroup STM32F1xx_HAL_Driver
33 | * @{
34 | */
35 |
36 | /** @addtogroup PCDEx
37 | * @{
38 | */
39 | /* Exported types ------------------------------------------------------------*/
40 | /* Exported constants --------------------------------------------------------*/
41 | /* Exported macros -----------------------------------------------------------*/
42 | /* Exported functions --------------------------------------------------------*/
43 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions
44 | * @{
45 | */
46 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
47 | * @{
48 | */
49 |
50 | #if defined (USB_OTG_FS)
51 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size);
52 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size);
53 | #endif /* defined (USB_OTG_FS) */
54 |
55 | #if defined (USB)
56 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr,
57 | uint16_t ep_kind, uint32_t pmaadress);
58 |
59 | void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state);
60 | #endif /* defined (USB) */
61 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg);
62 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg);
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /**
77 | * @}
78 | */
79 | #endif /* defined (USB) || defined (USB_OTG_FS) */
80 |
81 | #ifdef __cplusplus
82 | }
83 | #endif
84 |
85 |
86 | #endif /* STM32F1xx_HAL_PCD_EX_H */
87 |
88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
89 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_tim_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of TIM HAL Extended module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2016 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F1xx_HAL_TIM_EX_H
22 | #define STM32F1xx_HAL_TIM_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f1xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F1xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup TIMEx
36 | * @{
37 | */
38 |
39 | /* Exported types ------------------------------------------------------------*/
40 | /** @defgroup TIMEx_Exported_Types TIM Extended Exported Types
41 | * @{
42 | */
43 |
44 | /**
45 | * @brief TIM Hall sensor Configuration Structure definition
46 | */
47 |
48 | typedef struct
49 | {
50 | uint32_t IC1Polarity; /*!< Specifies the active edge of the input signal.
51 | This parameter can be a value of @ref TIM_Input_Capture_Polarity */
52 |
53 | uint32_t IC1Prescaler; /*!< Specifies the Input Capture Prescaler.
54 | This parameter can be a value of @ref TIM_Input_Capture_Prescaler */
55 |
56 | uint32_t IC1Filter; /*!< Specifies the input capture filter.
57 | This parameter can be a number between Min_Data = 0x0 and Max_Data = 0xF */
58 |
59 | uint32_t Commutation_Delay; /*!< Specifies the pulse value to be loaded into the Capture Compare Register.
60 | This parameter can be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */
61 | } TIM_HallSensor_InitTypeDef;
62 | /**
63 | * @}
64 | */
65 | /* End of exported types -----------------------------------------------------*/
66 |
67 | /* Exported constants --------------------------------------------------------*/
68 | /** @defgroup TIMEx_Exported_Constants TIM Extended Exported Constants
69 | * @{
70 | */
71 |
72 | /** @defgroup TIMEx_Remap TIM Extended Remapping
73 | * @{
74 | */
75 | /**
76 | * @}
77 | */
78 |
79 | /**
80 | * @}
81 | */
82 | /* End of exported constants -------------------------------------------------*/
83 |
84 | /* Exported macro ------------------------------------------------------------*/
85 | /** @defgroup TIMEx_Exported_Macros TIM Extended Exported Macros
86 | * @{
87 | */
88 |
89 | /**
90 | * @}
91 | */
92 | /* End of exported macro -----------------------------------------------------*/
93 |
94 | /* Private macro -------------------------------------------------------------*/
95 | /** @defgroup TIMEx_Private_Macros TIM Extended Private Macros
96 | * @{
97 | */
98 |
99 | /**
100 | * @}
101 | */
102 | /* End of private macro ------------------------------------------------------*/
103 |
104 | /* Exported functions --------------------------------------------------------*/
105 | /** @addtogroup TIMEx_Exported_Functions TIM Extended Exported Functions
106 | * @{
107 | */
108 |
109 | /** @addtogroup TIMEx_Exported_Functions_Group1 Extended Timer Hall Sensor functions
110 | * @brief Timer Hall Sensor functions
111 | * @{
112 | */
113 | /* Timer Hall Sensor functions **********************************************/
114 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Init(TIM_HandleTypeDef *htim, TIM_HallSensor_InitTypeDef *sConfig);
115 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_DeInit(TIM_HandleTypeDef *htim);
116 |
117 | void HAL_TIMEx_HallSensor_MspInit(TIM_HandleTypeDef *htim);
118 | void HAL_TIMEx_HallSensor_MspDeInit(TIM_HandleTypeDef *htim);
119 |
120 | /* Blocking mode: Polling */
121 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start(TIM_HandleTypeDef *htim);
122 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop(TIM_HandleTypeDef *htim);
123 | /* Non-Blocking mode: Interrupt */
124 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_IT(TIM_HandleTypeDef *htim);
125 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_IT(TIM_HandleTypeDef *htim);
126 | /* Non-Blocking mode: DMA */
127 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Start_DMA(TIM_HandleTypeDef *htim, uint32_t *pData, uint16_t Length);
128 | HAL_StatusTypeDef HAL_TIMEx_HallSensor_Stop_DMA(TIM_HandleTypeDef *htim);
129 | /**
130 | * @}
131 | */
132 |
133 | /** @addtogroup TIMEx_Exported_Functions_Group2 Extended Timer Complementary Output Compare functions
134 | * @brief Timer Complementary Output Compare functions
135 | * @{
136 | */
137 | /* Timer Complementary Output Compare functions *****************************/
138 | /* Blocking mode: Polling */
139 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
140 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
141 |
142 | /* Non-Blocking mode: Interrupt */
143 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
144 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
145 |
146 | /* Non-Blocking mode: DMA */
147 | HAL_StatusTypeDef HAL_TIMEx_OCN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
148 | HAL_StatusTypeDef HAL_TIMEx_OCN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
149 | /**
150 | * @}
151 | */
152 |
153 | /** @addtogroup TIMEx_Exported_Functions_Group3 Extended Timer Complementary PWM functions
154 | * @brief Timer Complementary PWM functions
155 | * @{
156 | */
157 | /* Timer Complementary PWM functions ****************************************/
158 | /* Blocking mode: Polling */
159 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start(TIM_HandleTypeDef *htim, uint32_t Channel);
160 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop(TIM_HandleTypeDef *htim, uint32_t Channel);
161 |
162 | /* Non-Blocking mode: Interrupt */
163 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
164 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t Channel);
165 | /* Non-Blocking mode: DMA */
166 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Start_DMA(TIM_HandleTypeDef *htim, uint32_t Channel, uint32_t *pData, uint16_t Length);
167 | HAL_StatusTypeDef HAL_TIMEx_PWMN_Stop_DMA(TIM_HandleTypeDef *htim, uint32_t Channel);
168 | /**
169 | * @}
170 | */
171 |
172 | /** @addtogroup TIMEx_Exported_Functions_Group4 Extended Timer Complementary One Pulse functions
173 | * @brief Timer Complementary One Pulse functions
174 | * @{
175 | */
176 | /* Timer Complementary One Pulse functions **********************************/
177 | /* Blocking mode: Polling */
178 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
179 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
180 |
181 | /* Non-Blocking mode: Interrupt */
182 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Start_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
183 | HAL_StatusTypeDef HAL_TIMEx_OnePulseN_Stop_IT(TIM_HandleTypeDef *htim, uint32_t OutputChannel);
184 | /**
185 | * @}
186 | */
187 |
188 | /** @addtogroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
189 | * @brief Peripheral Control functions
190 | * @{
191 | */
192 | /* Extended Control functions ************************************************/
193 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
194 | uint32_t CommutationSource);
195 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_IT(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
196 | uint32_t CommutationSource);
197 | HAL_StatusTypeDef HAL_TIMEx_ConfigCommutEvent_DMA(TIM_HandleTypeDef *htim, uint32_t InputTrigger,
198 | uint32_t CommutationSource);
199 | HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
200 | TIM_MasterConfigTypeDef *sMasterConfig);
201 | HAL_StatusTypeDef HAL_TIMEx_ConfigBreakDeadTime(TIM_HandleTypeDef *htim,
202 | TIM_BreakDeadTimeConfigTypeDef *sBreakDeadTimeConfig);
203 | HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap);
204 | /**
205 | * @}
206 | */
207 |
208 | /** @addtogroup TIMEx_Exported_Functions_Group6 Extended Callbacks functions
209 | * @brief Extended Callbacks functions
210 | * @{
211 | */
212 | /* Extended Callback **********************************************************/
213 | void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim);
214 | void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim);
215 | void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim);
216 | /**
217 | * @}
218 | */
219 |
220 | /** @addtogroup TIMEx_Exported_Functions_Group7 Extended Peripheral State functions
221 | * @brief Extended Peripheral State functions
222 | * @{
223 | */
224 | /* Extended Peripheral State functions ***************************************/
225 | HAL_TIM_StateTypeDef HAL_TIMEx_HallSensor_GetState(TIM_HandleTypeDef *htim);
226 | HAL_TIM_ChannelStateTypeDef HAL_TIMEx_GetChannelNState(TIM_HandleTypeDef *htim, uint32_t ChannelN);
227 | /**
228 | * @}
229 | */
230 |
231 | /**
232 | * @}
233 | */
234 | /* End of exported functions -------------------------------------------------*/
235 |
236 | /* Private functions----------------------------------------------------------*/
237 | /** @addtogroup TIMEx_Private_Functions TIMEx Private Functions
238 | * @{
239 | */
240 | void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma);
241 | void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma);
242 | /**
243 | * @}
244 | */
245 | /* End of private functions --------------------------------------------------*/
246 |
247 | /**
248 | * @}
249 | */
250 |
251 | /**
252 | * @}
253 | */
254 |
255 | #ifdef __cplusplus
256 | }
257 | #endif
258 |
259 |
260 | #endif /* STM32F1xx_HAL_TIM_EX_H */
261 |
262 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
263 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_gpio_ex.c
4 | * @author MCD Application Team
5 | * @brief GPIO Extension HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * functionalities of the General Purpose Input/Output (GPIO) extension peripheral.
8 | * + Extended features functions
9 | *
10 | @verbatim
11 | ==============================================================================
12 | ##### GPIO Peripheral extension features #####
13 | ==============================================================================
14 | [..] GPIO module on STM32F1 family, manage also the AFIO register:
15 | (+) Possibility to use the EVENTOUT Cortex feature
16 |
17 | ##### How to use this driver #####
18 | ==============================================================================
19 | [..] This driver provides functions to use EVENTOUT Cortex feature
20 | (#) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
21 | (#) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
22 | (#) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
23 |
24 | @endverbatim
25 | ******************************************************************************
26 | * @attention
27 | *
28 | * © Copyright (c) 2016 STMicroelectronics.
29 | * All rights reserved.
30 | *
31 | * This software component is licensed by ST under BSD 3-Clause license,
32 | * the "License"; You may not use this file except in compliance with the
33 | * License. You may obtain a copy of the License at:
34 | * opensource.org/licenses/BSD-3-Clause
35 | *
36 | ******************************************************************************
37 | */
38 |
39 | /* Includes ------------------------------------------------------------------*/
40 | #include "stm32f1xx_hal.h"
41 |
42 | /** @addtogroup STM32F1xx_HAL_Driver
43 | * @{
44 | */
45 |
46 | /** @defgroup GPIOEx GPIOEx
47 | * @brief GPIO HAL module driver
48 | * @{
49 | */
50 |
51 | #ifdef HAL_GPIO_MODULE_ENABLED
52 |
53 | /** @defgroup GPIOEx_Exported_Functions GPIOEx Exported Functions
54 | * @{
55 | */
56 |
57 | /** @defgroup GPIOEx_Exported_Functions_Group1 Extended features functions
58 | * @brief Extended features functions
59 | *
60 | @verbatim
61 | ==============================================================================
62 | ##### Extended features functions #####
63 | ==============================================================================
64 | [..] This section provides functions allowing to:
65 | (+) Configure EVENTOUT Cortex feature using the function HAL_GPIOEx_ConfigEventout()
66 | (+) Activate EVENTOUT Cortex feature using the HAL_GPIOEx_EnableEventout()
67 | (+) Deactivate EVENTOUT Cortex feature using the HAL_GPIOEx_DisableEventout()
68 |
69 | @endverbatim
70 | * @{
71 | */
72 |
73 | /**
74 | * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected.
75 | * @param GPIO_PortSource Select the port used to output the Cortex EVENTOUT signal.
76 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PORT.
77 | * @param GPIO_PinSource Select the pin used to output the Cortex EVENTOUT signal.
78 | * This parameter can be a value of @ref GPIOEx_EVENTOUT_PIN.
79 | * @retval None
80 | */
81 | void HAL_GPIOEx_ConfigEventout(uint32_t GPIO_PortSource, uint32_t GPIO_PinSource)
82 | {
83 | /* Verify the parameters */
84 | assert_param(IS_AFIO_EVENTOUT_PORT(GPIO_PortSource));
85 | assert_param(IS_AFIO_EVENTOUT_PIN(GPIO_PinSource));
86 |
87 | /* Apply the new configuration */
88 | MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (GPIO_PortSource) | (GPIO_PinSource));
89 | }
90 |
91 | /**
92 | * @brief Enables the Event Output.
93 | * @retval None
94 | */
95 | void HAL_GPIOEx_EnableEventout(void)
96 | {
97 | SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
98 | }
99 |
100 | /**
101 | * @brief Disables the Event Output.
102 | * @retval None
103 | */
104 | void HAL_GPIOEx_DisableEventout(void)
105 | {
106 | CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
107 | }
108 |
109 | /**
110 | * @}
111 | */
112 |
113 | /**
114 | * @}
115 | */
116 |
117 | #endif /* HAL_GPIO_MODULE_ENABLED */
118 |
119 | /**
120 | * @}
121 | */
122 |
123 | /**
124 | * @}
125 | */
126 |
127 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
128 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_pcd_ex.c
4 | * @author MCD Application Team
5 | * @brief PCD Extended HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * functionalities of the USB Peripheral Controller:
8 | * + Extended features functions
9 | *
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * © Copyright (c) 2016 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software component is licensed by ST under BSD 3-Clause license,
17 | * the "License"; You may not use this file except in compliance with the
18 | * License. You may obtain a copy of the License at:
19 | * opensource.org/licenses/BSD-3-Clause
20 | *
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "stm32f1xx_hal.h"
26 |
27 | /** @addtogroup STM32F1xx_HAL_Driver
28 | * @{
29 | */
30 |
31 | /** @defgroup PCDEx PCDEx
32 | * @brief PCD Extended HAL module driver
33 | * @{
34 | */
35 |
36 | #ifdef HAL_PCD_MODULE_ENABLED
37 |
38 | #if defined (USB) || defined (USB_OTG_FS)
39 | /* Private types -------------------------------------------------------------*/
40 | /* Private variables ---------------------------------------------------------*/
41 | /* Private constants ---------------------------------------------------------*/
42 | /* Private macros ------------------------------------------------------------*/
43 | /* Private functions ---------------------------------------------------------*/
44 | /* Exported functions --------------------------------------------------------*/
45 |
46 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
47 | * @{
48 | */
49 |
50 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
51 | * @brief PCDEx control functions
52 | *
53 | @verbatim
54 | ===============================================================================
55 | ##### Extended features functions #####
56 | ===============================================================================
57 | [..] This section provides functions allowing to:
58 | (+) Update FIFO configuration
59 |
60 | @endverbatim
61 | * @{
62 | */
63 | #if defined (USB_OTG_FS)
64 | /**
65 | * @brief Set Tx FIFO
66 | * @param hpcd PCD handle
67 | * @param fifo The number of Tx fifo
68 | * @param size Fifo size
69 | * @retval HAL status
70 | */
71 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
72 | {
73 | uint8_t i;
74 | uint32_t Tx_Offset;
75 |
76 | /* TXn min size = 16 words. (n : Transmit FIFO index)
77 | When a TxFIFO is not used, the Configuration should be as follows:
78 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
79 | --> Txm can use the space allocated for Txn.
80 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
81 | --> Txn should be configured with the minimum space of 16 words
82 | The FIFO is used optimally when used TxFIFOs are allocated in the top
83 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
84 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
85 |
86 | Tx_Offset = hpcd->Instance->GRXFSIZ;
87 |
88 | if (fifo == 0U)
89 | {
90 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset;
91 | }
92 | else
93 | {
94 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16;
95 | for (i = 0U; i < (fifo - 1U); i++)
96 | {
97 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16);
98 | }
99 |
100 | /* Multiply Tx_Size by 2 to get higher performance */
101 | hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset;
102 | }
103 |
104 | return HAL_OK;
105 | }
106 |
107 | /**
108 | * @brief Set Rx FIFO
109 | * @param hpcd PCD handle
110 | * @param size Size of Rx fifo
111 | * @retval HAL status
112 | */
113 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size)
114 | {
115 | hpcd->Instance->GRXFSIZ = size;
116 |
117 | return HAL_OK;
118 | }
119 | #endif /* defined (USB_OTG_FS) */
120 | #if defined (USB)
121 | /**
122 | * @brief Configure PMA for EP
123 | * @param hpcd Device instance
124 | * @param ep_addr endpoint address
125 | * @param ep_kind endpoint Kind
126 | * USB_SNG_BUF: Single Buffer used
127 | * USB_DBL_BUF: Double Buffer used
128 | * @param pmaadress: EP address in The PMA: In case of single buffer endpoint
129 | * this parameter is 16-bit value providing the address
130 | * in PMA allocated to endpoint.
131 | * In case of double buffer endpoint this parameter
132 | * is a 32-bit value providing the endpoint buffer 0 address
133 | * in the LSB part of 32-bit value and endpoint buffer 1 address
134 | * in the MSB part of 32-bit value.
135 | * @retval HAL status
136 | */
137 |
138 | HAL_StatusTypeDef HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr,
139 | uint16_t ep_kind, uint32_t pmaadress)
140 | {
141 | PCD_EPTypeDef *ep;
142 |
143 | /* initialize ep structure*/
144 | if ((0x80U & ep_addr) == 0x80U)
145 | {
146 | ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
147 | }
148 | else
149 | {
150 | ep = &hpcd->OUT_ep[ep_addr];
151 | }
152 |
153 | /* Here we check if the endpoint is single or double Buffer*/
154 | if (ep_kind == PCD_SNG_BUF)
155 | {
156 | /* Single Buffer */
157 | ep->doublebuffer = 0U;
158 | /* Configure the PMA */
159 | ep->pmaadress = (uint16_t)pmaadress;
160 | }
161 | else /* USB_DBL_BUF */
162 | {
163 | /* Double Buffer Endpoint */
164 | ep->doublebuffer = 1U;
165 | /* Configure the PMA */
166 | ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU);
167 | ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16);
168 | }
169 |
170 | return HAL_OK;
171 | }
172 |
173 | /**
174 | * @brief Software Device Connection,
175 | * this function is not required by USB OTG FS peripheral, it is used
176 | * only by USB Device FS peripheral.
177 | * @param hpcd PCD handle
178 | * @param state connection state (0 : disconnected / 1: connected)
179 | * @retval None
180 | */
181 | __weak void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
182 | {
183 | /* Prevent unused argument(s) compilation warning */
184 | UNUSED(hpcd);
185 | UNUSED(state);
186 | /* NOTE : This function Should not be modified, when the callback is needed,
187 | the HAL_PCDEx_SetConnectionState could be implemented in the user file
188 | */
189 | }
190 | #endif /* defined (USB) */
191 |
192 | /**
193 | * @brief Send LPM message to user layer callback.
194 | * @param hpcd PCD handle
195 | * @param msg LPM message
196 | * @retval HAL status
197 | */
198 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
199 | {
200 | /* Prevent unused argument(s) compilation warning */
201 | UNUSED(hpcd);
202 | UNUSED(msg);
203 |
204 | /* NOTE : This function should not be modified, when the callback is needed,
205 | the HAL_PCDEx_LPM_Callback could be implemented in the user file
206 | */
207 | }
208 |
209 | /**
210 | * @brief Send BatteryCharging message to user layer callback.
211 | * @param hpcd PCD handle
212 | * @param msg LPM message
213 | * @retval HAL status
214 | */
215 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg)
216 | {
217 | /* Prevent unused argument(s) compilation warning */
218 | UNUSED(hpcd);
219 | UNUSED(msg);
220 |
221 | /* NOTE : This function should not be modified, when the callback is needed,
222 | the HAL_PCDEx_BCD_Callback could be implemented in the user file
223 | */
224 | }
225 |
226 | /**
227 | * @}
228 | */
229 |
230 | /**
231 | * @}
232 | */
233 | #endif /* defined (USB) || defined (USB_OTG_FS) */
234 | #endif /* HAL_PCD_MODULE_ENABLED */
235 |
236 | /**
237 | * @}
238 | */
239 |
240 | /**
241 | * @}
242 | */
243 |
244 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
245 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f1xx_hal.h"
32 |
33 | /* Private includes ----------------------------------------------------------*/
34 | /* USER CODE BEGIN Includes */
35 | #include "stdint.h"
36 | #include "stm32f1xx_hal.h"
37 | #include "stm32f1xx_hal_dma.h"
38 | #include "stm32f1xx_hal_uart.h"
39 | /* USER CODE END Includes */
40 |
41 | /* Exported types ------------------------------------------------------------*/
42 | /* USER CODE BEGIN ET */
43 |
44 | /* USER CODE END ET */
45 |
46 | /* Exported constants --------------------------------------------------------*/
47 | /* USER CODE BEGIN EC */
48 |
49 | /* USER CODE END EC */
50 |
51 | /* Exported macro ------------------------------------------------------------*/
52 | /* USER CODE BEGIN EM */
53 |
54 | /* USER CODE END EM */
55 |
56 | /* Exported functions prototypes ---------------------------------------------*/
57 | void Error_Handler(void);
58 |
59 | /* USER CODE BEGIN EFP */
60 |
61 | /* USER CODE END EFP */
62 |
63 | /* Private defines -----------------------------------------------------------*/
64 | /* USER CODE BEGIN Private defines */
65 |
66 | // Version information.
67 | #define MAIN_VERSION (1)
68 | #define MINOR_VERSION (0)
69 | #define PATCH_VERSION (0)
70 |
71 | #define DBL_BUF_LEN (512)
72 | #define DBL_BUF_TOTAL_LEN (2 * DBL_BUF_LEN)
73 |
74 | typedef struct _hart_dbl_buf_t {
75 | uint32_t data[2][DBL_BUF_LEN / 4];
76 | uint32_t data_rest[DBL_BUF_LEN / 4 * 2];
77 | int len[2];
78 | int rest_len;
79 | int idx;
80 | } uart_dbl_buf_t;
81 |
82 | typedef struct _uart_ctx_t {
83 | const char *name;
84 | UART_HandleTypeDef *huart;
85 | IRQn_Type irq_num;
86 | DMA_HandleTypeDef *hdma_rx;
87 | DMA_HandleTypeDef *hdma_tx;
88 | uart_dbl_buf_t buf;
89 | int buf_idx;
90 | } uart_ctx_t;
91 |
92 | typedef struct _ctx_t {
93 | uart_ctx_t uart1;
94 | uart_ctx_t uart2;
95 | uart_ctx_t uart3;
96 | DMA_HandleTypeDef *memcpy_dma;
97 | } ctx_t;
98 |
99 | extern ctx_t ctx;
100 |
101 | /* USER CODE END Private defines */
102 |
103 | #ifdef __cplusplus
104 | }
105 | #endif
106 |
107 | #endif /* __MAIN_H */
108 |
109 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
110 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/stm32f1xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f1xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F1xx_IT_H
23 | #define __STM32F1xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Includes ------------------------------------------------------------------*/
35 | #include "stm32f1xx_hal.h"
36 | #include "main.h"
37 | /* Exported types ------------------------------------------------------------*/
38 | /* USER CODE BEGIN ET */
39 |
40 | /* USER CODE END ET */
41 |
42 | /* Exported constants --------------------------------------------------------*/
43 | /* USER CODE BEGIN EC */
44 |
45 | /* USER CODE END EC */
46 |
47 | /* Exported macro ------------------------------------------------------------*/
48 | /* USER CODE BEGIN EM */
49 |
50 | /* USER CODE END EM */
51 |
52 | /* Exported functions prototypes ---------------------------------------------*/
53 | void NMI_Handler(void);
54 | void HardFault_Handler(void);
55 | void MemManage_Handler(void);
56 | void BusFault_Handler(void);
57 | void UsageFault_Handler(void);
58 | void SVC_Handler(void);
59 | void DebugMon_Handler(void);
60 | void PendSV_Handler(void);
61 | void SysTick_Handler(void);
62 | void DMA1_Channel2_IRQHandler(void);
63 | void DMA1_Channel3_IRQHandler(void);
64 | void DMA1_Channel4_IRQHandler(void);
65 | void DMA1_Channel5_IRQHandler(void);
66 | void DMA1_Channel6_IRQHandler(void);
67 | void DMA1_Channel7_IRQHandler(void);
68 | void USB_LP_CAN1_RX0_IRQHandler(void);
69 | void USART1_IRQHandler(void);
70 | void USART2_IRQHandler(void);
71 | void USART3_IRQHandler(void);
72 | /* USER CODE BEGIN EFP */
73 |
74 | /* USER CODE END EFP */
75 |
76 | #ifdef __cplusplus
77 | }
78 | #endif
79 |
80 | #endif /* __STM32F1xx_IT_H */
81 |
82 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
83 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/usb_device.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.h
5 | * @version : v2.0_Cube
6 | * @brief : Header for usb_device.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_DEVICE__H__
24 | #define __USB_DEVICE__H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f1xx.h"
32 | #include "stm32f1xx_hal.h"
33 | #include "usbd_def.h"
34 |
35 | /* USER CODE BEGIN INCLUDE */
36 |
37 | /* USER CODE END INCLUDE */
38 |
39 | /** @addtogroup USBD_OTG_DRIVER
40 | * @{
41 | */
42 |
43 | /** @defgroup USBD_DEVICE USBD_DEVICE
44 | * @brief Device file for Usb otg low level driver.
45 | * @{
46 | */
47 |
48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
49 | * @brief Public variables.
50 | * @{
51 | */
52 |
53 | /* Private variables ---------------------------------------------------------*/
54 | /* USER CODE BEGIN PV */
55 |
56 | /* USER CODE END PV */
57 |
58 | /* Private function prototypes -----------------------------------------------*/
59 | /* USER CODE BEGIN PFP */
60 |
61 | /* USER CODE END PFP */
62 |
63 | /*
64 | * -- Insert your variables declaration here --
65 | */
66 | /* USER CODE BEGIN VARIABLES */
67 |
68 | /* USER CODE END VARIABLES */
69 | /**
70 | * @}
71 | */
72 |
73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
74 | * @brief Declaration of public functions for Usb device.
75 | * @{
76 | */
77 |
78 | /** USB Device initialization function. */
79 | void MX_USB_DEVICE_Init(void);
80 |
81 | /*
82 | * -- Insert functions declaration here --
83 | */
84 | /* USER CODE BEGIN FD */
85 |
86 | /* USER CODE END FD */
87 | /**
88 | * @}
89 | */
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif /* __USB_DEVICE__H__ */
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/usbd_cdc_if.h:
--------------------------------------------------------------------------------
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) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CDC_IF_H__
24 | #define __USBD_CDC_IF_H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "usbd_cdc.h"
32 |
33 | /* USER CODE BEGIN INCLUDE */
34 |
35 | /* USER CODE END INCLUDE */
36 |
37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
38 | * @brief For Usb device.
39 | * @{
40 | */
41 |
42 | /** @defgroup USBD_CDC_IF USBD_CDC_IF
43 | * @brief Usb VCP device module
44 | * @{
45 | */
46 |
47 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
48 | * @brief Defines.
49 | * @{
50 | */
51 | /* USER CODE BEGIN EXPORTED_DEFINES */
52 | /* Define size for the receive and transmit buffer over CDC */
53 | /* It's up to user to redefine and/or remove those define */
54 | #define APP_RX_DATA_SIZE 1000
55 | #define APP_TX_DATA_SIZE 1000
56 |
57 | /* USER CODE END EXPORTED_DEFINES */
58 |
59 | /**
60 | * @}
61 | */
62 |
63 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
64 | * @brief Types.
65 | * @{
66 | */
67 |
68 | /* USER CODE BEGIN EXPORTED_TYPES */
69 |
70 | /* USER CODE END EXPORTED_TYPES */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
77 | * @brief Aliases.
78 | * @{
79 | */
80 |
81 | /* USER CODE BEGIN EXPORTED_MACRO */
82 |
83 | /* USER CODE END EXPORTED_MACRO */
84 |
85 | /**
86 | * @}
87 | */
88 |
89 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
90 | * @brief Public variables.
91 | * @{
92 | */
93 |
94 | /** CDC Interface callback. */
95 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
96 |
97 | /* USER CODE BEGIN EXPORTED_VARIABLES */
98 |
99 | /* USER CODE END EXPORTED_VARIABLES */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
106 | * @brief Public functions declaration.
107 | * @{
108 | */
109 |
110 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len, uint16_t index);
111 |
112 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */
113 |
114 | /* USER CODE END EXPORTED_FUNCTIONS */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /**
121 | * @}
122 | */
123 |
124 | /**
125 | * @}
126 | */
127 |
128 | #ifdef __cplusplus
129 | }
130 | #endif
131 |
132 | #endif /* __USBD_CDC_IF_H__ */
133 |
134 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
135 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/usbd_conf.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_conf.h
5 | * @version : v2.0_Cube
6 | * @brief : Header for usbd_conf.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CONF__H__
24 | #define __USBD_CONF__H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include
32 | #include
33 | #include
34 | #include "main.h"
35 | #include "stm32f1xx.h"
36 | #include "stm32f1xx_hal.h"
37 |
38 | /* USER CODE BEGIN INCLUDE */
39 |
40 | /* USER CODE END INCLUDE */
41 |
42 | /** @addtogroup USBD_OTG_DRIVER
43 | * @{
44 | */
45 |
46 | /** @defgroup USBD_CONF USBD_CONF
47 | * @brief Configuration file for Usb otg low level driver.
48 | * @{
49 | */
50 |
51 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
52 | * @brief Public variables.
53 | * @{
54 | */
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
61 | * @brief Defines for configuration of the Usb device.
62 | * @{
63 | */
64 |
65 | /*---------- -----------*/
66 | #define USBD_MAX_NUM_INTERFACES 3
67 | /*---------- -----------*/
68 | #define USBD_MAX_NUM_CONFIGURATION 1
69 | /*---------- -----------*/
70 | #define USBD_MAX_STR_DESC_SIZ 512
71 | /*---------- -----------*/
72 | #define USBD_DEBUG_LEVEL 0
73 | /*---------- -----------*/
74 | #define USBD_SELF_POWERED 1
75 | /*---------- -----------*/
76 | #define MAX_STATIC_ALLOC_SIZE 512
77 |
78 | /****************************************/
79 | /* #define for FS and HS identification */
80 | #define DEVICE_FS 0
81 |
82 | /**
83 | * @}
84 | */
85 |
86 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
87 | * @brief Aliases.
88 | * @{
89 | */
90 |
91 | /* Memory management macros */
92 |
93 | /** Alias for memory allocation. */
94 | #define USBD_malloc (uint32_t *)USBD_static_malloc
95 |
96 | /** Alias for memory release. */
97 | #define USBD_free USBD_static_free
98 |
99 | /** Alias for memory set. */
100 | #define USBD_memset /* Not used */
101 |
102 | /** Alias for memory copy. */
103 | #define USBD_memcpy /* Not used */
104 |
105 | /** Alias for delay. */
106 | #define USBD_Delay HAL_Delay
107 |
108 | /* For footprint reasons and since only one allocation is handled in the HID class
109 | driver, the malloc/free is changed into a static allocation method */
110 | void *USBD_static_malloc(uint32_t size);
111 | void USBD_static_free(void *p);
112 |
113 | /* DEBUG macros */
114 |
115 | #if (USBD_DEBUG_LEVEL > 0)
116 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\
117 | printf("\n");
118 | #else
119 | #define USBD_UsrLog(...)
120 | #endif
121 |
122 | #if (USBD_DEBUG_LEVEL > 1)
123 |
124 | #define USBD_ErrLog(...) printf("ERROR: ") ;\
125 | printf(__VA_ARGS__);\
126 | printf("\n");
127 | #else
128 | #define USBD_ErrLog(...)
129 | #endif
130 |
131 | #if (USBD_DEBUG_LEVEL > 2)
132 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\
133 | printf(__VA_ARGS__);\
134 | printf("\n");
135 | #else
136 | #define USBD_DbgLog(...)
137 | #endif
138 |
139 | /**
140 | * @}
141 | */
142 |
143 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
144 | * @brief Types.
145 | * @{
146 | */
147 |
148 | /**
149 | * @}
150 | */
151 |
152 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
153 | * @brief Declaration of public functions for Usb device.
154 | * @{
155 | */
156 |
157 | /* Exported functions -------------------------------------------------------*/
158 |
159 | /**
160 | * @}
161 | */
162 |
163 | /**
164 | * @}
165 | */
166 |
167 | /**
168 | * @}
169 | */
170 |
171 | #ifdef __cplusplus
172 | }
173 | #endif
174 |
175 | #endif /* __USBD_CONF__H__ */
176 |
177 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
178 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Inc/usbd_desc.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_desc.c
5 | * @version : v2.0_Cube
6 | * @brief : Header for usbd_conf.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __USBD_DESC__C__
23 | #define __USBD_DESC__C__
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "usbd_def.h"
31 |
32 | /* USER CODE BEGIN INCLUDE */
33 |
34 | /* USER CODE END INCLUDE */
35 |
36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
37 | * @{
38 | */
39 |
40 | /** @defgroup USBD_DESC USBD_DESC
41 | * @brief Usb device descriptors module.
42 | * @{
43 | */
44 |
45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
46 | * @brief Constants.
47 | * @{
48 | */
49 | #define DEVICE_ID1 (UID_BASE)
50 | #define DEVICE_ID2 (UID_BASE + 0x4)
51 | #define DEVICE_ID3 (UID_BASE + 0x8)
52 |
53 | #define USB_SIZ_STRING_SERIAL 0x1A
54 |
55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */
56 |
57 | /* USER CODE END EXPORTED_CONSTANTS */
58 |
59 | /**
60 | * @}
61 | */
62 |
63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
64 | * @brief Defines.
65 | * @{
66 | */
67 |
68 | /* USER CODE BEGIN EXPORTED_DEFINES */
69 |
70 | /* USER CODE END EXPORTED_DEFINES */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
77 | * @brief Types.
78 | * @{
79 | */
80 |
81 | /* USER CODE BEGIN EXPORTED_TYPES */
82 |
83 | /* USER CODE END EXPORTED_TYPES */
84 |
85 | /**
86 | * @}
87 | */
88 |
89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
90 | * @brief Aliases.
91 | * @{
92 | */
93 |
94 | /* USER CODE BEGIN EXPORTED_MACRO */
95 |
96 | /* USER CODE END EXPORTED_MACRO */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
103 | * @brief Public variables.
104 | * @{
105 | */
106 |
107 | /** Descriptor for the Usb device. */
108 | extern USBD_DescriptorsTypeDef FS_Desc;
109 |
110 | /* USER CODE BEGIN EXPORTED_VARIABLES */
111 |
112 | /* USER CODE END EXPORTED_VARIABLES */
113 |
114 | /**
115 | * @}
116 | */
117 |
118 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
119 | * @brief Public functions declaration.
120 | * @{
121 | */
122 |
123 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */
124 |
125 | /* USER CODE END EXPORTED_FUNCTIONS */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /**
132 | * @}
133 | */
134 |
135 | /**
136 | * @}
137 | */
138 |
139 | #ifdef __cplusplus
140 | }
141 | #endif
142 |
143 | #endif /* __USBD_DESC__C__ */
144 |
145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
146 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/MDK-ARM/DebugConfig/STM32F103_DUAL_VCP_STM32F103CB_1.0.0.dbgconf:
--------------------------------------------------------------------------------
1 | // File: STM32F101_102_103_105_107.dbgconf
2 | // Version: 1.0.0
3 | // Note: refer to STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx Reference manual (RM0008)
4 | // STM32F101xx STM32F102xx STM32F103xx STM32F105xx STM32F107xx datasheets
5 |
6 | // <<< Use Configuration Wizard in Context Menu >>>
7 |
8 | // Debug MCU configuration register (DBGMCU_CR)
9 | // Reserved bits must be kept at reset value
10 | // DBG_TIM11_STOP TIM11 counter stopped when core is halted
11 | // DBG_TIM10_STOP TIM10 counter stopped when core is halted
12 | // DBG_TIM9_STOP TIM9 counter stopped when core is halted
13 | // DBG_TIM14_STOP TIM14 counter stopped when core is halted
14 | // DBG_TIM13_STOP TIM13 counter stopped when core is halted
15 | // DBG_TIM12_STOP TIM12 counter stopped when core is halted
16 | // DBG_CAN2_STOP Debug CAN2 stopped when core is halted
17 | // DBG_TIM7_STOP TIM7 counter stopped when core is halted
18 | // DBG_TIM6_STOP TIM6 counter stopped when core is halted
19 | // DBG_TIM5_STOP TIM5 counter stopped when core is halted
20 | // DBG_TIM8_STOP TIM8 counter stopped when core is halted
21 | // DBG_I2C2_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted
22 | // DBG_I2C1_SMBUS_TIMEOUT SMBUS timeout mode stopped when core is halted
23 | // DBG_CAN1_STOP Debug CAN1 stopped when Core is halted
24 | // DBG_TIM4_STOP TIM4 counter stopped when core is halted
25 | // DBG_TIM3_STOP TIM3 counter stopped when core is halted
26 | // DBG_TIM2_STOP TIM2 counter stopped when core is halted
27 | // DBG_TIM1_STOP TIM1 counter stopped when core is halted
28 | // DBG_WWDG_STOP Debug window watchdog stopped when core is halted
29 | // DBG_IWDG_STOP Debug independent watchdog stopped when core is halted
30 | // DBG_STANDBY Debug standby mode
31 | // DBG_STOP Debug stop mode
32 | // DBG_SLEEP Debug sleep mode
33 | //
34 | DbgMCU_CR = 0x00000007;
35 |
36 | // <<< end of configuration section >>>
37 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/MDK-ARM/RTE/_STM32F103_DUAL_VCP/RTE_Components.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Auto generated Run-Time-Environment Configuration File
4 | * *** Do not modify ! ***
5 | *
6 | * Project: 'STM32F103_DUAL_VCP'
7 | * Target: 'STM32F103_DUAL_VCP'
8 | */
9 |
10 | #ifndef RTE_COMPONENTS_H
11 | #define RTE_COMPONENTS_H
12 |
13 |
14 | /*
15 | * Define the Device Header File:
16 | */
17 | #define CMSIS_device_header "stm32f10x.h"
18 |
19 |
20 |
21 | #endif /* RTE_COMPONENTS_H */
22 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/MDK-ARM/STM32F103_DUAL_VCP/STM32F103_DUAL_VCP.sct:
--------------------------------------------------------------------------------
1 | ; *************************************************************
2 | ; *** Scatter-Loading Description File generated by uVision ***
3 | ; *************************************************************
4 |
5 | LR_IROM1 0x08000000 0x00020000 { ; load region size_region
6 | ER_IROM1 0x08000000 0x00020000 { ; load address = execution address
7 | *.o (RESET, +First)
8 | *(InRoot$$Sections)
9 | .ANY (+RO)
10 | .ANY (+XO)
11 | }
12 | RW_IRAM1 0x20000000 0x00005000 { ; RW data
13 | .ANY (+RW +ZI)
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h:
--------------------------------------------------------------------------------
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 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_CDC_H
22 | #define __USB_CDC_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_ioreq.h"
30 |
31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
32 | * @{
33 | */
34 |
35 | /** @defgroup usbd_cdc
36 | * @brief This file is the Header file for usbd_cdc.c
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup usbd_cdc_Exported_Defines
42 | * @{
43 | */
44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */
45 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */
46 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
47 |
48 | #ifndef CDC_HS_BINTERVAL
49 | #define CDC_HS_BINTERVAL 0x10U
50 | #endif /* CDC_HS_BINTERVAL */
51 |
52 | #ifndef CDC_FS_BINTERVAL
53 | #define CDC_FS_BINTERVAL 0x10U
54 | #endif /* CDC_FS_BINTERVAL */
55 |
56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
59 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
60 |
61 | #define USB_CDC_CONFIG_DESC_SIZ ((67-9+8)*2+9)
62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
64 |
65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
67 |
68 | /*---------------------------------------------------------------------*/
69 | /* CDC definitions */
70 | /*---------------------------------------------------------------------*/
71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
73 | #define CDC_SET_COMM_FEATURE 0x02U
74 | #define CDC_GET_COMM_FEATURE 0x03U
75 | #define CDC_CLEAR_COMM_FEATURE 0x04U
76 | #define CDC_SET_LINE_CODING 0x20U
77 | #define CDC_GET_LINE_CODING 0x21U
78 | #define CDC_SET_CONTROL_LINE_STATE 0x22U
79 | #define CDC_SEND_BREAK 0x23U
80 |
81 | /**
82 | * @}
83 | */
84 |
85 |
86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
87 | * @{
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 | typedef struct
94 | {
95 | uint32_t bitrate;
96 | uint8_t format;
97 | uint8_t paritytype;
98 | uint8_t datatype;
99 | } USBD_CDC_LineCodingTypeDef;
100 |
101 | typedef struct _USBD_CDC_Itf
102 | {
103 | int8_t (* Init)(void);
104 | int8_t (* DeInit)(void);
105 | int8_t (* Control) (uint8_t, uint8_t * , uint16_t, uint16_t);
106 | int8_t (* Receive) (uint8_t *, uint32_t *, uint16_t);
107 |
108 | } USBD_CDC_ItfTypeDef;
109 |
110 |
111 | typedef struct
112 | {
113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
114 | uint8_t CmdOpCode;
115 | uint8_t CmdLength;
116 | uint8_t *RxBuffer;
117 | uint8_t *TxBuffer;
118 | uint32_t RxLength;
119 | uint32_t TxLength;
120 |
121 | __IO uint32_t TxState;
122 | __IO uint32_t RxState;
123 | }
124 | USBD_CDC_HandleTypeDef;
125 |
126 |
127 |
128 | /** @defgroup USBD_CORE_Exported_Macros
129 | * @{
130 | */
131 |
132 | /**
133 | * @}
134 | */
135 |
136 | /** @defgroup USBD_CORE_Exported_Variables
137 | * @{
138 | */
139 |
140 | extern USBD_ClassTypeDef USBD_CDC;
141 | #define USBD_CDC_CLASS &USBD_CDC
142 | /**
143 | * @}
144 | */
145 |
146 | /** @defgroup USB_CORE_Exported_Functions
147 | * @{
148 | */
149 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
150 | USBD_CDC_ItfTypeDef *fops);
151 |
152 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
153 | uint8_t *pbuff,
154 | uint16_t length);
155 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev,
156 | uint8_t *pbuff);
157 | uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev, uint16_t index);
158 | uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev, uint16_t index);
159 | /**
160 | * @}
161 | */
162 |
163 | #ifdef __cplusplus
164 | }
165 | #endif
166 |
167 | #endif /* __USB_CDC_H */
168 | /**
169 | * @}
170 | */
171 |
172 | /**
173 | * @}
174 | */
175 |
176 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
177 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_core.h
4 | * @author MCD Application Team
5 | * @brief Header file for usbd_core.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_CORE_H
22 | #define __USBD_CORE_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_conf.h"
30 | #include "usbd_def.h"
31 | #include "usbd_ioreq.h"
32 | #include "usbd_ctlreq.h"
33 |
34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
35 | * @{
36 | */
37 |
38 | /** @defgroup USBD_CORE
39 | * @brief This file is the Header file for usbd_core.c file
40 | * @{
41 | */
42 |
43 |
44 | /** @defgroup USBD_CORE_Exported_Defines
45 | * @{
46 | */
47 | #ifndef USBD_DEBUG_LEVEL
48 | #define USBD_DEBUG_LEVEL 0U
49 | #endif /* USBD_DEBUG_LEVEL */
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
56 | * @{
57 | */
58 |
59 |
60 | /**
61 | * @}
62 | */
63 |
64 |
65 |
66 | /** @defgroup USBD_CORE_Exported_Macros
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup USBD_CORE_Exported_Variables
75 | * @{
76 | */
77 | #define USBD_SOF USBD_LL_SOF
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype
83 | * @{
84 | */
85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
87 | USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
88 | USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
90 |
91 | USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
94 |
95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
98 |
99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
103 |
104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
107 |
108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
110 |
111 | /* USBD Low Level Driver */
112 | USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
113 | USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
115 | USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
116 | USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev,
117 | uint8_t ep_addr,
118 | uint8_t ep_type,
119 | uint16_t ep_mps);
120 |
121 | USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
122 | USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
123 | USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
124 | USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
125 | uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
127 | USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev,
128 | uint8_t ep_addr,
129 | uint8_t *pbuf,
130 | uint16_t size);
131 |
132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev,
133 | uint8_t ep_addr,
134 | uint8_t *pbuf,
135 | uint16_t size);
136 |
137 | uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
138 | void USBD_LL_Delay(uint32_t Delay);
139 |
140 | /**
141 | * @}
142 | */
143 |
144 | #ifdef __cplusplus
145 | }
146 | #endif
147 |
148 | #endif /* __USBD_CORE_H */
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_req.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_req.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_REQUEST_H
22 | #define __USB_REQUEST_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 |
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_REQ
37 | * @brief header file for the usbd_req.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_REQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_REQ_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 |
58 | /** @defgroup USBD_REQ_Exported_Macros
59 | * @{
60 | */
61 | /**
62 | * @}
63 | */
64 |
65 | /** @defgroup USBD_REQ_Exported_Variables
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype
73 | * @{
74 | */
75 |
76 | USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
77 | USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
78 | USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
79 |
80 |
81 | void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
82 |
83 | void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
84 |
85 | void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
86 | /**
87 | * @}
88 | */
89 |
90 | #ifdef __cplusplus
91 | }
92 | #endif
93 |
94 | #endif /* __USB_REQUEST_H */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /**
101 | * @}
102 | */
103 |
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_def.h
4 | * @author MCD Application Team
5 | * @brief General defines for the usb device library
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_DEF_H
22 | #define __USBD_DEF_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_conf.h"
30 |
31 | /** @addtogroup STM32_USBD_DEVICE_LIBRARY
32 | * @{
33 | */
34 |
35 | /** @defgroup USB_DEF
36 | * @brief general defines for the usb device library file
37 | * @{
38 | */
39 |
40 | /** @defgroup USB_DEF_Exported_Defines
41 | * @{
42 | */
43 |
44 | #ifndef NULL
45 | #define NULL 0U
46 | #endif /* NULL */
47 |
48 | #ifndef USBD_MAX_NUM_INTERFACES
49 | #define USBD_MAX_NUM_INTERFACES 1U
50 | #endif /* USBD_MAX_NUM_CONFIGURATION */
51 |
52 | #ifndef USBD_MAX_NUM_CONFIGURATION
53 | #define USBD_MAX_NUM_CONFIGURATION 1U
54 | #endif /* USBD_MAX_NUM_CONFIGURATION */
55 |
56 | #ifndef USBD_LPM_ENABLED
57 | #define USBD_LPM_ENABLED 0U
58 | #endif /* USBD_LPM_ENABLED */
59 |
60 | #ifndef USBD_SELF_POWERED
61 | #define USBD_SELF_POWERED 1U
62 | #endif /*USBD_SELF_POWERED */
63 |
64 | #ifndef USBD_SUPPORT_USER_STRING_DESC
65 | #define USBD_SUPPORT_USER_STRING_DESC 0U
66 | #endif /* USBD_SUPPORT_USER_STRING_DESC */
67 |
68 | #define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
69 | #define USB_LEN_DEV_DESC 0x12U
70 | #define USB_LEN_CFG_DESC 0x09U
71 | #define USB_LEN_IF_DESC 0x09U
72 | #define USB_LEN_EP_DESC 0x07U
73 | #define USB_LEN_OTG_DESC 0x03U
74 | #define USB_LEN_LANGID_STR_DESC 0x04U
75 | #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U
76 |
77 | #define USBD_IDX_LANGID_STR 0x00U
78 | #define USBD_IDX_MFC_STR 0x01U
79 | #define USBD_IDX_PRODUCT_STR 0x02U
80 | #define USBD_IDX_SERIAL_STR 0x03U
81 | #define USBD_IDX_CONFIG_STR 0x04U
82 | #define USBD_IDX_INTERFACE_STR 0x05U
83 |
84 | #define USB_REQ_TYPE_STANDARD 0x00U
85 | #define USB_REQ_TYPE_CLASS 0x20U
86 | #define USB_REQ_TYPE_VENDOR 0x40U
87 | #define USB_REQ_TYPE_MASK 0x60U
88 |
89 | #define USB_REQ_RECIPIENT_DEVICE 0x00U
90 | #define USB_REQ_RECIPIENT_INTERFACE 0x01U
91 | #define USB_REQ_RECIPIENT_ENDPOINT 0x02U
92 | #define USB_REQ_RECIPIENT_MASK 0x03U
93 |
94 | #define USB_REQ_GET_STATUS 0x00U
95 | #define USB_REQ_CLEAR_FEATURE 0x01U
96 | #define USB_REQ_SET_FEATURE 0x03U
97 | #define USB_REQ_SET_ADDRESS 0x05U
98 | #define USB_REQ_GET_DESCRIPTOR 0x06U
99 | #define USB_REQ_SET_DESCRIPTOR 0x07U
100 | #define USB_REQ_GET_CONFIGURATION 0x08U
101 | #define USB_REQ_SET_CONFIGURATION 0x09U
102 | #define USB_REQ_GET_INTERFACE 0x0AU
103 | #define USB_REQ_SET_INTERFACE 0x0BU
104 | #define USB_REQ_SYNCH_FRAME 0x0CU
105 |
106 | #define USB_DESC_TYPE_DEVICE 0x01U
107 | #define USB_DESC_TYPE_CONFIGURATION 0x02U
108 | #define USB_DESC_TYPE_STRING 0x03U
109 | #define USB_DESC_TYPE_INTERFACE 0x04U
110 | #define USB_DESC_TYPE_ENDPOINT 0x05U
111 | #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
112 | #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
113 | #define USB_DESC_TYPE_BOS 0x0FU
114 |
115 | #define USB_CONFIG_REMOTE_WAKEUP 0x02U
116 | #define USB_CONFIG_SELF_POWERED 0x01U
117 |
118 | #define USB_FEATURE_EP_HALT 0x00U
119 | #define USB_FEATURE_REMOTE_WAKEUP 0x01U
120 | #define USB_FEATURE_TEST_MODE 0x02U
121 |
122 | #define USB_DEVICE_CAPABITY_TYPE 0x10U
123 |
124 | #define USB_HS_MAX_PACKET_SIZE 512U
125 | #define USB_FS_MAX_PACKET_SIZE 64U
126 | #define USB_MAX_EP0_SIZE 64U
127 |
128 | /* Device Status */
129 | #define USBD_STATE_DEFAULT 0x01U
130 | #define USBD_STATE_ADDRESSED 0x02U
131 | #define USBD_STATE_CONFIGURED 0x03U
132 | #define USBD_STATE_SUSPENDED 0x04U
133 |
134 |
135 | /* EP0 State */
136 | #define USBD_EP0_IDLE 0x00U
137 | #define USBD_EP0_SETUP 0x01U
138 | #define USBD_EP0_DATA_IN 0x02U
139 | #define USBD_EP0_DATA_OUT 0x03U
140 | #define USBD_EP0_STATUS_IN 0x04U
141 | #define USBD_EP0_STATUS_OUT 0x05U
142 | #define USBD_EP0_STALL 0x06U
143 |
144 | #define USBD_EP_TYPE_CTRL 0x00U
145 | #define USBD_EP_TYPE_ISOC 0x01U
146 | #define USBD_EP_TYPE_BULK 0x02U
147 | #define USBD_EP_TYPE_INTR 0x03U
148 |
149 |
150 | /**
151 | * @}
152 | */
153 |
154 |
155 | /** @defgroup USBD_DEF_Exported_TypesDefinitions
156 | * @{
157 | */
158 |
159 | typedef struct usb_setup_req
160 | {
161 | uint8_t bmRequest;
162 | uint8_t bRequest;
163 | uint16_t wValue;
164 | uint16_t wIndex;
165 | uint16_t wLength;
166 | } USBD_SetupReqTypedef;
167 |
168 | struct _USBD_HandleTypeDef;
169 |
170 | typedef struct _Device_cb
171 | {
172 | uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
173 | uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
174 | /* Control Endpoints*/
175 | uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
176 | uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev);
177 | uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev);
178 | /* Class Specific Endpoints*/
179 | uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
180 | uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
181 | uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev);
182 | uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
183 | uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
184 |
185 | uint8_t *(*GetHSConfigDescriptor)(uint16_t *length);
186 | uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
187 | uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
188 | uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
189 | #if (USBD_SUPPORT_USER_STRING_DESC == 1U)
190 | uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length);
191 | #endif
192 |
193 | } USBD_ClassTypeDef;
194 |
195 | /* Following USB Device Speed */
196 | typedef enum
197 | {
198 | USBD_SPEED_HIGH = 0U,
199 | USBD_SPEED_FULL = 1U,
200 | USBD_SPEED_LOW = 2U,
201 | } USBD_SpeedTypeDef;
202 |
203 | /* Following USB Device status */
204 | typedef enum
205 | {
206 | USBD_OK = 0U,
207 | USBD_BUSY,
208 | USBD_FAIL,
209 | } USBD_StatusTypeDef;
210 |
211 | /* USB Device descriptors structure */
212 | typedef struct
213 | {
214 | uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
215 | uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
216 | uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
217 | uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
218 | uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
219 | uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
220 | uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
221 | #if (USBD_LPM_ENABLED == 1U)
222 | uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
223 | #endif
224 | } USBD_DescriptorsTypeDef;
225 |
226 | /* USB Device handle structure */
227 | typedef struct
228 | {
229 | uint32_t status;
230 | uint32_t is_used;
231 | uint32_t total_length;
232 | uint32_t rem_length;
233 | uint32_t maxpacket;
234 | } USBD_EndpointTypeDef;
235 |
236 | /* USB Device handle structure */
237 | typedef struct _USBD_HandleTypeDef
238 | {
239 | uint8_t id;
240 | uint32_t dev_config;
241 | uint32_t dev_default_config;
242 | uint32_t dev_config_status;
243 | USBD_SpeedTypeDef dev_speed;
244 | USBD_EndpointTypeDef ep_in[16];
245 | USBD_EndpointTypeDef ep_out[16];
246 | uint32_t ep0_state;
247 | uint32_t ep0_data_len;
248 | uint8_t dev_state;
249 | uint8_t dev_old_state;
250 | uint8_t dev_address;
251 | uint8_t dev_connection_status;
252 | uint8_t dev_test_mode;
253 | uint32_t dev_remote_wakeup;
254 |
255 | USBD_SetupReqTypedef request;
256 | USBD_DescriptorsTypeDef *pDesc;
257 | USBD_ClassTypeDef *pClass;
258 | void *pClassData;
259 | void *pUserData;
260 | void *pData;
261 | } USBD_HandleTypeDef;
262 |
263 | /**
264 | * @}
265 | */
266 |
267 |
268 |
269 | /** @defgroup USBD_DEF_Exported_Macros
270 | * @{
271 | */
272 | #define SWAPBYTE(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \
273 | (((uint16_t)(*(((uint8_t *)(addr)) + 1U))) << 8U))
274 |
275 | #define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
276 | #define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
277 | #define MIN(a, b) (((a) < (b)) ? (a) : (b))
278 | #define MAX(a, b) (((a) > (b)) ? (a) : (b))
279 |
280 |
281 | #if defined ( __GNUC__ )
282 | #ifndef __weak
283 | #define __weak __attribute__((weak))
284 | #endif /* __weak */
285 | #ifndef __packed
286 | #define __packed __attribute__((__packed__))
287 | #endif /* __packed */
288 | #endif /* __GNUC__ */
289 |
290 |
291 | /* In HS mode and when the DMA is used, all variables and data structures dealing
292 | with the DMA during the transaction process should be 4-bytes aligned */
293 |
294 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
295 | #ifndef __ALIGN_END
296 | #define __ALIGN_END __attribute__ ((aligned (4U)))
297 | #endif /* __ALIGN_END */
298 | #ifndef __ALIGN_BEGIN
299 | #define __ALIGN_BEGIN
300 | #endif /* __ALIGN_BEGIN */
301 | #else
302 | #ifndef __ALIGN_END
303 | #define __ALIGN_END
304 | #endif /* __ALIGN_END */
305 | #ifndef __ALIGN_BEGIN
306 | #if defined (__CC_ARM) /* ARM Compiler */
307 | #define __ALIGN_BEGIN __align(4U)
308 | #elif defined (__ICCARM__) /* IAR Compiler */
309 | #define __ALIGN_BEGIN
310 | #endif /* __CC_ARM */
311 | #endif /* __ALIGN_BEGIN */
312 | #endif /* __GNUC__ */
313 |
314 |
315 | /**
316 | * @}
317 | */
318 |
319 | /** @defgroup USBD_DEF_Exported_Variables
320 | * @{
321 | */
322 |
323 | /**
324 | * @}
325 | */
326 |
327 | /** @defgroup USBD_DEF_Exported_FunctionsPrototype
328 | * @{
329 | */
330 |
331 | /**
332 | * @}
333 | */
334 |
335 | #ifdef __cplusplus
336 | }
337 | #endif
338 |
339 | #endif /* __USBD_DEF_H */
340 |
341 | /**
342 | * @}
343 | */
344 |
345 | /**
346 | * @}
347 | */
348 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
349 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ioreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_ioreq.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_IOREQ_H
22 | #define __USBD_IOREQ_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 | #include "usbd_core.h"
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_IOREQ
37 | * @brief header file for the usbd_ioreq.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_IOREQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_IOREQ_Exported_Types
50 | * @{
51 | */
52 |
53 |
54 | /**
55 | * @}
56 | */
57 |
58 |
59 |
60 | /** @defgroup USBD_IOREQ_Exported_Macros
61 | * @{
62 | */
63 |
64 | /**
65 | * @}
66 | */
67 |
68 | /** @defgroup USBD_IOREQ_Exported_Variables
69 | * @{
70 | */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
77 | * @{
78 | */
79 |
80 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
81 | uint8_t *pbuf,
82 | uint16_t len);
83 |
84 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
85 | uint8_t *pbuf,
86 | uint16_t len);
87 |
88 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
89 | uint8_t *pbuf,
90 | uint16_t len);
91 |
92 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
93 | uint8_t *pbuf,
94 | uint16_t len);
95 |
96 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
97 |
98 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
99 |
100 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
101 |
102 | /**
103 | * @}
104 | */
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /* __USBD_IOREQ_H */
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /**
117 | * @}
118 | */
119 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
120 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.c
4 | * @author MCD Application Team
5 | * @brief This file provides the IO requests APIs for control endpoints.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usbd_ioreq.h"
22 |
23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
24 | * @{
25 | */
26 |
27 |
28 | /** @defgroup USBD_IOREQ
29 | * @brief control I/O requests module
30 | * @{
31 | */
32 |
33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions
34 | * @{
35 | */
36 | /**
37 | * @}
38 | */
39 |
40 |
41 | /** @defgroup USBD_IOREQ_Private_Defines
42 | * @{
43 | */
44 |
45 | /**
46 | * @}
47 | */
48 |
49 |
50 | /** @defgroup USBD_IOREQ_Private_Macros
51 | * @{
52 | */
53 | /**
54 | * @}
55 | */
56 |
57 |
58 | /** @defgroup USBD_IOREQ_Private_Variables
59 | * @{
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 |
67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
68 | * @{
69 | */
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | /** @defgroup USBD_IOREQ_Private_Functions
76 | * @{
77 | */
78 |
79 | /**
80 | * @brief USBD_CtlSendData
81 | * send data on the ctl pipe
82 | * @param pdev: device instance
83 | * @param buff: pointer to data buffer
84 | * @param len: length of data to be sent
85 | * @retval status
86 | */
87 | USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
88 | uint8_t *pbuf, uint16_t len)
89 | {
90 | /* Set EP0 State */
91 | pdev->ep0_state = USBD_EP0_DATA_IN;
92 | pdev->ep_in[0].total_length = len;
93 | pdev->ep_in[0].rem_length = len;
94 |
95 | /* Start the transfer */
96 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
97 |
98 | return USBD_OK;
99 | }
100 |
101 | /**
102 | * @brief USBD_CtlContinueSendData
103 | * continue sending data on the ctl pipe
104 | * @param pdev: device instance
105 | * @param buff: pointer to data buffer
106 | * @param len: length of data to be sent
107 | * @retval status
108 | */
109 | USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
110 | uint8_t *pbuf, uint16_t len)
111 | {
112 | /* Start the next transfer */
113 | USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
114 |
115 | return USBD_OK;
116 | }
117 |
118 | /**
119 | * @brief USBD_CtlPrepareRx
120 | * receive data on the ctl pipe
121 | * @param pdev: device instance
122 | * @param buff: pointer to data buffer
123 | * @param len: length of data to be received
124 | * @retval status
125 | */
126 | USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
127 | uint8_t *pbuf, uint16_t len)
128 | {
129 | /* Set EP0 State */
130 | pdev->ep0_state = USBD_EP0_DATA_OUT;
131 | pdev->ep_out[0].total_length = len;
132 | pdev->ep_out[0].rem_length = len;
133 |
134 | /* Start the transfer */
135 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
136 |
137 | return USBD_OK;
138 | }
139 |
140 | /**
141 | * @brief USBD_CtlContinueRx
142 | * continue receive data on the ctl pipe
143 | * @param pdev: device instance
144 | * @param buff: pointer to data buffer
145 | * @param len: length of data to be received
146 | * @retval status
147 | */
148 | USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
149 | uint8_t *pbuf, uint16_t len)
150 | {
151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
152 |
153 | return USBD_OK;
154 | }
155 |
156 | /**
157 | * @brief USBD_CtlSendStatus
158 | * send zero lzngth packet on the ctl pipe
159 | * @param pdev: device instance
160 | * @retval status
161 | */
162 | USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
163 | {
164 | /* Set EP0 State */
165 | pdev->ep0_state = USBD_EP0_STATUS_IN;
166 |
167 | /* Start the transfer */
168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
169 |
170 | return USBD_OK;
171 | }
172 |
173 | /**
174 | * @brief USBD_CtlReceiveStatus
175 | * receive zero lzngth packet on the ctl pipe
176 | * @param pdev: device instance
177 | * @retval status
178 | */
179 | USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
180 | {
181 | /* Set EP0 State */
182 | pdev->ep0_state = USBD_EP0_STATUS_OUT;
183 |
184 | /* Start the transfer */
185 | USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
186 |
187 | return USBD_OK;
188 | }
189 |
190 | /**
191 | * @brief USBD_GetRxCount
192 | * returns the received data length
193 | * @param pdev: device instance
194 | * @param ep_addr: endpoint address
195 | * @retval Rx Data blength
196 | */
197 | uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
198 | {
199 | return USBD_LL_GetRxDataSize(pdev, ep_addr);
200 | }
201 |
202 | /**
203 | * @}
204 | */
205 |
206 |
207 | /**
208 | * @}
209 | */
210 |
211 |
212 | /**
213 | * @}
214 | */
215 |
216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
217 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Src/stm32f1xx_hal_msp.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f1xx_hal_msp.c
5 | * @brief This file provides code for the MSP Initialization
6 | * and de-Initialization codes.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "main.h"
24 | /* USER CODE BEGIN Includes */
25 |
26 | /* USER CODE END Includes */
27 | extern DMA_HandleTypeDef hdma_usart1_rx;
28 |
29 | extern DMA_HandleTypeDef hdma_usart1_tx;
30 |
31 | extern DMA_HandleTypeDef hdma_usart2_rx;
32 |
33 | extern DMA_HandleTypeDef hdma_usart2_tx;
34 |
35 | extern DMA_HandleTypeDef hdma_usart3_rx;
36 |
37 | extern DMA_HandleTypeDef hdma_usart3_tx;
38 |
39 | /* Private typedef -----------------------------------------------------------*/
40 | /* USER CODE BEGIN TD */
41 |
42 | /* USER CODE END TD */
43 |
44 | /* Private define ------------------------------------------------------------*/
45 | /* USER CODE BEGIN Define */
46 |
47 | /* USER CODE END Define */
48 |
49 | /* Private macro -------------------------------------------------------------*/
50 | /* USER CODE BEGIN Macro */
51 |
52 | /* USER CODE END Macro */
53 |
54 | /* Private variables ---------------------------------------------------------*/
55 | /* USER CODE BEGIN PV */
56 |
57 | /* USER CODE END PV */
58 |
59 | /* Private function prototypes -----------------------------------------------*/
60 | /* USER CODE BEGIN PFP */
61 |
62 | /* USER CODE END PFP */
63 |
64 | /* External functions --------------------------------------------------------*/
65 | /* USER CODE BEGIN ExternalFunctions */
66 |
67 | /* USER CODE END ExternalFunctions */
68 |
69 | /* USER CODE BEGIN 0 */
70 |
71 | /* USER CODE END 0 */
72 | /**
73 | * Initializes the Global MSP.
74 | */
75 | void HAL_MspInit(void)
76 | {
77 | /* USER CODE BEGIN MspInit 0 */
78 |
79 | /* USER CODE END MspInit 0 */
80 |
81 | __HAL_RCC_AFIO_CLK_ENABLE();
82 | __HAL_RCC_PWR_CLK_ENABLE();
83 |
84 | /* System interrupt init*/
85 |
86 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
87 | */
88 | __HAL_AFIO_REMAP_SWJ_NOJTAG();
89 |
90 | /* USER CODE BEGIN MspInit 1 */
91 |
92 | /* USER CODE END MspInit 1 */
93 | }
94 |
95 | /**
96 | * @brief UART MSP Initialization
97 | * This function configures the hardware resources used in this example
98 | * @param huart: UART handle pointer
99 | * @retval None
100 | */
101 | void HAL_UART_MspInit(UART_HandleTypeDef* huart)
102 | {
103 | GPIO_InitTypeDef GPIO_InitStruct = {0};
104 | if(huart->Instance==USART1)
105 | {
106 | /* USER CODE BEGIN USART1_MspInit 0 */
107 |
108 | /* USER CODE END USART1_MspInit 0 */
109 | /* Peripheral clock enable */
110 | __HAL_RCC_USART1_CLK_ENABLE();
111 |
112 | __HAL_RCC_GPIOA_CLK_ENABLE();
113 | /**USART1 GPIO Configuration
114 | PA9 ------> USART1_TX
115 | PA10 ------> USART1_RX
116 | */
117 | GPIO_InitStruct.Pin = GPIO_PIN_9;
118 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
119 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
120 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
121 |
122 | GPIO_InitStruct.Pin = GPIO_PIN_10;
123 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
124 | GPIO_InitStruct.Pull = GPIO_NOPULL;
125 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
126 |
127 | /* USART1 DMA Init */
128 | /* USART1_RX Init */
129 | hdma_usart1_rx.Instance = DMA1_Channel5;
130 | hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
131 | hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
132 | hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
133 | hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
134 | hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
135 | hdma_usart1_rx.Init.Mode = DMA_CIRCULAR;
136 | hdma_usart1_rx.Init.Priority = DMA_PRIORITY_HIGH;
137 | if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
138 | {
139 | Error_Handler();
140 | }
141 |
142 | __HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx);
143 |
144 | /* USART1_TX Init */
145 | hdma_usart1_tx.Instance = DMA1_Channel4;
146 | hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
147 | hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
148 | hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE;
149 | hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
150 | hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
151 | hdma_usart1_tx.Init.Mode = DMA_NORMAL;
152 | hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW;
153 | if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK)
154 | {
155 | Error_Handler();
156 | }
157 |
158 | __HAL_LINKDMA(huart,hdmatx,hdma_usart1_tx);
159 |
160 | /* USART1 interrupt Init */
161 | HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
162 | HAL_NVIC_EnableIRQ(USART1_IRQn);
163 | /* USER CODE BEGIN USART1_MspInit 1 */
164 |
165 | /* USER CODE END USART1_MspInit 1 */
166 | }
167 | else if(huart->Instance==USART2)
168 | {
169 | /* USER CODE BEGIN USART2_MspInit 0 */
170 |
171 | /* USER CODE END USART2_MspInit 0 */
172 | /* Peripheral clock enable */
173 | __HAL_RCC_USART2_CLK_ENABLE();
174 |
175 | __HAL_RCC_GPIOA_CLK_ENABLE();
176 | /**USART2 GPIO Configuration
177 | PA2 ------> USART2_TX
178 | PA3 ------> USART2_RX
179 | */
180 | GPIO_InitStruct.Pin = GPIO_PIN_2;
181 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
182 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
183 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
184 |
185 | GPIO_InitStruct.Pin = GPIO_PIN_3;
186 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
187 | GPIO_InitStruct.Pull = GPIO_NOPULL;
188 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
189 |
190 | /* USART2 DMA Init */
191 | /* USART2_RX Init */
192 | hdma_usart2_rx.Instance = DMA1_Channel6;
193 | hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
194 | hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
195 | hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
196 | hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
197 | hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
198 | hdma_usart2_rx.Init.Mode = DMA_CIRCULAR;
199 | hdma_usart2_rx.Init.Priority = DMA_PRIORITY_HIGH;
200 | if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
201 | {
202 | Error_Handler();
203 | }
204 |
205 | __HAL_LINKDMA(huart,hdmarx,hdma_usart2_rx);
206 |
207 | /* USART2_TX Init */
208 | hdma_usart2_tx.Instance = DMA1_Channel7;
209 | hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
210 | hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
211 | hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
212 | hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
213 | hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
214 | hdma_usart2_tx.Init.Mode = DMA_NORMAL;
215 | hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
216 | if (HAL_DMA_Init(&hdma_usart2_tx) != HAL_OK)
217 | {
218 | Error_Handler();
219 | }
220 |
221 | __HAL_LINKDMA(huart,hdmatx,hdma_usart2_tx);
222 |
223 | /* USART2 interrupt Init */
224 | HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
225 | HAL_NVIC_EnableIRQ(USART2_IRQn);
226 | /* USER CODE BEGIN USART2_MspInit 1 */
227 |
228 | /* USER CODE END USART2_MspInit 1 */
229 | }
230 | else if(huart->Instance==USART3)
231 | {
232 | /* USER CODE BEGIN USART3_MspInit 0 */
233 |
234 | /* USER CODE END USART3_MspInit 0 */
235 | /* Peripheral clock enable */
236 | __HAL_RCC_USART3_CLK_ENABLE();
237 |
238 | __HAL_RCC_GPIOB_CLK_ENABLE();
239 | /**USART3 GPIO Configuration
240 | PB10 ------> USART3_TX
241 | PB11 ------> USART3_RX
242 | */
243 | GPIO_InitStruct.Pin = GPIO_PIN_10;
244 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
245 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
246 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
247 |
248 | GPIO_InitStruct.Pin = GPIO_PIN_11;
249 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
250 | GPIO_InitStruct.Pull = GPIO_NOPULL;
251 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
252 |
253 | /* USART3 DMA Init */
254 | /* USART3_RX Init */
255 | hdma_usart3_rx.Instance = DMA1_Channel3;
256 | hdma_usart3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
257 | hdma_usart3_rx.Init.PeriphInc = DMA_PINC_DISABLE;
258 | hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE;
259 | hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
260 | hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
261 | hdma_usart3_rx.Init.Mode = DMA_CIRCULAR;
262 | hdma_usart3_rx.Init.Priority = DMA_PRIORITY_HIGH;
263 | if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK)
264 | {
265 | Error_Handler();
266 | }
267 |
268 | __HAL_LINKDMA(huart,hdmarx,hdma_usart3_rx);
269 |
270 | /* USART3_TX Init */
271 | hdma_usart3_tx.Instance = DMA1_Channel2;
272 | hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
273 | hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE;
274 | hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE;
275 | hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
276 | hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
277 | hdma_usart3_tx.Init.Mode = DMA_NORMAL;
278 | hdma_usart3_tx.Init.Priority = DMA_PRIORITY_LOW;
279 | if (HAL_DMA_Init(&hdma_usart3_tx) != HAL_OK)
280 | {
281 | Error_Handler();
282 | }
283 |
284 | __HAL_LINKDMA(huart,hdmatx,hdma_usart3_tx);
285 |
286 | /* USART3 interrupt Init */
287 | HAL_NVIC_SetPriority(USART3_IRQn, 0, 0);
288 | HAL_NVIC_EnableIRQ(USART3_IRQn);
289 | /* USER CODE BEGIN USART3_MspInit 1 */
290 |
291 | /* USER CODE END USART3_MspInit 1 */
292 | }
293 |
294 | }
295 |
296 | /**
297 | * @brief UART MSP De-Initialization
298 | * This function freeze the hardware resources used in this example
299 | * @param huart: UART handle pointer
300 | * @retval None
301 | */
302 | void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
303 | {
304 | if(huart->Instance==USART1)
305 | {
306 | /* USER CODE BEGIN USART1_MspDeInit 0 */
307 |
308 | /* USER CODE END USART1_MspDeInit 0 */
309 | /* Peripheral clock disable */
310 | __HAL_RCC_USART1_CLK_DISABLE();
311 |
312 | /**USART1 GPIO Configuration
313 | PA9 ------> USART1_TX
314 | PA10 ------> USART1_RX
315 | */
316 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
317 |
318 | /* USART1 DMA DeInit */
319 | HAL_DMA_DeInit(huart->hdmarx);
320 | HAL_DMA_DeInit(huart->hdmatx);
321 |
322 | /* USART1 interrupt DeInit */
323 | HAL_NVIC_DisableIRQ(USART1_IRQn);
324 | /* USER CODE BEGIN USART1_MspDeInit 1 */
325 |
326 | /* USER CODE END USART1_MspDeInit 1 */
327 | }
328 | else if(huart->Instance==USART2)
329 | {
330 | /* USER CODE BEGIN USART2_MspDeInit 0 */
331 |
332 | /* USER CODE END USART2_MspDeInit 0 */
333 | /* Peripheral clock disable */
334 | __HAL_RCC_USART2_CLK_DISABLE();
335 |
336 | /**USART2 GPIO Configuration
337 | PA2 ------> USART2_TX
338 | PA3 ------> USART2_RX
339 | */
340 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
341 |
342 | /* USART2 DMA DeInit */
343 | HAL_DMA_DeInit(huart->hdmarx);
344 | HAL_DMA_DeInit(huart->hdmatx);
345 |
346 | /* USART2 interrupt DeInit */
347 | HAL_NVIC_DisableIRQ(USART2_IRQn);
348 | /* USER CODE BEGIN USART2_MspDeInit 1 */
349 |
350 | /* USER CODE END USART2_MspDeInit 1 */
351 | }
352 | else if(huart->Instance==USART3)
353 | {
354 | /* USER CODE BEGIN USART3_MspDeInit 0 */
355 |
356 | /* USER CODE END USART3_MspDeInit 0 */
357 | /* Peripheral clock disable */
358 | __HAL_RCC_USART3_CLK_DISABLE();
359 |
360 | /**USART3 GPIO Configuration
361 | PB10 ------> USART3_TX
362 | PB11 ------> USART3_RX
363 | */
364 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11);
365 |
366 | /* USART3 DMA DeInit */
367 | HAL_DMA_DeInit(huart->hdmarx);
368 | HAL_DMA_DeInit(huart->hdmatx);
369 |
370 | /* USART3 interrupt DeInit */
371 | HAL_NVIC_DisableIRQ(USART3_IRQn);
372 | /* USER CODE BEGIN USART3_MspDeInit 1 */
373 |
374 | /* USER CODE END USART3_MspDeInit 1 */
375 | }
376 |
377 | }
378 |
379 | /* USER CODE BEGIN 1 */
380 |
381 | /* USER CODE END 1 */
382 |
383 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
384 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Src/stm32f1xx_it.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f1xx_it.c
5 | * @brief Interrupt Service Routines.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "main.h"
23 | #include "stm32f1xx.h"
24 | #include "stm32f1xx_it.h"
25 | /* Private includes ----------------------------------------------------------*/
26 | /* USER CODE BEGIN Includes */
27 | /* USER CODE END Includes */
28 |
29 | /* Private typedef -----------------------------------------------------------*/
30 | /* USER CODE BEGIN TD */
31 |
32 | /* USER CODE END TD */
33 |
34 | /* Private define ------------------------------------------------------------*/
35 | /* USER CODE BEGIN PD */
36 |
37 | /* USER CODE END PD */
38 |
39 | /* Private macro -------------------------------------------------------------*/
40 | /* USER CODE BEGIN PM */
41 |
42 | /* USER CODE END PM */
43 |
44 | /* Private variables ---------------------------------------------------------*/
45 | /* USER CODE BEGIN PV */
46 |
47 | /* USER CODE END PV */
48 |
49 | /* Private function prototypes -----------------------------------------------*/
50 | /* USER CODE BEGIN PFP */
51 |
52 | /* USER CODE END PFP */
53 |
54 | /* Private user code ---------------------------------------------------------*/
55 | /* USER CODE BEGIN 0 */
56 | #include
57 | #include "usbd_cdc_if.h"
58 | //#include "SEGGER_RTT.h"
59 |
60 | extern uint32_t u32LEDcounter;
61 | extern uint32_t u32LEDblinkEnable;
62 |
63 | /* USER CODE END 0 */
64 |
65 | /* External variables --------------------------------------------------------*/
66 | extern PCD_HandleTypeDef hpcd_USB_FS;
67 | extern DMA_HandleTypeDef hdma_usart1_rx;
68 | extern DMA_HandleTypeDef hdma_usart1_tx;
69 | extern DMA_HandleTypeDef hdma_usart2_rx;
70 | extern DMA_HandleTypeDef hdma_usart2_tx;
71 | extern DMA_HandleTypeDef hdma_usart3_rx;
72 | extern DMA_HandleTypeDef hdma_usart3_tx;
73 | extern UART_HandleTypeDef huart1;
74 | extern UART_HandleTypeDef huart2;
75 | extern UART_HandleTypeDef huart3;
76 | /* USER CODE BEGIN EV */
77 |
78 | static void uart_irq_handler(uart_ctx_t *uart_ctx)
79 | {
80 | int buf_len;
81 |
82 | if (uart_ctx->buf.idx == 0)
83 | {
84 | buf_len = DBL_BUF_TOTAL_LEN - __HAL_DMA_GET_COUNTER(uart_ctx->hdma_rx);
85 | } else {
86 | buf_len = DBL_BUF_LEN - __HAL_DMA_GET_COUNTER(uart_ctx->hdma_rx);
87 | }
88 | // SEGGER_RTT_printf(0, "idle[UART1]: %d, len=%d\n", uart_ctx->buf.idx, buf_len);
89 | HAL_UART_DMAStop(uart_ctx->huart);
90 | if (buf_len > 0) {
91 | if (buf_len == 1) {
92 | uart_ctx->buf.data_rest[0] = uart_ctx->buf.data[uart_ctx->buf.idx][0];
93 | uart_ctx->buf.rest_len = 1;
94 | } else {
95 | // memcpy(uart_ctx->buf.data_rest, uart_ctx->buf.data[uart_ctx->buf.idx], buf_len);
96 | HAL_DMA_Start(ctx.memcpy_dma, (uint32_t)uart_ctx->buf.data[uart_ctx->buf.idx], (uint32_t)uart_ctx->buf.data_rest, buf_len);
97 | if (HAL_DMA_PollForTransfer(ctx.memcpy_dma, HAL_DMA_FULL_TRANSFER, 2) == HAL_OK) {
98 | uart_ctx->buf.rest_len = buf_len;
99 | }
100 | }
101 | }
102 | // Set index of double buffer to next.
103 | uart_ctx->buf.idx = 0;
104 | HAL_UART_Receive_DMA(uart_ctx->huart, (uint8_t *)uart_ctx->buf.data[0], DBL_BUF_TOTAL_LEN);
105 | }
106 |
107 | /* USER CODE END EV */
108 |
109 | /******************************************************************************/
110 | /* Cortex-M3 Processor Interruption and Exception Handlers */
111 | /******************************************************************************/
112 | /**
113 | * @brief This function handles Non maskable interrupt.
114 | */
115 | void NMI_Handler(void)
116 | {
117 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
118 |
119 | /* USER CODE END NonMaskableInt_IRQn 0 */
120 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
121 | while (1)
122 | {
123 | }
124 | /* USER CODE END NonMaskableInt_IRQn 1 */
125 | }
126 |
127 | /**
128 | * @brief This function handles Hard fault interrupt.
129 | */
130 | void HardFault_Handler(void)
131 | {
132 | /* USER CODE BEGIN HardFault_IRQn 0 */
133 |
134 | /* USER CODE END HardFault_IRQn 0 */
135 | while (1)
136 | {
137 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
138 | /* USER CODE END W1_HardFault_IRQn 0 */
139 | }
140 | }
141 |
142 | /**
143 | * @brief This function handles Memory management fault.
144 | */
145 | void MemManage_Handler(void)
146 | {
147 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */
148 |
149 | /* USER CODE END MemoryManagement_IRQn 0 */
150 | while (1)
151 | {
152 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
153 | /* USER CODE END W1_MemoryManagement_IRQn 0 */
154 | }
155 | }
156 |
157 | /**
158 | * @brief This function handles Prefetch fault, memory access fault.
159 | */
160 | void BusFault_Handler(void)
161 | {
162 | /* USER CODE BEGIN BusFault_IRQn 0 */
163 |
164 | /* USER CODE END BusFault_IRQn 0 */
165 | while (1)
166 | {
167 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */
168 | /* USER CODE END W1_BusFault_IRQn 0 */
169 | }
170 | }
171 |
172 | /**
173 | * @brief This function handles Undefined instruction or illegal state.
174 | */
175 | void UsageFault_Handler(void)
176 | {
177 | /* USER CODE BEGIN UsageFault_IRQn 0 */
178 |
179 | /* USER CODE END UsageFault_IRQn 0 */
180 | while (1)
181 | {
182 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
183 | /* USER CODE END W1_UsageFault_IRQn 0 */
184 | }
185 | }
186 |
187 | /**
188 | * @brief This function handles System service call via SWI instruction.
189 | */
190 | void SVC_Handler(void)
191 | {
192 | /* USER CODE BEGIN SVCall_IRQn 0 */
193 |
194 | /* USER CODE END SVCall_IRQn 0 */
195 | /* USER CODE BEGIN SVCall_IRQn 1 */
196 |
197 | /* USER CODE END SVCall_IRQn 1 */
198 | }
199 |
200 | /**
201 | * @brief This function handles Debug monitor.
202 | */
203 | void DebugMon_Handler(void)
204 | {
205 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */
206 |
207 | /* USER CODE END DebugMonitor_IRQn 0 */
208 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */
209 |
210 | /* USER CODE END DebugMonitor_IRQn 1 */
211 | }
212 |
213 | /**
214 | * @brief This function handles Pendable request for system service.
215 | */
216 | void PendSV_Handler(void)
217 | {
218 | /* USER CODE BEGIN PendSV_IRQn 0 */
219 |
220 | /* USER CODE END PendSV_IRQn 0 */
221 | /* USER CODE BEGIN PendSV_IRQn 1 */
222 |
223 | /* USER CODE END PendSV_IRQn 1 */
224 | }
225 |
226 | /**
227 | * @brief This function handles System tick timer.
228 | */
229 | void SysTick_Handler(void)
230 | {
231 | /* USER CODE BEGIN SysTick_IRQn 0 */
232 |
233 | /* USER CODE END SysTick_IRQn 0 */
234 | HAL_IncTick();
235 | HAL_SYSTICK_IRQHandler();
236 | /* USER CODE BEGIN SysTick_IRQn 1 */
237 | u32LEDcounter++;
238 | /* USER CODE END SysTick_IRQn 1 */
239 | }
240 |
241 | /******************************************************************************/
242 | /* STM32F1xx Peripheral Interrupt Handlers */
243 | /* Add here the Interrupt Handlers for the used peripherals. */
244 | /* For the available peripheral interrupt handler names, */
245 | /* please refer to the startup file (startup_stm32f1xx.s). */
246 | /******************************************************************************/
247 |
248 | /**
249 | * @brief This function handles DMA1 channel2 global interrupt.
250 | */
251 | void DMA1_Channel2_IRQHandler(void)
252 | {
253 | /* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
254 |
255 | /* USER CODE END DMA1_Channel2_IRQn 0 */
256 | HAL_DMA_IRQHandler(&hdma_usart3_tx);
257 | /* USER CODE BEGIN DMA1_Channel2_IRQn 1 */
258 |
259 | /* USER CODE END DMA1_Channel2_IRQn 1 */
260 | }
261 |
262 | /**
263 | * @brief This function handles DMA1 channel3 global interrupt.
264 | */
265 | void DMA1_Channel3_IRQHandler(void)
266 | {
267 | /* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
268 |
269 | /* USER CODE END DMA1_Channel3_IRQn 0 */
270 | HAL_DMA_IRQHandler(&hdma_usart3_rx);
271 | /* USER CODE BEGIN DMA1_Channel3_IRQn 1 */
272 |
273 | /* USER CODE END DMA1_Channel3_IRQn 1 */
274 | }
275 |
276 | /**
277 | * @brief This function handles DMA1 channel4 global interrupt.
278 | */
279 | void DMA1_Channel4_IRQHandler(void)
280 | {
281 | /* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
282 |
283 | /* USER CODE END DMA1_Channel4_IRQn 0 */
284 | HAL_DMA_IRQHandler(&hdma_usart1_tx);
285 | /* USER CODE BEGIN DMA1_Channel4_IRQn 1 */
286 |
287 | /* USER CODE END DMA1_Channel4_IRQn 1 */
288 | }
289 |
290 | /**
291 | * @brief This function handles DMA1 channel5 global interrupt.
292 | */
293 | void DMA1_Channel5_IRQHandler(void)
294 | {
295 | /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
296 |
297 | /* USER CODE END DMA1_Channel5_IRQn 0 */
298 | HAL_DMA_IRQHandler(&hdma_usart1_rx);
299 | /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
300 |
301 | /* USER CODE END DMA1_Channel5_IRQn 1 */
302 | }
303 |
304 | /**
305 | * @brief This function handles DMA1 channel6 global interrupt.
306 | */
307 | void DMA1_Channel6_IRQHandler(void)
308 | {
309 | /* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
310 |
311 | /* USER CODE END DMA1_Channel6_IRQn 0 */
312 | HAL_DMA_IRQHandler(&hdma_usart2_rx);
313 | /* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
314 |
315 | /* USER CODE END DMA1_Channel6_IRQn 1 */
316 | }
317 |
318 | /**
319 | * @brief This function handles DMA1 channel7 global interrupt.
320 | */
321 | void DMA1_Channel7_IRQHandler(void)
322 | {
323 | /* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
324 |
325 | /* USER CODE END DMA1_Channel7_IRQn 0 */
326 | HAL_DMA_IRQHandler(&hdma_usart2_tx);
327 | /* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
328 |
329 | /* USER CODE END DMA1_Channel7_IRQn 1 */
330 | }
331 |
332 | /**
333 | * @brief This function handles USB low priority or CAN RX0 interrupts.
334 | */
335 | void USB_LP_CAN1_RX0_IRQHandler(void)
336 | {
337 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 0 */
338 |
339 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 0 */
340 | HAL_PCD_IRQHandler(&hpcd_USB_FS);
341 | /* USER CODE BEGIN USB_LP_CAN1_RX0_IRQn 1 */
342 |
343 | /* USER CODE END USB_LP_CAN1_RX0_IRQn 1 */
344 | }
345 |
346 | /**
347 | * @brief This function handles USART1 global interrupt.
348 | */
349 | void USART1_IRQHandler(void)
350 | {
351 | /* USER CODE BEGIN USART1_IRQn 0 */
352 | u32LEDblinkEnable = 1;
353 | u32LEDcounter = 1;
354 | /* USER CODE END USART1_IRQn 0 */
355 | HAL_UART_IRQHandler(&huart1);
356 | /* USER CODE BEGIN USART1_IRQn 1 */
357 | if(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_IDLE))
358 | {
359 | __HAL_UART_CLEAR_IDLEFLAG(&huart1);
360 |
361 | uart_irq_handler(&ctx.uart1);
362 | }
363 | /* USER CODE END USART1_IRQn 1 */
364 | }
365 |
366 | /**
367 | * @brief This function handles USART2 global interrupt.
368 | */
369 | void USART2_IRQHandler(void)
370 | {
371 | /* USER CODE BEGIN USART2_IRQn 0 */
372 | u32LEDblinkEnable = 1;
373 | u32LEDcounter = 1;
374 | /* USER CODE END USART2_IRQn 0 */
375 | HAL_UART_IRQHandler(&huart2);
376 | /* USER CODE BEGIN USART2_IRQn 1 */
377 | if(__HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE))
378 | {
379 | __HAL_UART_CLEAR_IDLEFLAG(&huart2);
380 |
381 | uart_irq_handler(&ctx.uart2);
382 | }
383 | /* USER CODE END USART2_IRQn 1 */
384 | }
385 |
386 | /**
387 | * @brief This function handles USART3 global interrupt.
388 | */
389 | void USART3_IRQHandler(void)
390 | {
391 | /* USER CODE BEGIN USART3_IRQn 0 */
392 | u32LEDblinkEnable = 1;
393 | u32LEDcounter = 1;
394 | /* USER CODE END USART3_IRQn 0 */
395 | HAL_UART_IRQHandler(&huart3);
396 | /* USER CODE BEGIN USART3_IRQn 1 */
397 | if(__HAL_UART_GET_FLAG(&huart3, UART_FLAG_IDLE))
398 | {
399 | __HAL_UART_CLEAR_IDLEFLAG(&huart3);
400 |
401 | uart_irq_handler(&ctx.uart3);
402 | }
403 | /* USER CODE END USART3_IRQn 1 */
404 | }
405 |
406 | /* USER CODE BEGIN 1 */
407 |
408 | /* USER CODE END 1 */
409 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
410 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Src/usb_device.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.c
5 | * @version : v2.0_Cube
6 | * @brief : This file implements the USB Device
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #include "usb_device.h"
25 | #include "usbd_core.h"
26 | #include "usbd_desc.h"
27 | #include "usbd_cdc.h"
28 | #include "usbd_cdc_if.h"
29 |
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* USER CODE BEGIN PV */
35 | /* Private variables ---------------------------------------------------------*/
36 |
37 | /* USER CODE END PV */
38 |
39 | /* USER CODE BEGIN PFP */
40 | /* Private function prototypes -----------------------------------------------*/
41 |
42 | /* USER CODE END PFP */
43 |
44 | /* USB Device Core handle declaration. */
45 | USBD_HandleTypeDef hUsbDeviceFS;
46 |
47 | /*
48 | * -- Insert your variables declaration here --
49 | */
50 | /* USER CODE BEGIN 0 */
51 |
52 | /* USER CODE END 0 */
53 |
54 | /*
55 | * -- Insert your external function declaration here --
56 | */
57 | /* USER CODE BEGIN 1 */
58 |
59 | /* USER CODE END 1 */
60 |
61 | /**
62 | * Init USB device Library, add supported class and start the library
63 | * @retval None
64 | */
65 | void MX_USB_DEVICE_Init(void)
66 | {
67 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
68 |
69 | /* USER CODE END USB_DEVICE_Init_PreTreatment */
70 |
71 | /* Init Device Library, add supported class and start the library. */
72 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
73 | {
74 | Error_Handler();
75 | }
76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
77 | {
78 | Error_Handler();
79 | }
80 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
81 | {
82 | Error_Handler();
83 | }
84 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
85 | {
86 | Error_Handler();
87 | }
88 |
89 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
90 |
91 | /* USER CODE END USB_DEVICE_Init_PostTreatment */
92 | }
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
103 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Src/usbd_cdc_if.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file : usbd_cdc_if.c
4 | * @version : v2.0_Cube
5 | * @brief : Usb device for Virtual Com Port.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2021 STMicroelectronics.
10 | * All rights reserved.
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 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "usbd_cdc_if.h"
23 |
24 | /* USER CODE BEGIN INCLUDE */
25 | #include "main.h"
26 | //#include "SEGGER_RTT.h"
27 | /* USER CODE END INCLUDE */
28 |
29 | /* Private typedef -----------------------------------------------------------*/
30 | /* Private define ------------------------------------------------------------*/
31 | /* Private macro -------------------------------------------------------------*/
32 |
33 | /* USER CODE BEGIN PV */
34 | /* Private variables ---------------------------------------------------------*/
35 |
36 | /* USER CODE END PV */
37 |
38 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
39 | * @brief Usb device library.
40 | * @{
41 | */
42 |
43 | /** @addtogroup USBD_CDC_IF
44 | * @{
45 | */
46 |
47 | /** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions
48 | * @brief Private types.
49 | * @{
50 | */
51 |
52 | /* USER CODE BEGIN PRIVATE_TYPES */
53 |
54 | /* USER CODE END PRIVATE_TYPES */
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines
61 | * @brief Private defines.
62 | * @{
63 | */
64 |
65 | /* USER CODE BEGIN PRIVATE_DEFINES */
66 | /* USER CODE END PRIVATE_DEFINES */
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros
73 | * @brief Private macros.
74 | * @{
75 | */
76 |
77 | /* USER CODE BEGIN PRIVATE_MACRO */
78 |
79 | /* USER CODE END PRIVATE_MACRO */
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables
86 | * @brief Private variables.
87 | * @{
88 | */
89 | /* Create buffer for reception and transmission */
90 | /* It's up to user to redefine and/or remove those define */
91 | /** Received data over USB are stored in this buffer */
92 | uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
93 |
94 | /** Data to send over USB CDC are stored in this buffer */
95 | uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
96 |
97 | /* USER CODE BEGIN PRIVATE_VARIABLES */
98 |
99 | /* USER CODE END PRIVATE_VARIABLES */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
106 | * @brief Public variables.
107 | * @{
108 | */
109 |
110 | extern USBD_HandleTypeDef hUsbDeviceFS;
111 |
112 | /* USER CODE BEGIN EXPORTED_VARIABLES */
113 |
114 | /* USER CODE END EXPORTED_VARIABLES */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes
121 | * @brief Private functions declaration.
122 | * @{
123 | */
124 |
125 | static int8_t CDC_Init_FS(void);
126 | static int8_t CDC_DeInit_FS(void);
127 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length, uint16_t index);
128 | static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len, uint16_t index);
129 |
130 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
131 |
132 | /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
133 |
134 | /**
135 | * @}
136 | */
137 |
138 | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
139 | {
140 | CDC_Init_FS,
141 | CDC_DeInit_FS,
142 | CDC_Control_FS,
143 | CDC_Receive_FS
144 | };
145 |
146 | /* Private functions ---------------------------------------------------------*/
147 | /**
148 | * @brief Initializes the CDC media low layer over the FS USB IP
149 | * @retval USBD_OK if all operations are OK else USBD_FAIL
150 | */
151 | static int8_t CDC_Init_FS(void)
152 | {
153 | /* USER CODE BEGIN 3 */
154 | /* Set Application Buffers */
155 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
156 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
157 | return (USBD_OK);
158 | /* USER CODE END 3 */
159 | }
160 |
161 | /**
162 | * @brief DeInitializes the CDC media low layer
163 | * @retval USBD_OK if all operations are OK else USBD_FAIL
164 | */
165 | static int8_t CDC_DeInit_FS(void)
166 | {
167 | /* USER CODE BEGIN 4 */
168 | return (USBD_OK);
169 | /* USER CODE END 4 */
170 | }
171 |
172 | /**
173 | * @brief Manage the CDC class requests
174 | * @param cmd: Command code
175 | * @param pbuf: Buffer containing command data (request parameters)
176 | * @param length: Number of data to be sent (in bytes)
177 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
178 | */
179 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length, uint16_t index)
180 | {
181 | /* USER CODE BEGIN 5 */
182 | switch(cmd)
183 | {
184 | case CDC_SEND_ENCAPSULATED_COMMAND:
185 |
186 | break;
187 |
188 | case CDC_GET_ENCAPSULATED_RESPONSE:
189 |
190 | break;
191 |
192 | case CDC_SET_COMM_FEATURE:
193 |
194 | break;
195 |
196 | case CDC_GET_COMM_FEATURE:
197 |
198 | break;
199 |
200 | case CDC_CLEAR_COMM_FEATURE:
201 |
202 | break;
203 |
204 | /*******************************************************************************/
205 | /* Line Coding Structure */
206 | /*-----------------------------------------------------------------------------*/
207 | /* Offset | Field | Size | Value | Description */
208 | /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
209 | /* 4 | bCharFormat | 1 | Number | Stop bits */
210 | /* 0 - 1 Stop bit */
211 | /* 1 - 1.5 Stop bits */
212 | /* 2 - 2 Stop bits */
213 | /* 5 | bParityType | 1 | Number | Parity */
214 | /* 0 - None */
215 | /* 1 - Odd */
216 | /* 2 - Even */
217 | /* 3 - Mark */
218 | /* 4 - Space */
219 | /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
220 | /*******************************************************************************/
221 | case CDC_SET_LINE_CODING:
222 | {
223 | uart_ctx_t * const uart_ctx = (index < 2) ? &ctx.uart1 : &ctx.uart2;
224 |
225 | USBD_CDC_LineCodingTypeDef *line_coding = (USBD_CDC_LineCodingTypeDef *)pbuf;
226 | if (line_coding->bitrate == 0 || line_coding->datatype == 0) {
227 | break;
228 | }
229 |
230 | /*
231 | * The maping between USBD_CDC_LineCodingTypeDef and line coding structure.
232 | * dwDTERate -> line_coding->bitrate
233 | * bCharFormat -> line_coding->format
234 | * bParityType -> line_coding->paritytype
235 | * bDataBits -> line_coding->datatype
236 | */
237 | uart_ctx->huart->Init.BaudRate = line_coding->bitrate;
238 | uart_ctx->huart->Init.WordLength = (line_coding->datatype == 8) ? UART_WORDLENGTH_8B : UART_WORDLENGTH_9B;
239 | uart_ctx->huart->Init.StopBits = (line_coding->format == 0) ? UART_STOPBITS_1 : UART_STOPBITS_2;
240 | uart_ctx->huart->Init.Parity = (line_coding->paritytype == 0) ? UART_PARITY_NONE : (line_coding->paritytype == 1) ? UART_PARITY_ODD : UART_PARITY_EVEN;
241 | uart_ctx->huart->Init.Mode = UART_MODE_TX_RX;
242 | uart_ctx->huart->Init.HwFlowCtl = UART_HWCONTROL_NONE;
243 | uart_ctx->huart->Init.OverSampling = UART_OVERSAMPLING_16;
244 |
245 | __HAL_UART_DISABLE(uart_ctx->huart);
246 | if (HAL_UART_Init(uart_ctx->huart) != HAL_OK) {
247 | while(1)
248 | {
249 | }
250 | }
251 |
252 | __HAL_UART_ENABLE_IT(uart_ctx->huart, UART_IT_IDLE);
253 | __HAL_UART_ENABLE(uart_ctx->huart);
254 | NVIC_ClearPendingIRQ(uart_ctx->irq_num);
255 |
256 | HAL_UART_DMAStop(uart_ctx->huart);
257 | HAL_UART_Receive_DMA(uart_ctx->huart, (uint8_t *)uart_ctx->buf.data[0], DBL_BUF_TOTAL_LEN);
258 |
259 | // SEGGER_RTT_printf(0, "LINE_CODING: UART=%s, bitrate=%d, format=%d, parity=%d, datatype=%d\n",
260 | // uart_ctx->name, line_coding->bitrate, line_coding->format, line_coding->paritytype, line_coding->datatype);
261 | }
262 | break;
263 |
264 | case CDC_GET_LINE_CODING:
265 |
266 | break;
267 |
268 | case CDC_SET_CONTROL_LINE_STATE:
269 |
270 | break;
271 |
272 | case CDC_SEND_BREAK:
273 |
274 | break;
275 |
276 | default:
277 | break;
278 | }
279 |
280 | return (USBD_OK);
281 | /* USER CODE END 5 */
282 | }
283 |
284 | /**
285 | * @brief Data received over USB OUT endpoint are sent over CDC interface
286 | * through this function.
287 | *
288 | * @note
289 | * This function will issue a NAK packet on any OUT packet received on
290 | * USB endpoint until exiting this function. If you exit this function
291 | * before transfer is complete on CDC interface (ie. using DMA controller)
292 | * it will result in receiving more data while previous ones are still
293 | * not sent.
294 | *
295 | * @param Buf: Buffer of data to be received
296 | * @param Len: Number of data received (in bytes)
297 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
298 | */
299 | static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len, uint16_t index)
300 | {
301 | /* USER CODE BEGIN 6 */
302 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
303 | USBD_CDC_ReceivePacket(&hUsbDeviceFS, index);
304 | #if defined(LOOPBACK_TEST)
305 | CDC_Transmit_FS(Buf, *Len, index);
306 | #else
307 | // SEGGER_RTT_printf(0, "[index=%d] Tx: %c\n", index, Buf[0]);
308 | HAL_UART_Transmit_DMA((index < 2) ? ctx.uart1.huart : ctx.uart2.huart, Buf, *Len);
309 | #endif
310 | return (USBD_OK);
311 | /* USER CODE END 6 */
312 | }
313 |
314 | /**
315 | * @brief CDC_Transmit_FS
316 | * Data to send over USB IN endpoint are sent over CDC interface
317 | * through this function.
318 | * @note
319 | *
320 | *
321 | * @param Buf: Buffer of data to be sent
322 | * @param Len: Number of data to be sent (in bytes)
323 | * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY
324 | */
325 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len, uint16_t index)
326 | {
327 | uint8_t result = USBD_OK;
328 | /* USER CODE BEGIN 7 */
329 | int i;
330 | int rest_len;
331 | USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
332 | if (hcdc->TxState != 0){
333 | return USBD_BUSY;
334 | }
335 | rest_len = Len;
336 | for (i = 0; result == USBD_OK && i <= Len; rest_len = Len - i) {
337 |
338 | if (rest_len >= USB_FS_MAX_PACKET_SIZE) {
339 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, &Buf[i], USB_FS_MAX_PACKET_SIZE);
340 | i += USB_FS_MAX_PACKET_SIZE;
341 | do {
342 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS, index);
343 | } while (result == USBD_BUSY);
344 |
345 | } else if (rest_len == 0) {
346 | // It's necessary to send zero-length packet to compliance USB protocol.
347 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, &Buf[0], 0);
348 | do {
349 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS, index);
350 | } while (result == USBD_BUSY);
351 | break;
352 |
353 | } else {
354 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, &Buf[i], rest_len);
355 | do {
356 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS, index);
357 | } while (result == USBD_BUSY);
358 | break;
359 |
360 | }
361 | }
362 |
363 | /* USER CODE END 7 */
364 | return result;
365 | }
366 |
367 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
368 |
369 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
370 |
371 | /**
372 | * @}
373 | */
374 |
375 | /**
376 | * @}
377 | */
378 |
379 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
380 |
--------------------------------------------------------------------------------
/STM32F103_DUAL_VCP/Src/usbd_desc.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_desc.c
5 | * @version : v2.0_Cube
6 | * @brief : This file implements the USB device descriptors.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2021 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "usbd_core.h"
24 | #include "usbd_desc.h"
25 | #include "usbd_conf.h"
26 |
27 | /* USER CODE BEGIN INCLUDE */
28 |
29 | /* USER CODE END INCLUDE */
30 |
31 | /* Private typedef -----------------------------------------------------------*/
32 | /* Private define ------------------------------------------------------------*/
33 | /* Private macro -------------------------------------------------------------*/
34 |
35 | /* USER CODE BEGIN PV */
36 | /* Private variables ---------------------------------------------------------*/
37 |
38 | /* USER CODE END PV */
39 |
40 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
41 | * @{
42 | */
43 |
44 | /** @addtogroup USBD_DESC
45 | * @{
46 | */
47 |
48 | /** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
49 | * @brief Private types.
50 | * @{
51 | */
52 |
53 | /* USER CODE BEGIN PRIVATE_TYPES */
54 |
55 | /* USER CODE END PRIVATE_TYPES */
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
62 | * @brief Private defines.
63 | * @{
64 | */
65 |
66 | #define USBD_VID 1155
67 | #define USBD_LANGID_STRING 1033
68 | #define USBD_MANUFACTURER_STRING "STMicroelectronics"
69 | #define USBD_PID_FS 22336
70 | #define USBD_PRODUCT_STRING_FS "STM32_DUAL_VCP"
71 | #define USBD_CONFIGURATION_STRING_FS "CDC Config"
72 | #define USBD_INTERFACE_STRING_FS "CDC Interface"
73 |
74 | /* USER CODE BEGIN PRIVATE_DEFINES */
75 |
76 | /* USER CODE END PRIVATE_DEFINES */
77 |
78 | /**
79 | * @}
80 | */
81 |
82 | /* USER CODE BEGIN 0 */
83 |
84 | /* USER CODE END 0 */
85 |
86 | /** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
87 | * @brief Private macros.
88 | * @{
89 | */
90 |
91 | /* USER CODE BEGIN PRIVATE_MACRO */
92 |
93 | /* USER CODE END PRIVATE_MACRO */
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
100 | * @brief Private functions declaration.
101 | * @{
102 | */
103 |
104 | static void Get_SerialNum(void);
105 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
112 | * @brief Private functions declaration for FS.
113 | * @{
114 | */
115 |
116 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
117 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
118 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
119 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
120 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
121 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
122 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
123 |
124 | /**
125 | * @}
126 | */
127 |
128 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
129 | * @brief Private variables.
130 | * @{
131 | */
132 |
133 | USBD_DescriptorsTypeDef FS_Desc =
134 | {
135 | USBD_FS_DeviceDescriptor
136 | , USBD_FS_LangIDStrDescriptor
137 | , USBD_FS_ManufacturerStrDescriptor
138 | , USBD_FS_ProductStrDescriptor
139 | , USBD_FS_SerialStrDescriptor
140 | , USBD_FS_ConfigStrDescriptor
141 | , USBD_FS_InterfaceStrDescriptor
142 | };
143 |
144 | #if defined ( __ICCARM__ ) /* IAR Compiler */
145 | #pragma data_alignment=4
146 | #endif /* defined ( __ICCARM__ ) */
147 | /** USB standard device descriptor. */
148 | __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
149 | {
150 | 0x12, /*bLength */
151 | USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
152 | 0x00, /*bcdUSB */
153 | 0x02,
154 | 0xEF, //0x02, /*bDeviceClass*/
155 | 0x02, /*bDeviceSubClass*/
156 | 0x01, //0x00, /*bDeviceProtocol*/
157 | USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
158 | LOBYTE(USBD_VID), /*idVendor*/
159 | HIBYTE(USBD_VID), /*idVendor*/
160 | LOBYTE(USBD_PID_FS), /*idProduct*/
161 | HIBYTE(USBD_PID_FS), /*idProduct*/
162 | 0x00, /*bcdDevice rel. 2.00*/
163 | 0x02,
164 | USBD_IDX_MFC_STR, /*Index of manufacturer string*/
165 | USBD_IDX_PRODUCT_STR, /*Index of product string*/
166 | USBD_IDX_SERIAL_STR, /*Index of serial number string*/
167 | USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/
168 | };
169 |
170 | /* USB_DeviceDescriptor */
171 |
172 | /**
173 | * @}
174 | */
175 |
176 | /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
177 | * @brief Private variables.
178 | * @{
179 | */
180 |
181 | #if defined ( __ICCARM__ ) /* IAR Compiler */
182 | #pragma data_alignment=4
183 | #endif /* defined ( __ICCARM__ ) */
184 |
185 | /** USB lang indentifier descriptor. */
186 | __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
187 | {
188 | USB_LEN_LANGID_STR_DESC,
189 | USB_DESC_TYPE_STRING,
190 | LOBYTE(USBD_LANGID_STRING),
191 | HIBYTE(USBD_LANGID_STRING)
192 | };
193 |
194 | #if defined ( __ICCARM__ ) /* IAR Compiler */
195 | #pragma data_alignment=4
196 | #endif /* defined ( __ICCARM__ ) */
197 | /* Internal string descriptor. */
198 | __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
199 |
200 | #if defined ( __ICCARM__ ) /*!< IAR Compiler */
201 | #pragma data_alignment=4
202 | #endif
203 | __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
204 | USB_SIZ_STRING_SERIAL,
205 | USB_DESC_TYPE_STRING,
206 | };
207 |
208 | /**
209 | * @}
210 | */
211 |
212 | /** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions
213 | * @brief Private functions.
214 | * @{
215 | */
216 |
217 | /**
218 | * @brief Return the device descriptor
219 | * @param speed : Current device speed
220 | * @param length : Pointer to data length variable
221 | * @retval Pointer to descriptor buffer
222 | */
223 | uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
224 | {
225 | UNUSED(speed);
226 | *length = sizeof(USBD_FS_DeviceDesc);
227 | return USBD_FS_DeviceDesc;
228 | }
229 |
230 | /**
231 | * @brief Return the LangID string descriptor
232 | * @param speed : Current device speed
233 | * @param length : Pointer to data length variable
234 | * @retval Pointer to descriptor buffer
235 | */
236 | uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
237 | {
238 | UNUSED(speed);
239 | *length = sizeof(USBD_LangIDDesc);
240 | return USBD_LangIDDesc;
241 | }
242 |
243 | /**
244 | * @brief Return the product string descriptor
245 | * @param speed : Current device speed
246 | * @param length : Pointer to data length variable
247 | * @retval Pointer to descriptor buffer
248 | */
249 | uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
250 | {
251 | if(speed == 0)
252 | {
253 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
254 | }
255 | else
256 | {
257 | USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
258 | }
259 | return USBD_StrDesc;
260 | }
261 |
262 | /**
263 | * @brief Return the manufacturer string descriptor
264 | * @param speed : Current device speed
265 | * @param length : Pointer to data length variable
266 | * @retval Pointer to descriptor buffer
267 | */
268 | uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
269 | {
270 | UNUSED(speed);
271 | USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
272 | return USBD_StrDesc;
273 | }
274 |
275 | /**
276 | * @brief Return the serial number string descriptor
277 | * @param speed : Current device speed
278 | * @param length : Pointer to data length variable
279 | * @retval Pointer to descriptor buffer
280 | */
281 | uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
282 | {
283 | UNUSED(speed);
284 | *length = USB_SIZ_STRING_SERIAL;
285 |
286 | /* Update the serial number string descriptor with the data from the unique
287 | * ID */
288 | Get_SerialNum();
289 | /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */
290 |
291 | /* USER CODE END USBD_FS_SerialStrDescriptor */
292 | return (uint8_t *) USBD_StringSerial;
293 | }
294 |
295 | /**
296 | * @brief Return the configuration string descriptor
297 | * @param speed : Current device speed
298 | * @param length : Pointer to data length variable
299 | * @retval Pointer to descriptor buffer
300 | */
301 | uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
302 | {
303 | if(speed == USBD_SPEED_HIGH)
304 | {
305 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
306 | }
307 | else
308 | {
309 | USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
310 | }
311 | return USBD_StrDesc;
312 | }
313 |
314 | /**
315 | * @brief Return the interface string descriptor
316 | * @param speed : Current device speed
317 | * @param length : Pointer to data length variable
318 | * @retval Pointer to descriptor buffer
319 | */
320 | uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
321 | {
322 | if(speed == 0)
323 | {
324 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
325 | }
326 | else
327 | {
328 | USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
329 | }
330 | return USBD_StrDesc;
331 | }
332 |
333 | /**
334 | * @brief Create the serial number string descriptor
335 | * @param None
336 | * @retval None
337 | */
338 | static void Get_SerialNum(void)
339 | {
340 | uint32_t deviceserial0, deviceserial1, deviceserial2;
341 |
342 | deviceserial0 = *(uint32_t *) DEVICE_ID1;
343 | deviceserial1 = *(uint32_t *) DEVICE_ID2;
344 | deviceserial2 = *(uint32_t *) DEVICE_ID3;
345 |
346 | deviceserial0 += deviceserial2;
347 |
348 | if (deviceserial0 != 0)
349 | {
350 | IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
351 | IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
352 | }
353 | }
354 |
355 | /**
356 | * @brief Convert Hex 32Bits value into char
357 | * @param value: value to convert
358 | * @param pbuf: pointer to the buffer
359 | * @param len: buffer length
360 | * @retval None
361 | */
362 | static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
363 | {
364 | uint8_t idx = 0;
365 |
366 | for (idx = 0; idx < len; idx++)
367 | {
368 | if (((value >> 28)) < 0xA)
369 | {
370 | pbuf[2 * idx] = (value >> 28) + '0';
371 | }
372 | else
373 | {
374 | pbuf[2 * idx] = (value >> 28) + 'A' - 10;
375 | }
376 |
377 | value = value << 4;
378 |
379 | pbuf[2 * idx + 1] = 0;
380 | }
381 | }
382 | /**
383 | * @}
384 | */
385 |
386 | /**
387 | * @}
388 | */
389 |
390 | /**
391 | * @}
392 | */
393 |
394 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
395 |
--------------------------------------------------------------------------------
/Win7-Dual-VCP-Driver/Win7_Dual_VCP_Driver.inf:
--------------------------------------------------------------------------------
1 | [Version]
2 | Signature = "$Windows NT$"
3 | Class = Ports
4 | ClassGUID = {4D36E978-E325-11CE-BFC1-08002BE10318}
5 | Provider = %ManufacturerName%
6 | DriverVer = 2021-01-28,1.00
7 |
8 | ; ========== Manufacturer/Models sections ===========
9 |
10 | [Manufacturer]
11 | %ManufacturerName% = Standard,NTx86,NTamd64
12 |
13 | ; List of devices supporting the Virtual COM port (with the corresponding interface ID)
14 |
15 | [Standard.NTx86]
16 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740
17 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_00
18 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_01
19 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_02
20 |
21 | [Standard.NTamd64]
22 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740
23 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_00
24 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_01
25 | %DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_5740&MI_02
26 |
27 | ; =================== Installation ===================
28 |
29 | [USB_InstallVCP]
30 | Include = mdmcpq.inf
31 | CopyFiles = FakeModemCopyFileSection
32 | AddReg = USB_InstallVCP.AddReg
33 |
34 | [USB_InstallVCP.AddReg]
35 | HKR,,DevLoader,,*ntkern
36 | HKR,,NTMPDriver,,usbser.sys
37 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
38 |
39 | [USB_InstallVCP.Services]
40 | AddService=usbser, 0x00000002, DriverService
41 |
42 | [DriverService]
43 | DisplayName=%DeviceNameVCP%
44 | ServiceType=1
45 | StartType=3
46 | ErrorControl=1
47 | ServiceBinary=%12%\usbser.sys
48 |
49 | ; [DestinationDirs]
50 | ; If your INF needs to copy files, you must not use the DefaultDestDir directive here.
51 | ; You must explicitly reference all file-list-section names in this section.
52 |
53 | ; =================== Strings ===================
54 |
55 | [Strings]
56 | ManufacturerName="RadioOperator"
57 | ;ClassName="Universal Serial Bus devices"
58 | DeviceNameVCP="STM32_DUAL_VCP"
59 | REG_MULTI_SZ = 0x00010000
60 |
--------------------------------------------------------------------------------