Skip to content

Commit ada7c5c

Browse files
authored
Merge pull request #57 from fpistm/menu_ext
Add menu to enable Serial instances and USB interface
2 parents 88915b7 + b409ad5 commit ada7c5c

File tree

8 files changed

+267
-173
lines changed

8 files changed

+267
-173
lines changed

Diff for: boards.txt

+198-156
Large diffs are not rendered by default.

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 -----------------------------------------------*/

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#include "usbd_core.h"
5050
#include "usbd_desc.h"
5151
#include "usbd_conf.h"
52+
#include "utils.h"
53+
5254
/* Private typedef -----------------------------------------------------------*/
5355
/* Private define ------------------------------------------------------------*/
5456

@@ -63,14 +65,16 @@
6365
#elif !defined(USB_MANUFACTURER)
6466
// Fall through to unknown if no manufacturer name was provided in a macro
6567
#define USBD_MANUFACTURER_STRING "Unknown"
68+
#else
69+
#define USBD_MANUFACTURER_STRING USB_MANUFACTURER
6670
#endif
6771
#ifdef USBD_USE_HID_COMPOSITE
68-
#define USBD_HID_PRODUCT_HS_STRING "HID in HS Mode"
69-
#define USBD_HID_PRODUCT_FS_STRING "HID in FS Mode"
70-
#define USBD_HID_CONFIGURATION_HS_STRING "HID Config"
71-
#define USBD_HID_INTERFACE_HS_STRING "HID Interface"
72-
#define USBD_HID_CONFIGURATION_FS_STRING "HID Config"
73-
#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")
7478

7579
/* Private macro -------------------------------------------------------------*/
7680
/* Private function prototypes -----------------------------------------------*/

0 commit comments

Comments
 (0)