Skip to content

Commit 08f668d

Browse files
authored
Merge branch 'master' into uart_read_faster
2 parents e072302 + 9006751 commit 08f668d

File tree

4 files changed

+367
-0
lines changed

4 files changed

+367
-0
lines changed

boards.txt

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19452,3 +19452,178 @@ cytron_maker_feather_aiot_s3.menu.EraseFlash.all=Enabled
1945219452
cytron_maker_feather_aiot_s3.menu.EraseFlash.all.upload.erase_cmd=-e
1945319453

1945419454
##############################################################
19455+
# RedPill(+) ESP32-S3
19456+
19457+
redpill_esp32s3.name=RedPill(+) ESP32-S3
19458+
redpill_esp32s3.vid.0=0x303a
19459+
redpill_esp32s3.pid.0=0x1001
19460+
19461+
redpill_esp32s3.bootloader.tool=esptool_py
19462+
redpill_esp32s3.bootloader.tool.default=esptool_py
19463+
19464+
redpill_esp32s3.upload.tool=esptool_py
19465+
redpill_esp32s3.upload.tool.default=esptool_py
19466+
redpill_esp32s3.upload.tool.network=esp_ota
19467+
19468+
redpill_esp32s3.upload.maximum_size=1310720
19469+
redpill_esp32s3.upload.maximum_data_size=327680
19470+
redpill_esp32s3.upload.flags=
19471+
redpill_esp32s3.upload.extra_flags=
19472+
redpill_esp32s3.upload.use_1200bps_touch=true
19473+
redpill_esp32s3.upload.wait_for_upload_port=true
19474+
19475+
redpill_esp32s3.serial.disableDTR=false
19476+
redpill_esp32s3.serial.disableRTS=false
19477+
19478+
redpill_esp32s3.build.tarch=xtensa
19479+
redpill_esp32s3.build.bootloader_addr=0x0
19480+
redpill_esp32s3.build.target=esp32s3
19481+
redpill_esp32s3.build.mcu=esp32s3
19482+
redpill_esp32s3.build.core=esp32
19483+
redpill_esp32s3.build.variant=redpill_esp32s3
19484+
redpill_esp32s3.build.board=REDPILL_ESP32S3
19485+
19486+
redpill_esp32s3.build.usb_mode=0
19487+
redpill_esp32s3.build.cdc_on_boot=1
19488+
redpill_esp32s3.build.msc_on_boot=0
19489+
redpill_esp32s3.build.dfu_on_boot=0
19490+
redpill_esp32s3.build.f_cpu=240000000L
19491+
redpill_esp32s3.build.flash_size=8MB
19492+
redpill_esp32s3.build.flash_freq=80m
19493+
redpill_esp32s3.build.flash_mode=dio
19494+
redpill_esp32s3.build.boot=qio
19495+
redpill_esp32s3.build.partitions=default
19496+
redpill_esp32s3.build.defines=
19497+
redpill_esp32s3.build.loop_core=
19498+
redpill_esp32s3.build.event_core=
19499+
redpill_esp32s3.build.flash_type=qio
19500+
redpill_esp32s3.build.psram_type=qspi
19501+
redpill_esp32s3.build.memory_type={build.flash_type}_{build.psram_type}
19502+
19503+
redpill_esp32s3.menu.LoopCore.1=Core 1
19504+
redpill_esp32s3.menu.LoopCore.1.build.loop_core=-DARDUINO_RUNNING_CORE=1
19505+
redpill_esp32s3.menu.LoopCore.0=Core 0
19506+
redpill_esp32s3.menu.LoopCore.0.build.loop_core=-DARDUINO_RUNNING_CORE=0
19507+
19508+
redpill_esp32s3.menu.EventsCore.1=Core 1
19509+
redpill_esp32s3.menu.EventsCore.1.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=1
19510+
redpill_esp32s3.menu.EventsCore.0=Core 0
19511+
redpill_esp32s3.menu.EventsCore.0.build.event_core=-DARDUINO_EVENT_RUNNING_CORE=0
19512+
19513+
redpill_esp32s3.menu.USBMode.default=USB-OTG (TinyUSB)
19514+
redpill_esp32s3.menu.USBMode.default.build.usb_mode=0
19515+
redpill_esp32s3.menu.USBMode.hwcdc=Hardware CDC and JTAG
19516+
redpill_esp32s3.menu.USBMode.hwcdc.build.usb_mode=1
19517+
19518+
redpill_esp32s3.menu.CDCOnBoot.cdc=Enabled
19519+
redpill_esp32s3.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
19520+
redpill_esp32s3.menu.CDCOnBoot.default=Disabled
19521+
redpill_esp32s3.menu.CDCOnBoot.default.build.cdc_on_boot=0
19522+
19523+
redpill_esp32s3.menu.MSCOnBoot.default=Disabled
19524+
redpill_esp32s3.menu.MSCOnBoot.default.build.msc_on_boot=0
19525+
redpill_esp32s3.menu.MSCOnBoot.msc=Enabled (Requires USB-OTG Mode)
19526+
redpill_esp32s3.menu.MSCOnBoot.msc.build.msc_on_boot=1
19527+
19528+
redpill_esp32s3.menu.DFUOnBoot.default=Disabled
19529+
redpill_esp32s3.menu.DFUOnBoot.default.build.dfu_on_boot=0
19530+
redpill_esp32s3.menu.DFUOnBoot.dfu=Enabled (Requires USB-OTG Mode)
19531+
redpill_esp32s3.menu.DFUOnBoot.dfu.build.dfu_on_boot=1
19532+
19533+
redpill_esp32s3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
19534+
redpill_esp32s3.menu.UploadMode.cdc.upload.use_1200bps_touch=true
19535+
redpill_esp32s3.menu.UploadMode.cdc.upload.wait_for_upload_port=true
19536+
redpill_esp32s3.menu.UploadMode.default=UART0 / Hardware CDC
19537+
redpill_esp32s3.menu.UploadMode.default.upload.use_1200bps_touch=false
19538+
redpill_esp32s3.menu.UploadMode.default.upload.wait_for_upload_port=false
19539+
19540+
redpill_esp32s3.menu.PSRAM.enabled=QSPI PSRAM
19541+
redpill_esp32s3.menu.PSRAM.enabled.build.defines=-DBOARD_HAS_PSRAM
19542+
redpill_esp32s3.menu.PSRAM.enabled.build.psram_type=qspi
19543+
redpill_esp32s3.menu.PSRAM.disabled=Disabled
19544+
redpill_esp32s3.menu.PSRAM.disabled.build.defines=
19545+
redpill_esp32s3.menu.PSRAM.disabled.build.psram_type=qspi
19546+
redpill_esp32s3.menu.PSRAM.opi=OPI PSRAM
19547+
redpill_esp32s3.menu.PSRAM.opi.build.defines=-DBOARD_HAS_PSRAM
19548+
redpill_esp32s3.menu.PSRAM.opi.build.psram_type=opi
19549+
19550+
redpill_esp32s3.menu.PartitionScheme.tinyuf2=TinyUF2 8MB (2MB APP/3.7MB FFAT)
19551+
redpill_esp32s3.menu.PartitionScheme.tinyuf2.build.custom_bootloader=bootloader-tinyuf2
19552+
redpill_esp32s3.menu.PartitionScheme.tinyuf2.build.custom_partitions=partitions-8MB-tinyuf2
19553+
redpill_esp32s3.menu.PartitionScheme.tinyuf2.upload.maximum_size=2097152
19554+
redpill_esp32s3.menu.PartitionScheme.tinyuf2.upload.extra_flags=0x410000 "{runtime.platform.path}/variants/{build.variant}/tinyuf2.bin"
19555+
redpill_esp32s3.menu.PartitionScheme.default_8MB=Default (3MB APP/1.5MB SPIFFS)
19556+
redpill_esp32s3.menu.PartitionScheme.default_8MB.build.partitions=default_8MB
19557+
redpill_esp32s3.menu.PartitionScheme.default_8MB.upload.maximum_size=3342336
19558+
19559+
redpill_esp32s3.menu.CPUFreq.240=240MHz (WiFi)
19560+
redpill_esp32s3.menu.CPUFreq.240.build.f_cpu=240000000L
19561+
redpill_esp32s3.menu.CPUFreq.160=160MHz (WiFi)
19562+
redpill_esp32s3.menu.CPUFreq.160.build.f_cpu=160000000L
19563+
redpill_esp32s3.menu.CPUFreq.80=80MHz (WiFi)
19564+
redpill_esp32s3.menu.CPUFreq.80.build.f_cpu=80000000L
19565+
redpill_esp32s3.menu.CPUFreq.40=40MHz
19566+
redpill_esp32s3.menu.CPUFreq.40.build.f_cpu=40000000L
19567+
redpill_esp32s3.menu.CPUFreq.20=20MHz
19568+
redpill_esp32s3.menu.CPUFreq.20.build.f_cpu=20000000L
19569+
redpill_esp32s3.menu.CPUFreq.10=10MHz
19570+
redpill_esp32s3.menu.CPUFreq.10.build.f_cpu=10000000L
19571+
19572+
redpill_esp32s3.menu.FlashMode.qio=QIO 80MHz
19573+
redpill_esp32s3.menu.FlashMode.qio.build.flash_mode=dio
19574+
redpill_esp32s3.menu.FlashMode.qio.build.boot=qio
19575+
redpill_esp32s3.menu.FlashMode.qio.build.boot_freq=80m
19576+
redpill_esp32s3.menu.FlashMode.qio.build.flash_freq=80m
19577+
redpill_esp32s3.menu.FlashMode.qio120=QIO 120MHz
19578+
redpill_esp32s3.menu.FlashMode.qio120.build.flash_mode=dio
19579+
redpill_esp32s3.menu.FlashMode.qio120.build.boot=qio
19580+
redpill_esp32s3.menu.FlashMode.qio120.build.boot_freq=120m
19581+
redpill_esp32s3.menu.FlashMode.qio120.build.flash_freq=80m
19582+
redpill_esp32s3.menu.FlashMode.dio=DIO 80MHz
19583+
redpill_esp32s3.menu.FlashMode.dio.build.flash_mode=dio
19584+
redpill_esp32s3.menu.FlashMode.dio.build.boot=dio
19585+
redpill_esp32s3.menu.FlashMode.dio.build.boot_freq=80m
19586+
redpill_esp32s3.menu.FlashMode.dio.build.flash_freq=80m
19587+
redpill_esp32s3.menu.FlashMode.opi=OPI 80MHz
19588+
redpill_esp32s3.menu.FlashMode.opi.build.flash_mode=dout
19589+
redpill_esp32s3.menu.FlashMode.opi.build.boot=opi
19590+
redpill_esp32s3.menu.FlashMode.opi.build.boot_freq=80m
19591+
redpill_esp32s3.menu.FlashMode.opi.build.flash_freq=80m
19592+
19593+
redpill_esp32s3.menu.FlashSize.8M=8MB (64Mb)
19594+
redpill_esp32s3.menu.FlashSize.8M.build.flash_size=8MB
19595+
19596+
redpill_esp32s3.menu.UploadSpeed.921600=921600
19597+
redpill_esp32s3.menu.UploadSpeed.921600.upload.speed=921600
19598+
redpill_esp32s3.menu.UploadSpeed.115200=115200
19599+
redpill_esp32s3.menu.UploadSpeed.115200.upload.speed=115200
19600+
redpill_esp32s3.menu.UploadSpeed.256000.windows=256000
19601+
redpill_esp32s3.menu.UploadSpeed.256000.upload.speed=256000
19602+
redpill_esp32s3.menu.UploadSpeed.230400.windows.upload.speed=256000
19603+
redpill_esp32s3.menu.UploadSpeed.230400=230400
19604+
redpill_esp32s3.menu.UploadSpeed.230400.upload.speed=230400
19605+
redpill_esp32s3.menu.UploadSpeed.460800.linux=460800
19606+
redpill_esp32s3.menu.UploadSpeed.460800.macosx=460800
19607+
redpill_esp32s3.menu.UploadSpeed.460800.upload.speed=460800
19608+
redpill_esp32s3.menu.UploadSpeed.512000.windows=512000
19609+
redpill_esp32s3.menu.UploadSpeed.512000.upload.speed=512000
19610+
19611+
redpill_esp32s3.menu.DebugLevel.none=None
19612+
redpill_esp32s3.menu.DebugLevel.none.build.code_debug=0
19613+
redpill_esp32s3.menu.DebugLevel.error=Error
19614+
redpill_esp32s3.menu.DebugLevel.error.build.code_debug=1
19615+
redpill_esp32s3.menu.DebugLevel.warn=Warn
19616+
redpill_esp32s3.menu.DebugLevel.warn.build.code_debug=2
19617+
redpill_esp32s3.menu.DebugLevel.info=Info
19618+
redpill_esp32s3.menu.DebugLevel.info.build.code_debug=3
19619+
redpill_esp32s3.menu.DebugLevel.debug=Debug
19620+
redpill_esp32s3.menu.DebugLevel.debug.build.code_debug=4
19621+
redpill_esp32s3.menu.DebugLevel.verbose=Verbose
19622+
redpill_esp32s3.menu.DebugLevel.verbose.build.code_debug=5
19623+
19624+
redpill_esp32s3.menu.EraseFlash.none=Disabled
19625+
redpill_esp32s3.menu.EraseFlash.none.upload.erase_cmd=
19626+
redpill_esp32s3.menu.EraseFlash.all=Enabled
19627+
redpill_esp32s3.menu.EraseFlash.all.upload.erase_cmd=-e
19628+
19629+
##############################################################
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/* ESP32 TWAI receive example.
2+
Receive messages and sends them over serial.
3+
4+
Connect a CAN bus transceiver to the RX/TX pins.
5+
For example: SN65HVD230
6+
7+
TWAI_MODE_LISTEN_ONLY is used so that the TWAI controller will not influence the bus.
8+
9+
The API gives other possible speeds and alerts:
10+
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/twai.html
11+
12+
Example output from a can bus message:
13+
-> Message received
14+
-> Message is in Standard Format
15+
-> ID: 604
16+
-> Byte: 0 = 00, 1 = 0f, 2 = 13, 3 = 02, 4 = 00, 5 = 00, 6 = 08, 7 = 00
17+
18+
Example output with alerts:
19+
-> Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus.
20+
-> Bus error count: 171
21+
-> Alert: The RX queue is full causing a received frame to be lost.
22+
-> RX buffered: 4 RX missed: 46 RX overrun 0
23+
24+
created 05-11-2022 by Stephan Martin (designer2k2)
25+
*/
26+
27+
#include "driver/twai.h"
28+
29+
// Pins used to connect to CAN bus transceiver:
30+
#define RX_PIN 21
31+
#define TX_PIN 22
32+
33+
// Intervall:
34+
#define POLLING_RATE_MS 1000
35+
36+
static bool driver_installed = false;
37+
38+
void setup() {
39+
// Start Serial:
40+
Serial.begin(115200);
41+
42+
// Initialize configuration structures using macro initializers
43+
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT((gpio_num_t)TX_PIN, (gpio_num_t)RX_PIN, TWAI_MODE_LISTEN_ONLY);
44+
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_500KBITS(); //Look in the api-reference for other speed sets.
45+
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
46+
47+
// Install TWAI driver
48+
if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK) {
49+
Serial.println("Driver installed");
50+
} else {
51+
Serial.println("Failed to install driver");
52+
return;
53+
}
54+
55+
// Start TWAI driver
56+
if (twai_start() == ESP_OK) {
57+
Serial.println("Driver started");
58+
} else {
59+
Serial.println("Failed to start driver");
60+
return;
61+
}
62+
63+
// Reconfigure alerts to detect frame receive, Bus-Off error and RX queue full states
64+
uint32_t alerts_to_enable = TWAI_ALERT_RX_DATA | TWAI_ALERT_ERR_PASS | TWAI_ALERT_BUS_ERROR | TWAI_ALERT_RX_QUEUE_FULL;
65+
if (twai_reconfigure_alerts(alerts_to_enable, NULL) == ESP_OK) {
66+
Serial.println("CAN Alerts reconfigured");
67+
} else {
68+
Serial.println("Failed to reconfigure alerts");
69+
return;
70+
}
71+
72+
// TWAI driver is now successfully installed and started
73+
driver_installed = true;
74+
}
75+
76+
static void handle_rx_message(twai_message_t& message) {
77+
// Process received message
78+
if (message.extd) {
79+
Serial.println("Message is in Extended Format");
80+
} else {
81+
Serial.println("Message is in Standard Format");
82+
}
83+
Serial.printf("ID: %x\nByte:", message.identifier);
84+
if (!(message.rtr)) {
85+
for (int i = 0; i < message.data_length_code; i++) {
86+
Serial.printf(" %d = %02x,", i, message.data[i]);
87+
}
88+
Serial.println("");
89+
}
90+
}
91+
92+
void loop() {
93+
if (!driver_installed) {
94+
// Driver not installed
95+
delay(1000);
96+
return;
97+
}
98+
// Check if alert happened
99+
uint32_t alerts_triggered;
100+
twai_read_alerts(&alerts_triggered, pdMS_TO_TICKS(POLLING_RATE_MS));
101+
twai_status_info_t twaistatus;
102+
twai_get_status_info(&twaistatus);
103+
104+
// Handle alerts
105+
if (alerts_triggered & TWAI_ALERT_ERR_PASS) {
106+
Serial.println("Alert: TWAI controller has become error passive.");
107+
}
108+
if (alerts_triggered & TWAI_ALERT_BUS_ERROR) {
109+
Serial.println("Alert: A (Bit, Stuff, CRC, Form, ACK) error has occurred on the bus.");
110+
Serial.printf("Bus error count: %d\n", twaistatus.bus_error_count);
111+
}
112+
if (alerts_triggered & TWAI_ALERT_RX_QUEUE_FULL) {
113+
Serial.println("Alert: The RX queue is full causing a received frame to be lost.");
114+
Serial.printf("RX buffered: %d\t", twaistatus.msgs_to_rx);
115+
Serial.printf("RX missed: %d\t", twaistatus.rx_missed_count);
116+
Serial.printf("RX overrun %d\n", twaistatus.rx_overrun_count);
117+
}
118+
119+
// Check if message is received
120+
if (alerts_triggered & TWAI_ALERT_RX_DATA) {
121+
// One or more messages received. Handle all.
122+
twai_message_t message;
123+
while (twai_receive(&message, 0) == ESP_OK) {
124+
handle_rx_message(message);
125+
}
126+
}
127+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#ifndef Pins_Arduino_h
2+
#define Pins_Arduino_h
3+
4+
#include <stdint.h>
5+
6+
#define USB_VID 0x303A
7+
#define USB_PID 0x1001
8+
9+
#define EXTERNAL_NUM_INTERRUPTS 46
10+
#define NUM_DIGITAL_PINS 48
11+
#define NUM_ANALOG_INPUTS 20
12+
13+
#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1)
14+
#define digitalPinToInterrupt(p) (((p)<48)?(p):-1)
15+
#define digitalPinHasPWM(p) (p < 46)
16+
17+
static const uint8_t LED_BUILTIN = 3;
18+
#define BUILTIN_LED LED_BUILTIN // backward compatibility
19+
#define LED_BUILTIN LED_BUILTIN
20+
#define RGB_BUILTIN LED_BUILTIN
21+
#define RGB_BRIGHTNESS 64
22+
23+
static const uint8_t TX = 43;
24+
static const uint8_t RX = 44;
25+
26+
static const uint8_t SDA = 11;
27+
static const uint8_t SCL = 10;
28+
29+
static const uint8_t A0 = 1;
30+
static const uint8_t A1 = 2;
31+
static const uint8_t A2 = 3;
32+
static const uint8_t A3 = 4;
33+
static const uint8_t A4 = 5;
34+
static const uint8_t A5 = 6;
35+
static const uint8_t A6 = 7;
36+
static const uint8_t A7 = 8;
37+
static const uint8_t A8 = 9;
38+
static const uint8_t A9 = 10;
39+
static const uint8_t A10 = 11;
40+
static const uint8_t A11 = 12;
41+
static const uint8_t A12 = 13;
42+
static const uint8_t A13 = 14;
43+
static const uint8_t A14 = 15;
44+
static const uint8_t A15 = 16;
45+
static const uint8_t A16 = 17;
46+
static const uint8_t A17 = 18;
47+
static const uint8_t A18 = 19;
48+
static const uint8_t A19 = 20;
49+
50+
static const uint8_t T1 = 1;
51+
static const uint8_t T2 = 2;
52+
static const uint8_t T3 = 3;
53+
static const uint8_t T4 = 4;
54+
static const uint8_t T5 = 5;
55+
static const uint8_t T6 = 6;
56+
static const uint8_t T7 = 7;
57+
static const uint8_t T8 = 8;
58+
static const uint8_t T9 = 9;
59+
static const uint8_t T10 = 10;
60+
static const uint8_t T11 = 11;
61+
static const uint8_t T12 = 12;
62+
static const uint8_t T13 = 13;
63+
static const uint8_t T14 = 14;
64+
65+
#endif /* Pins_Arduino_h */

variants/redpill_esp32s3/tinyuf2.bin

148 KB
Binary file not shown.

0 commit comments

Comments
 (0)