Skip to content

Commit b409ad5

Browse files
committed
Add menu to enable Serial instances and USB interface
If USB is not supported by the target an error is displayed at the compile time. Review build option: USB_MANUFACTURER is now used USB_PRODUCT is now used Signed-off-by: Frederic.Pillon <[email protected]>
1 parent f760949 commit b409ad5

File tree

8 files changed

+153
-57
lines changed

8 files changed

+153
-57
lines changed

Diff for: boards.txt

+84-40
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# See: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-specification
22

33
menu.board_part_num=Board part number
4+
5+
menu.Other_serial=Other serial instance
6+
menu.USB_interface=USB interface
7+
48
menu.upload_method=Upload method
59

610
################################################################################
@@ -15,25 +19,21 @@ Nucleo_144.pid.0=0x5711
1519

1620
Nucleo_144.build.core=arduino
1721
Nucleo_144.build.board=Nucleo_144
22+
Nucleo_144.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx}
1823

1924
# NUCLEO_F429ZI board
20-
25+
# Support: USB HID, Serial1 (USART1 on PG9, PG14) and Serial2 (USART2 on PD6, PD5)
2126
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI=Nucleo F429ZI
2227
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.node=NODE_F429ZI
2328
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.upload.maximum_size=2097152
2429
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.upload.maximum_data_size=262144
2530
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.mcu=cortex-m4
2631
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.f_cpu=16000000L
27-
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.usb_product="NUCLEO-F429ZI"
2832
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.board=NUCLEO_F429ZI
2933
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.series=STM32F4xx
34+
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.product_line=STM32F429xx
3035
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.variant=NUCLEO_F429ZI
3136
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.cmsis_lib_gcc=arm_cortexM4l_math
32-
#To enable USB add '-DUSBCON'
33-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
34-
#To enable Serial1 (USART1 on PG9, PG14) add -DENABLE_SERIAL1
35-
#To enable Serial2 (USART2 on PD6, PD5) add -DENABLE_SERIAL2
36-
Nucleo_144.menu.board_part_num.NUCLEO_F429ZI.build.extra_flags=-DSTM32F429xx {build.usb_flags}
3737

3838
# Upload menu
3939
Nucleo_144.menu.upload_method.MassStorageMethod=Mass Storage
@@ -56,9 +56,10 @@ Nucleo_64.pid.0=0x5711
5656

5757
Nucleo_64.build.core=arduino
5858
Nucleo_64.build.board=Nucleo_64
59+
Nucleo_64.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx}
5960

6061
# NUCLEO_F030R8 board
61-
62+
# Support: Serial1 (USART1 on PA10, PA9)
6263
Nucleo_64.menu.board_part_num.NUCLEO_F030R8=Nucleo F030R8
6364
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.node="NODE_F030R8,NUCLEO"
6465
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.upload.maximum_size=65536
@@ -67,13 +68,12 @@ Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.mcu=cortex-m0
6768
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.f_cpu=48000000L
6869
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.board=NUCLEO_F030R8
6970
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.series=STM32F0xx
71+
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.product_line=STM32F030x8
7072
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.variant=NUCLEO_F030R8
7173
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.cmsis_lib_gcc=arm_cortexM0l_math
72-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
73-
Nucleo_64.menu.board_part_num.NUCLEO_F030R8.build.extra_flags=-DSTM32F030x8
7474

7575
# NUCLEO_F091RC board
76-
76+
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART2 on PA1, PA0)
7777
Nucleo_64.menu.board_part_num.NUCLEO_F091RC=Nucleo F091RC
7878
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.node=NODE_F091RC
7979
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.upload.maximum_size=262144
@@ -82,14 +82,12 @@ Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.mcu=cortex-m0
8282
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.f_cpu=8000000L
8383
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.board=NUCLEO_F091RC
8484
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.series=STM32F0xx
85+
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.product_line=STM32F091xC
8586
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.variant=NUCLEO_F091RC
8687
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.cmsis_lib_gcc=arm_cortexM0l_math
87-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
88-
#To enable Serial2 (USART2 on PA1, PA0) add -DENABLE_SERIAL2
89-
Nucleo_64.menu.board_part_num.NUCLEO_F091RC.build.extra_flags=-DSTM32F091xC
9088

