Skip to content
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

ESP32-S2 support using the built-in USB peripheral #1

Open
wants to merge 1 commit into
base: esp32
Choose a base branch
from
Open
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
17 changes: 16 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ build_flags =
[esp32v2]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.14
framework = arduino
build_flags =
-D AR488_CUSTOM
Expand Down Expand Up @@ -158,3 +158,18 @@ build_flags =
-D DIO5=27 -D DIO6=14 -D DIO7=12 -D DIO8=13
-D REN=22 -D IFC=21 -D NDAC=19 -D NRFD=23
-D DAV=18 -D EOI=17 -D ATN=16 -D SRQ=4

[env:ar488-esp32s2]
platform = espressif32
framework = arduino
board = esp32-s2-saola-1
upload_protocol = esptool
build_flags =
${esp32v2.build_flags}
-D BOARD_HAS_PSRAM
-D AR_ESP32S2_USB_CDC
-D AR488_CUSTOM
-D DIO1=1 -D DIO2=3 -D DIO3=5 -D DIO4=7
-D DIO5=2 -D DIO6=4 -D DIO7=6 -D DIO8=8
-D REN=10 -D IFC=14 -D NDAC=13 -D NRFD=12
-D DAV=11 -D EOI=9 -D ATN=16 -D SRQ=15
6 changes: 3 additions & 3 deletions src/AR488_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
* section below
*/
/* Serial ports */
#define AR_HW_SERIAL
// #define AR_HW_SERIAL
#ifndef AR_SERIAL_PORT
#define AR_SERIAL_PORT Serial
// #define AR_SERIAL_PORT Serial
//#define AR_SERIAL_PORT Serial1
//#define AR_SERIAL_PORT Serial2
//#define AR_SERIAL_PORT Serial3
//#define AR_CDC_SERIAL
//#define AR_SW_SERIAL
#define AR_BT_SERIAL_PORT Serial
// #define AR_BT_SERIAL_PORT Serial
#endif

/*** UNO and NANO boards ***/
Expand Down
13 changes: 13 additions & 0 deletions src/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@

#endif

#ifdef AR_ESP32S2_USB_CDC
#include "USB.h"
USBCDC UsbCdcSerial;
#endif

/********** BT SERIAL PORT DECLARATIONS **********/
/* on ESP32, this comes as an extra serial port */
/* on Arduino, this is done using an HC05 like */
Expand All @@ -23,6 +28,12 @@ Stream *arSerial = NULL;

Stream* getSerialStream() {
if (arSerial == NULL) {
#if defined(AR_ESP32S2_USB_CDC)
arSerial =(Stream*) &(UsbCdcSerial);
UsbCdcSerial.begin();
USB.begin();

#else
#if defined(AR_CDC_SERIAL)
Serial_ *serial = &(AR_SERIAL_PORT);
#elif defined(AR_HW_SERIAL)
Expand All @@ -34,6 +45,8 @@ Stream* getSerialStream() {
#endif
serial->begin(AR_SERIAL_BAUD);
arSerial = (Stream*) serial;
#endif

}
return arSerial;
}
Expand Down