How do you explain this works?
Code: Select all
#include "driver/uart.h"
// ESP32S2 usb cdc on boot on, usb dfu on boot off, upload mode internal usb.
const int VEBUS_RXD1=13, VEBUS_TXD1=12;
const int VEBUS_RXD2=10, VEBUS_TXD2=11;
const int UART_USED1 = 0; //UART_NUM_1; // serial1
const int UART_USED2 = 1; // serial2
const int LED = 15;
esp_err_t err11,err12,err13,err21,err22,err23;
void setup()
{
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
Serial.begin(115200);
delay(5000);
Serial.println("Start");
uart_config_t uart_config1 =
{
.baud_rate = 9600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 32,
};
err11 = uart_driver_install(UART_USED1, 256, 256, 0, NULL, 0);
err12 = uart_param_config(UART_USED1, &uart_config1);
err13 = uart_set_pin(UART_USED1, VEBUS_TXD1, VEBUS_RXD1, -1, -1);
Serial.println(err11);
Serial.println(err12);
Serial.println(err13);
uart_config_t uart_config2 =
{
.baud_rate = 9600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_EVEN,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 32,
};
err21 = uart_driver_install(UART_USED2, 256, 256, 0, NULL, 0);
err22 = uart_param_config(UART_USED2, &uart_config2);
err23 = uart_set_pin(UART_USED2, VEBUS_TXD2, VEBUS_RXD2, -1, -1);
Serial.println(err21);
Serial.println(err22);
Serial.println(err23);
Serial.println("Done");
}
char buf1[3] = { 0xaF, 0x00, 0x55 };
char buf2[3] = { 0xa0, 0xFF, 0x55 };
void loop()
{
uart_write_bytes(UART_USED1, buf1, 3);
buf1[2]++;
uart_write_bytes(UART_USED2, buf2, 3);
buf2[2]++;
delay(100);
digitalWrite(LED, !digitalRead(LED));
}
usb output
This shows two hardware UART and the usb console working by circumnavigating the arduino functions.
"You are, quite simply, incorrect."
pic measured pin 11 and 12