9189
# NUCLEO_F303RE board
92-
90+
# Support: Serial1 (USART1 on PA10, PA9) and Serial2 (USART2 on PA1, PA0)
9391
Nucleo_64.menu.board_part_num.NUCLEO_F303RE=Nucleo F303RE
9492
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.node=NODE_F303RE
9593
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.upload.maximum_size=524288
@@ -98,14 +96,12 @@ Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.mcu=cortex-m4
9896
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.f_cpu=8000000L
9997
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.board=NUCLEO_F303RE
10098
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.series=STM32F3xx
99+
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.product_line=STM32F303xE
101100
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.variant=NUCLEO_F303RE
102101
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.cmsis_lib_gcc=arm_cortexM4l_math
103-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
104-
#To enable Serial2 (USART2 on PA1, PA0) add -DENABLE_SERIAL2
105-
Nucleo_64.menu.board_part_num.NUCLEO_F303RE.build.extra_flags=-DSTM32F303xE
106102

107103
# NUCLEO_L053R8 board
108-
104+
# Support: Serial1 (USART1 on PA10, PA9)
109105
Nucleo_64.menu.board_part_num.NUCLEO_L053R8=Nucleo L053R8
110106
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.node=NODE_L053R8
111107
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.upload.maximum_size=65536
@@ -114,13 +110,13 @@ Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.mcu=cortex-m0
114110
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.f_cpu=2000000L
115111
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.board=NUCLEO_L053R8
116112
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.series=STM32L0xx
113+
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.product_line=STM32L053xx
117114
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.variant=NUCLEO_L053R8
118115
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.cmsis_lib_gcc=arm_cortexM0l_math
119-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
120-
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.extra_flags=-DSTM32L053xx -D__CORTEX_SC=0
116+
Nucleo_64.menu.board_part_num.NUCLEO_L053R8.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx} -D__CORTEX_SC=0
121117

122118
# NUCLEO_L476RG board
123-
119+
# Support: Serial1 (USART1 on PA10, PA9)
124120
Nucleo_64.menu.board_part_num.NUCLEO_L476RG=Nucleo L476RG
125121
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.node=NODE_L476RG
126122
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.upload.maximum_size=1048576
@@ -129,10 +125,9 @@ Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.mcu=cortex-m4
129125
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.f_cpu=4000000L
130126
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.board=NUCLEO_L476RG
131127
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.series=STM32L4xx
128+
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.product_line=STM32L476xx
132129
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.variant=NUCLEO_L476RG
133130
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.cmsis_lib_gcc=arm_cortexM4l_math
134-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
135-
Nucleo_64.menu.board_part_num.NUCLEO_L476RG.build.extra_flags=-DSTM32L476xx
136131

137132
# Upload menu
138133
Nucleo_64.menu.upload_method.MassStorageMethod=Mass Storage
@@ -155,22 +150,21 @@ Nucleo_32.pid.0=0x5711
155150

156151
Nucleo_32.build.core=arduino
157152
Nucleo_32.build.board=Nucleo_32
153+
Nucleo_32.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx}
158154

159155
# NUCLEO_L432KC board
160-
156+
# Support: Serial1 (USART1 on PA10, PA9)
161157
Nucleo_32.menu.board_part_num.NUCLEO_L432KC=Nucleo L432KC
162158
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.node=NODE_L432KC
163159
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.upload.maximum_size=65536
164160
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.upload.maximum_data_size=262144
165161
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.mcu=cortex-m4
166162
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.f_cpu=80000000L
167-
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.usb_product="NUCLEO-L432KC"
168163
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.board=NUCLEO_L432KC
169164
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.series=STM32L4xx
165+
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.product_line=STM32L432xx
170166
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.variant=NUCLEO_L432KC
171167
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.cmsis_lib_gcc=arm_cortexM4l_math
172-
#To enable Serial1 (USART1 on PA10, PA9) add -DENABLE_SERIAL1
173-
Nucleo_32.menu.board_part_num.NUCLEO_L432KC.build.extra_flags=-DSTM32L432xx {build.usb_flags}
174168

