Skip to content

Commit 18542b1

Browse files
author
harbaum
committed
More WebUSB sanitiy checks
1 parent 77522bd commit 18542b1

3 files changed

Lines changed: 33 additions & 23 deletions

File tree

ftduino/libraries/Ftduino/Ftduino.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010
#include "Arduino.h"
1111

1212
#ifdef IN_FTDUINO_LIB
13-
#if !defined(OUTPUT_DRIVER_MC33879A) && !defined(OUTPUT_DRIVER_AUTO)
14-
#error "Only the MC33879A or AUTO output drivers are currently supported!"
15-
#endif
13+
#if !defined(OUTPUT_DRIVER_MC33879A) && !defined(OUTPUT_DRIVER_AUTO)
14+
#error "Only the MC33879A or AUTO output drivers are currently supported!"
15+
#endif
16+
#else
17+
// make sure WebUSB is being used with correct settings
18+
#if USB_VERSION == 0x210 && !defined(WebUSB_h)
19+
#error "Please include WebUSB.h if WebUSB is being used!"
20+
#endif
1621
#endif
1722

1823
#define STRINGIFY(name) #name

ftduino/libraries/FtduinoSimple/FtduinoSimple.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@
1010
#include "Arduino.h"
1111

1212
#ifndef IN_FTDUINO_SIMPLE_LIB
13-
#if defined(OUTPUT_DRIVER_MC33879A)
14-
#warning "Building for MC33879A boards only"
15-
#ifndef MC33879A_ONLY // user has to define this
16-
#error "Please select 'Automatic' output driver or define MC33879A_ONLY when using MC33879A output driver."
17-
#endif
18-
#elif defined(OUTPUT_DRIVER_TLE94108EL)
19-
#warning "Building for TLE94108EL boards only"
20-
#ifndef TLE94108EL_ONLY // user has to define this
21-
#error "Please select 'Automatic' output driver or define TLE94108EL_ONLY when using TLE94108EL output driver."
22-
#endif
23-
#elif defined(OUTPUT_DRIVER_AUTO)
24-
// #warning "Building for output auto detection"
13+
#if defined(OUTPUT_DRIVER_MC33879A)
14+
#warning "Building for MC33879A boards only"
15+
#ifndef MC33879A_ONLY // user has to define this
16+
#error "Please select 'Automatic' output driver or define MC33879A_ONLY when using MC33879A output driver."
17+
#endif
18+
#elif defined(OUTPUT_DRIVER_TLE94108EL)
19+
#warning "Building for TLE94108EL boards only"
20+
#ifndef TLE94108EL_ONLY // user has to define this
21+
#error "Please select 'Automatic' output driver or define TLE94108EL_ONLY when using TLE94108EL output driver."
22+
#endif
23+
#elif defined(OUTPUT_DRIVER_AUTO)
24+
// #warning "Building for output auto detection"
25+
#else
26+
#warning "Error, no output driver configured"
27+
#endif
2528
#else
26-
#warning "Error, no output driver configured"
27-
#endif
29+
// make sure WebUSB is being used with correct settings
30+
#if USB_VERSION == 0x210 && !defined(WebUSB_h)
31+
#error "Please include WebUSB.h if WebUSB is being used!"
32+
#endif
2833
#endif
2934

3035
class Ftduino {

ftduino/libraries/WebUSB/examples/IoServer/JsonParser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
// https://www.json.org/json-de.html
66

7+
#if USB_VERSION == 0x210
8+
#include <WebUSB.h>
9+
extern WebUSB WebUSBSerial;
10+
#define Serial WebUSBSerial
11+
#endif
12+
713
#ifdef ARDUINO
814
#include <Ftduino.h>
915
#else
@@ -14,12 +20,6 @@
1420
#include <string.h>
1521
#include "JsonParser.h"
1622

17-
#if USB_VERSION == 0x210
18-
#include <WebUSB.h>
19-
extern WebUSB WebUSBSerial;
20-
#define Serial WebUSBSerial
21-
#endif
22-
2323
// generic JSON error codes
2424
#define ERR_UNEXP_STATE 1 // unexpected state
2525
#define ERR_EXP_OBJ 2 // expecting object

0 commit comments

Comments
 (0)