Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Distinguishing S2 and C3 from legacy ESP32 across core versions #6780

Unanswered
Miq1 asked this question in Q&A
Discussion options

We have a library requiring the UART conf1.rxfifo_full_thrhd being set to 1. To not leave that to the users, we do it like

...
 uart_dev_t *uart = nullptr;
 uint8_t uart_num = 0;
 if (&serial == &Serial) {
 uart_num = 0;
 uart = &UART0;
 } else {
 if (&serial == &Serial1) {
 uart_num = 1;
 uart = &UART1;
 } else {
 if (&serial == &Serial2) {
 uart_num = 2;
 uart = &UART2;
 }
 }
 }
 // Is it a defined serial?
 if (uart != nullptr) {
 // Yes. get the current value and set ours instead
 rc = uart->conf1.rxfifo_full_thrhd;
 uart->conf1.rxfifo_full_thrhd = thresholdBytes;
 LOG_D("Serial%u FIFO threshold set to %d (was %d)\n", thresholdBytes, rc);
 } else {
 LOG_W("Unable to identify serial\n");
 }
 }
...

While this was working okay for the "classic" ESP32s, like WROOM and WROVER, it failed due to the non-existing UARTs for the newer MCUs like the S2 or C3, because there was no way in the 1.0.x core to determine at compile time the number of UARTs present.

Now in core 2.0.x we have the SOC_UART_NUM preprocessor variable to do the differentiation. That is nice, but is failing again for the users still using the 1.0.x core.

Is there any advisable way to get the differentiation in both the old and newer core? I mean, without taking the core version to incllude/exclude a chunk of code depending on it?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /