Skip to content

Commit

Permalink
Fine-tune ESP32 serial buffer and ACK sizes for better reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Feb 26, 2024
1 parent 211422d commit 88af1e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions benchmarks/i2c_ssd1306_refresh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
# Arduino Nano Every : 9.2 fps (USB through ATSAMD11 @ 115200, 128-byte I2C limit, no I2C level shifter)
# Arduino Nano Every : 13.0 fps (USB through ATSAMD11 @ 230400, 128-byte I2C limit, no I2C level shifter)
#
# February 25 2024 | i7 8700k CPU | CRuby 3.2.1 | 100 frames | 1 Mhz I2C frequency | Average of 3 runs
#
# ESP32-S3 : 51.8 fps (native USB) - Changed from 64 to 128 serial ACK interval
# ESP32-C3 : 51.7 fps (native USB) - Changed from 64 to 128 serial ACK interval
#
require 'bundler/setup'
require 'denko'

Expand Down
17 changes: 16 additions & 1 deletion src/lib/DenkoDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,24 @@
// Best performance acknowledging at 64 bytes, or 32 if buffer is only 64.
//
// These are 256/64 regardless of whether native USB CDC or UART bridge.
#if defined(ARDUINO_ARCH_RP2040) || defined(ESP32) || defined(ESP8266) || defined(__SAM3X8E__)
#if defined(ARDUINO_ARCH_RP2040) || defined(ESP8266) || defined(__SAM3X8E__)
#define DENKO_SERIAL_BUFFER_SIZE 256
#define DENKO_RX_ACK_INTERVAL 64
// ESP32 defaults to 256 buffer. Stay one under.
#elif defined(ESP32)
#define DENKO_SERIAL_BUFFER_SIZE 255
#ifdef ARDUINO_USB_CDC_ON_BOOT
// S2 unreliable with acknowledgement before buffer is full.
#ifdef CONFIG_IDF_TARGET_ESP32S2
#define DENKO_RX_ACK_INTERVAL 255
// S3 and C3 are fine acknowledging at half buffer filled.
#else
#define DENKO_RX_ACK_INTERVAL 128
#endif
// Default to 64 if using a UART bridge.
#else
#define DENKO_RX_ACK_INTERVAL 64
#endif
// RA4M1 has a 512 Serial buffer.
#elif defined(_RENESAS_RA_)
#define DENKO_SERIAL_BUFFER_SIZE 512
Expand Down

0 comments on commit 88af1e6

Please sign in to comment.