175169
# Upload menu
176170
Nucleo_32.menu.upload_method.MassStorageMethod=Mass Storage
@@ -193,42 +187,35 @@ Disco.pid.0=0x5711
193187

194188
Disco.build.core=arduino
195189
Disco.build.board=Disco
190+
Disco.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.enable_Serialx}
196191

197192
# DISCO_F407VG board
198-
193+
# Support: USB HID
199194
Disco.menu.board_part_num.DISCO_F407VG=STM32F407G-DISC1
200195
Disco.menu.board_part_num.DISCO_F407VG.node=DIS_F407VG
201196
Disco.menu.board_part_num.DISCO_F407VG.upload.maximum_size=1048576
202197
Disco.menu.board_part_num.DISCO_F407VG.upload.maximum_data_size=196608
203198
Disco.menu.board_part_num.DISCO_F407VG.build.mcu=cortex-m4
204199
Disco.menu.board_part_num.DISCO_F407VG.build.f_cpu=16000000L
205-
Disco.menu.board_part_num.DISCO_F407VG.build.usb_product="DISCO-F407G"
206200
Disco.menu.board_part_num.DISCO_F407VG.build.board=DISCO_F407VG
207201
Disco.menu.board_part_num.DISCO_F407VG.build.series=STM32F4xx
202+
Disco.menu.board_part_num.DISCO_F407VG.build.product_line=STM32F407xx
208203
Disco.menu.board_part_num.DISCO_F407VG.build.variant=DISCO_F407VG
209204
Disco.menu.board_part_num.DISCO_F407VG.build.cmsis_lib_gcc=arm_cortexM4l_math
210-
#To enable USB add '-DUSBCON'
211-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
212-
Disco.menu.board_part_num.DISCO_F407VG.build.extra_flags=-DSTM32F407xx {build.usb_flags}
213205

214206
# DISCO_F746NG board
215-
207+
# Support: USB HID, Serial1 (USART6 on PC7, PC6) and Serial2 (UART7 on PF6, PF7)
216208
Disco.menu.board_part_num.DISCO_F746NG=STM32F746G-DISCOVERY
217209
Disco.menu.board_part_num.DISCO_F746NG.node=DIS_F746NG
218210
Disco.menu.board_part_num.DISCO_F746NG.upload.maximum_size=1048576
219211
Disco.menu.board_part_num.DISCO_F746NG.upload.maximum_data_size=327680
220212
Disco.menu.board_part_num.DISCO_F746NG.build.mcu=cortex-m7
221213
Disco.menu.board_part_num.DISCO_F746NG.build.f_cpu=216000000L
222-
Disco.menu.board_part_num.DISCO_F746NG.build.usb_product="DISCO-F746NG"
223214
Disco.menu.board_part_num.DISCO_F746NG.build.board=DISCO_F746NG
224215
Disco.menu.board_part_num.DISCO_F746NG.build.series=STM32F7xx
216+
Disco.menu.board_part_num.DISCO_F746NG.build.product_line=STM32F746xx
225217
Disco.menu.board_part_num.DISCO_F746NG.build.variant=DISCO_F746NG
226218
Disco.menu.board_part_num.DISCO_F746NG.build.cmsis_lib_gcc=arm_cortexM7l_math
227-
#To enable USB add '-DUSBCON'
228-
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE'
229-
#To enable Serial1 (USART6 on PC7, PC6) add -DENABLE_SERIAL1
230-
#To enable Serial2 (UART7 on PF6, PF7) add -DENABLE_SERIAL2
231-
Disco.menu.board_part_num.DISCO_F746NG.build.extra_flags=-DSTM32F746xx {build.usb_flags}
232219

233220
# Upload menu
234221
Disco.menu.upload_method.MassStorageMethod=Mass Storage
@@ -241,3 +228,60 @@ Disco.menu.upload_method.STLinkMethod.upload.tool=stlink_upload
241228

242229

