Add Phase 0 RS-232 characterization harness and test firmware with cli

This commit is contained in:
2026-08-22 16:15:53 +02:00
parent e43b624aec
commit 3024b135dc
11 changed files with 1164 additions and 71 deletions
+36 -57
View File
@@ -1,54 +1,20 @@
#include <stdint.h>
#include "driver/uart.h"
#include "esp_console.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_psram.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "led_strip.h"
#include "led_strip_rmt.h"
#include "rs232_hw_test.h"
#include "status_led.h"
#ifndef RGB_LED_GPIO
#define RGB_LED_GPIO 48
#endif
#define CONSOLE_BAUD_RATE 115200
#define CONSOLE_TX_GPIO 43
#define CONSOLE_RX_GPIO 44
#define RGB_LED_COUNT 1
#define RGB_LED_BRIGHTNESS 32
#define FADE_STEP_DELAY_MS 20
static const char *TAG = "rgb_smoke_test";
static led_strip_handle_t configure_rgb_led(void)
{
const led_strip_config_t strip_config = {
.strip_gpio_num = RGB_LED_GPIO,
.max_leds = RGB_LED_COUNT,
.led_model = LED_MODEL_WS2812,
.color_component_format = LED_STRIP_COLOR_COMPONENT_FMT_GRB,
.flags = {
.invert_out = false,
},
};
const led_strip_rmt_config_t rmt_config = {
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = 10 * 1000 * 1000,
.mem_block_symbols = 0,
.flags = {
.with_dma = false,
},
};
led_strip_handle_t strip = NULL;
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &strip));
ESP_ERROR_CHECK(led_strip_clear(strip));
return strip;
}
static const char *TAG = "phase0";
void app_main(void)
{
ESP_LOGI(TAG, "ESP32-S3 build-chain smoke test started");
ESP_LOGI(TAG, "ESP32-S3 RS-232 Phase 0 hardware characterization started");
if (esp_psram_is_initialized()) {
ESP_LOGI(TAG, "PSRAM initialized: %u bytes", (unsigned int)esp_psram_get_size());
@@ -56,19 +22,32 @@ void app_main(void)
ESP_LOGW(TAG, "PSRAM is not initialized");
}
led_strip_handle_t strip = configure_rgb_led();
ESP_LOGI(TAG, "Sweeping the onboard RGB LED on GPIO%d", RGB_LED_GPIO);
/* Blue means that the test harness is initialized and waiting for a command. */
ESP_ERROR_CHECK(status_led_init());
ESP_ERROR_CHECK(rs232_hw_test_init());
while (true) {
for (uint16_t hue = 0; hue < 360; ++hue) {
ESP_ERROR_CHECK(led_strip_set_pixel_hsv(
strip,
0,
hue,
UINT8_MAX,
RGB_LED_BRIGHTNESS));
ESP_ERROR_CHECK(led_strip_refresh(strip));
vTaskDelay(pdMS_TO_TICKS(FADE_STEP_DELAY_MS));
}
}
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
repl_config.prompt = "rs232-test> ";
repl_config.max_cmdline_length = 160;
repl_config.task_stack_size = 8192;
/*
* UART0 remains dedicated to development and diagnostics. The external
* RS-232 data path uses UART1 on GPIO17/18 and cannot disturb this REPL.
*/
esp_console_dev_uart_config_t uart_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
uart_config.channel = UART_NUM_0;
uart_config.baud_rate = CONSOLE_BAUD_RATE;
uart_config.tx_gpio_num = CONSOLE_TX_GPIO;
uart_config.rx_gpio_num = CONSOLE_RX_GPIO;
esp_console_repl_t *repl = NULL;
ESP_ERROR_CHECK(esp_console_new_repl_uart(&uart_config, &repl_config, &repl));
/* The REPL constructor initializes esp_console and installs `help`. */
ESP_ERROR_CHECK(rs232_hw_test_register_console_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");
}