Skip to content

Add menu to enable Serial instances and USB interface #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
354 changes: 198 additions & 156 deletions boards.txt

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions cores/arduino/stm32/usb_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@
#ifdef USBCON

/* Includes ------------------------------------------------------------------*/
#if __has_include("usbd_desc.h")
#include "usbd_desc.h"
#else
#ifdef USBD_USE_HID_COMPOSITE
#error "This board does not support (yet?) USB HID! Select 'None' in the 'Tools->USB interface' menu"
#elif defined(USBD_USE_CDC)
#error "This board does not support (yet?) USB CDC! Select 'None' in the 'Tools->USB interface' menu"
#else
#error "This board does not support (yet?) USB! Select 'None' in the 'Tools->USB interface' menu"
#endif
#endif
#include "usbd_hid_composite.h"

#ifdef __cplusplus
Expand Down
30 changes: 30 additions & 0 deletions cores/arduino/utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
*
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
* Author: Frederic Pillon for STMicroelectronics.
*
* License type: GPLv2
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __UTILS_H
#define __UTILS_H

// Concatenate 2 strings
#define CONCAT(s1, s2) (s1 s2)
// Concatenate 2 strings separated by space
#define CONCATS(s1, s2) (s1" " s2)

#endif
4 changes: 2 additions & 2 deletions libraries/Keyboard/src/Keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include <Arduino.h>

#if !defined(USBCON)
#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)

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

#else

Expand Down
4 changes: 2 additions & 2 deletions libraries/Mouse/src/Mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include <Arduino.h>

#if !defined(USBCON)
#if !defined(USBCON) || !defined(USBD_USE_HID_COMPOSITE)

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

#else

Expand Down
7 changes: 6 additions & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ compiler.arm.cmsis.c.flags="-I{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Include/" "
compiler.arm.cmsis.ldflags="-L{runtime.tools.CMSIS-4.5.0.path}/CMSIS/Lib/GCC/" -l{build.cmsis_lib_gcc}
# USB Flags
# ---------
build.usb_flags=-DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT={build.usb_product}'
build.usb_flags=-DUSBCON -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} '-DUSB_MANUFACTURER={build.usb_manufacturer}' '-DUSB_PRODUCT="{build.board}"'

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

#
# Defaults config
#
build.enable_Serialx=
build.enable_usb=

# compile patterns
# ---------------------
Expand Down
15 changes: 9 additions & 6 deletions variants/DISCO_F407VG/usb/usbd_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
#include "utils.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
Expand All @@ -64,14 +65,16 @@
#elif !defined(USB_MANUFACTURER)
// Fall through to unknown if no manufacturer name was provided in a macro
#define USBD_MANUFACTURER_STRING "Unknown"
#else
#define USBD_MANUFACTURER_STRING USB_MANUFACTURER
#endif
#ifdef USBD_USE_HID_COMPOSITE
#define USBD_HID_PRODUCT_HS_STRING "HID in HS Mode"
#define USBD_HID_PRODUCT_FS_STRING "HID in FS Mode"
#define USBD_HID_CONFIGURATION_HS_STRING "HID Config"
#define USBD_HID_INTERFACE_HS_STRING "HID Interface"
#define USBD_HID_CONFIGURATION_FS_STRING "HID Config"
#define USBD_HID_INTERFACE_FS_STRING "HID Interface"
#define USBD_HID_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "HID in HS Mode")
#define USBD_HID_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "HID in FS Mode")
#define USBD_HID_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "HID Config")
#define USBD_HID_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "HID Interface")
#define USBD_HID_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "HID Config")
#define USBD_HID_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")

/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
Expand Down
16 changes: 10 additions & 6 deletions variants/NUCLEO_F429ZI/usb/usbd_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_conf.h"
#include "utils.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/

Expand All @@ -63,14 +65,16 @@
#elif !defined(USB_MANUFACTURER)
// Fall through to unknown if no manufacturer name was provided in a macro
#define USBD_MANUFACTURER_STRING "Unknown"
#else
#define USBD_MANUFACTURER_STRING USB_MANUFACTURER
#endif
#ifdef USBD_USE_HID_COMPOSITE
#define USBD_HID_PRODUCT_HS_STRING "HID in HS Mode"
#define USBD_HID_PRODUCT_FS_STRING "HID in FS Mode"
#define USBD_HID_CONFIGURATION_HS_STRING "HID Config"
#define USBD_HID_INTERFACE_HS_STRING "HID Interface"
#define USBD_HID_CONFIGURATION_FS_STRING "HID Config"
#define USBD_HID_INTERFACE_FS_STRING "HID Interface"
#define USBD_HID_PRODUCT_HS_STRING CONCATS(USB_PRODUCT, "HID in HS Mode")
#define USBD_HID_PRODUCT_FS_STRING CONCATS(USB_PRODUCT, "HID in FS Mode")
#define USBD_HID_CONFIGURATION_HS_STRING CONCATS(USB_PRODUCT, "HID Config")
#define USBD_HID_INTERFACE_HS_STRING CONCATS(USB_PRODUCT, "HID Interface")
#define USBD_HID_CONFIGURATION_FS_STRING CONCATS(USB_PRODUCT, "HID Config")
#define USBD_HID_INTERFACE_FS_STRING CONCATS(USB_PRODUCT, "HID Interface")

/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
Expand Down