243230
################################################################################
231+
# Serialx activation
232+
Nucleo_144.menu.Other_serial.enable_Serial=None
233+
Nucleo_144.menu.Other_serial.enable_SerialAll=All
234+
Nucleo_144.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL1 -DENABLE_SERIAL2
235+
Nucleo_144.menu.Other_serial.enable_Serial1=Serial1 (if available)
236+
Nucleo_144.menu.Other_serial.enable_Serial1.build.enable_Serialx=-DENABLE_SERIAL1
237+
Nucleo_144.menu.Other_serial.enable_Serial2=Serial2 (if available)
238+
Nucleo_144.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
239+
240+
Nucleo_64.menu.Other_serial.enable_Serial=None
241+
Nucleo_64.menu.Other_serial.enable_SerialAll=All
242+
Nucleo_64.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL1 -DENABLE_SERIAL2
243+
Nucleo_64.menu.Other_serial.enable_Serial1=Serial1 (if available)
244+
Nucleo_64.menu.Other_serial.enable_Serial1.build.enable_Serialx=-DENABLE_SERIAL1
245+
Nucleo_64.menu.Other_serial.enable_Serial2=Serial2 (if available)
246+
Nucleo_64.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
247+
248+
Nucleo_32.menu.Other_serial.enable_Serial=None
249+
Nucleo_32.menu.Other_serial.enable_SerialAll=All
250+
Nucleo_32.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL1 -DENABLE_SERIAL2
251+
Nucleo_32.menu.Other_serial.enable_Serial1=Serial1 (if available)
252+
Nucleo_32.menu.Other_serial.enable_Serial1.build.enable_Serialx=-DENABLE_SERIAL1
253+
Nucleo_32.menu.Other_serial.enable_Serial2=Serial2 (if available)
254+
Nucleo_32.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
255+
256+
Disco.menu.Other_serial.enable_Serial=None
257+
Disco.menu.Other_serial.enable_SerialAll=All
258+
Disco.menu.Other_serial.enable_SerialAll.build.enable_Serialx=-DENABLE_SERIAL1 -DENABLE_SERIAL2
259+
Disco.menu.Other_serial.enable_Serial1=Serial1 (if available)
260+
Disco.menu.Other_serial.enable_Serial1.build.enable_Serialx=-DENABLE_SERIAL1
261+
Disco.menu.Other_serial.enable_Serial2=Serial2 (if available)
262+
Disco.menu.Other_serial.enable_Serial2.build.enable_Serialx=-DENABLE_SERIAL2
263+
264+
# USB connectivity
265+
Nucleo_144.menu.USB_interface.enable_USB=None
266+
Nucleo_144.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
267+
Nucleo_144.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
268+
Nucleo_144.menu.USB_interface.enable_CDC=CDC (if available)
269+
Nucleo_144.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
270+
271+
Nucleo_64.menu.USB_interface.enable_USB=None
272+
Nucleo_64.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
273+
Nucleo_64.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
274+
Nucleo_64.menu.USB_interface.enable_CDC=CDC (if available)
275+
Nucleo_64.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
276+
277+
Nucleo_32.menu.USB_interface.enable_USB=None
278+
Nucleo_32.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
279+
Nucleo_32.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
280+
Nucleo_32.menu.USB_interface.enable_CDC=CDC (if available)
281+
Nucleo_32.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS
282+
283+
Disco.menu.USB_interface.enable_USB=None
284+
Disco.menu.USB_interface.enable_HID=HID keyboard and mouse support (if available)
285+
Disco.menu.USB_interface.enable_HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
286+
Disco.menu.USB_interface.enable_CDC=CDC (if available)
287+
Disco.menu.USB_interface.enable_CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DUSE_USB_FS

Diff for: cores/arduino/stm32/usb_interface.h

+10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@
4141
#ifdef USBCON
4242

4343
/* Includes ------------------------------------------------------------------*/
44+
#if __has_include("usbd_desc.h")
4445
#include "usbd_desc.h"
46+
#else
47+
#ifdef USBD_USE_HID_COMPOSITE
48+
#error "This board does not support (yet?) USB HID! Select 'None' in the 'Tools->USB interface' menu"
49+
#elif defined(USBD_USE_CDC)
50+
#error "This board does not support (yet?) USB CDC! Select 'None' in the 'Tools->USB interface' menu"
51+
#else
52+
#error "This board does not support (yet?) USB! Select 'None' in the 'Tools->USB interface' menu"
53+
#endif
54+
#endif
4555
#include "usbd_hid_composite.h"
4656

