Add Phase 1 UART service foundation

Add versioned NVS-backed configuration, buffered UART1 I/O, modem
monitoring, counters, and serial console controls. Coordinate UART1
ownership with Phase 0 diagnostics and document loopback verification.
This commit is contained in:
2026-08-22 23:23:13 +02:00
parent 126314a277
commit 535c27350d
13 changed files with 1961 additions and 30 deletions
+27 -5
View File
@@ -4,17 +4,21 @@
#include "esp_log.h"
#include "esp_psram.h"
#include "rs232_hw_test.h"
#include "rs232_port_owner.h"
#include "serial_config.h"
#include "serial_console.h"
#include "serial_service.h"
#include "status_led.h"
#define CONSOLE_BAUD_RATE 115200
#define CONSOLE_TX_GPIO 43
#define CONSOLE_RX_GPIO 44
static const char *TAG = "phase0";
static const char *TAG = "firmware";
void app_main(void)
{
ESP_LOGI(TAG, "ESP32-S3 RS-232 Phase 0 hardware characterization started");
ESP_LOGI(TAG, "ESP32-S3 Serial Swiss Army Knife Phase 1 started");
if (esp_psram_is_initialized()) {
ESP_LOGI(TAG, "PSRAM initialized: %u bytes", (unsigned int)esp_psram_get_size());
@@ -22,12 +26,29 @@ void app_main(void)
ESP_LOGW(TAG, "PSRAM is not initialized");
}
/* Blue means that the test harness is initialized and waiting for a command. */
/* Blue means the firmware is initialized and waiting for a console command. */
ESP_ERROR_CHECK(status_led_init());
ESP_ERROR_CHECK(rs232_port_owner_init());
ESP_ERROR_CHECK(rs232_hw_test_init());
serial_config_t serial_config;
bool used_stored_config = false;
esp_err_t config_error = serial_config_load(&serial_config, &used_stored_config);
if (config_error != ESP_OK) {
serial_config_defaults(&serial_config);
ESP_LOGW(
TAG,
"NVS serial configuration unavailable (%s); using RAM defaults without erasing storage",
esp_err_to_name(config_error));
}
ESP_ERROR_CHECK(serial_service_init(&serial_config));
ESP_LOGI(
TAG,
"Using %s serial configuration; UART service remains stopped until 'serial start'",
used_stored_config ? "stored" : "default");
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
repl_config.prompt = "rs232-test> ";
repl_config.prompt = "serial-tool> ";
repl_config.max_cmdline_length = 160;
repl_config.task_stack_size = 8192;
@@ -46,8 +67,9 @@ void app_main(void)
/* The REPL constructor initializes esp_console and installs `help`. */
ESP_ERROR_CHECK(rs232_hw_test_register_console_commands());
ESP_ERROR_CHECK(serial_console_register_commands());
ESP_ERROR_CHECK(esp_console_start_repl(repl));
ESP_LOGI(TAG, "Interactive test console ready at %d baud", CONSOLE_BAUD_RATE);
ESP_LOGI(TAG, "Type 'help' for commands; no test runs automatically");
ESP_LOGI(TAG, "Type 'help' for commands; no serial service or test runs automatically");
}