4757
#ifdef __cplusplus

Diff for: cores/arduino/utils.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
*
3+
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
4+
* Author: Frederic Pillon for STMicroelectronics.
5+
*
6+
* License type: GPLv2
7+
*
8+
* This program is free software; you can redistribute it and/or modify it
9+
* under the terms of the GNU General Public License version 2 as published by
10+
* the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful, but
13+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14+
* or FITNESS FOR A PARTICULAR PURPOSE.
15+
* See the GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License along with
18+
* this program. If not, see
19+
* <http://www.gnu.org/licenses/>.
20+
*/
21+
/* Define to prevent recursive inclusion -------------------------------------*/
22+
#ifndef __UTILS_H
23+
#define __UTILS_H
24+
25+
// Concatenate 2 strings
26+
#define CONCAT(s1, s2) (s1 s2)
27+
// Concatenate 2 strings separated by space
28+
#define CONCATS(s1, s2) (s1" " s2)
29+
30+
#endif

Diff for: libraries/Keyboard/src/Keyboard.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
#include <Arduino.h>
2626

27-
#if !defined(USBCON)
27+
#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)
2828

29-
#warning "Using legacy HID core (non pluggable)"
29+
#error "USB HID not enabled! Select 'HID' in the 'Tools->USB interface' menu."
3030

3131
#else
3232

Diff for: libraries/Mouse/src/Mouse.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
#include <Arduino.h>
2626

27-
#if !defined(USBCON)
27+
#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)
2828

29-
#warning "Using legacy HID core (non pluggable)"
29+
#error "USB HID not enabled! Select 'HID' in the 'Tools->USB interface' menu."
3030

3131
#else
3232

Diff for: platform.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "
5555
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -l{build.cmsis_lib_gcc}
5656
# USB Flags
5757
# ---------
58-
build.usb_flags=-DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
58+
build.usb_flags=-DUSBCON -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT="{build.board}"'
5959

6060
# Default usb manufacturer will be replaced at compile time using
6161
# numeric vendor ID if available or by board's specific value.
6262
build.usb_manufacturer="Unknown"
6363

64+
#
65+
# Defaults config
66+
#
67+
build.enable_Serialx=
68+
build.enable_usb=
6469

6570
# compile patterns
6671
# ---------------------

Diff for: variants/DISCO_F407VG/usb/usbd_desc.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "usbd_core.h"
5050
#include "usbd_desc.h"
5151
#include "usbd_conf.h"
52+
#include "utils.h"
5253

5354
/* Private typedef -----------------------------------------------------------*/
5455
/* Private define ------------------------------------------------------------*/
@@ -64,14 +65,16 @@
6465
#elif !defined(USB_MANUFACTURER)
6566
// Fall through to unknown if no manufacturer name was provided in a macro
6667
#define USBD_MANUFACTURER_STRING "Unknown"
68+
#else
69+
#define USBD_MANUFACTURER_STRING USB_MANUFACTURER
6770
#endif
6871
#ifdef USBD_USE_HID_COMPOSITE
69-
#define USBD_HID_PRODUCT_HS_STRING "HID in HS Mode"
70-
#define USBD_HID_PRODUCT_FS_STRING "HID in FS Mode"
71-
#define USBD_HID_CONFIGURATION_HS_STRING "HID Config"
72-
#define USBD_HID_INTERFACE_HS_STRING "HID Interface"
73-
#define USBD_HID_CONFIGURATION_FS_STRING "HID Config"
74-
#define USBD_HID_INTERFACE_FS_STRING "HID Interface"
72+
#define USBD_HID_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "HID in HS Mode")
73+
#define USBD_HID_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "HID in FS Mode")
74+
#define USBD_HID_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "HID Config")
75+
#define USBD_HID_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "HID Interface")
76+
#define USBD_HID_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "HID Config")
77+
#define USBD_HID_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")
7578

7679
/* Private macro -------------------------------------------------------------*/
7780
/* Private function prototypes -----------------------------------------------*/

0 commit comments

Comments
 (0)