#include #include #include #include #include #include #include #include const static char *TAG = "MAIN"; #define GPIO_LED_PASS 12 #define GPIO_LED_FAIL 13 #define GPIO_BTN_TEST 14 static void init_gpio() { gpio_config_t io_conf = {}; io_conf.intr_type = GPIO_INTR_DISABLE; io_conf.mode = GPIO_MODE_OUTPUT; io_conf.pin_bit_mask = ((1ULL< B gen_rand_str(msg_a); uart_write_bytes(UART_A, msg_a, strlen(msg_a)); int len = uart_read_bytes(UART_B, msg_b, UART_BUFFER_SIZE, 10 / portTICK_PERIOD_MS); if (len <= 0) { led_fail(); ESP_LOGW(TAG, "A -> B: read fail"); return; } msg_b[len] = '\0'; if (strcmp(msg_a, msg_b) != 0) { led_fail(); ESP_LOGW(TAG, "A -> B: mismatch: %s, %s", msg_a, msg_b); return; } vTaskDelay(10 / portTICK_PERIOD_MS); // B -> A gen_rand_str(msg_a); uart_write_bytes(UART_B, msg_a, strlen(msg_a)); len = uart_read_bytes(UART_A, msg_b, UART_BUFFER_SIZE, 10 / portTICK_PERIOD_MS); if (len <= 0) { led_fail(); ESP_LOGW(TAG, "A -> B: read fail"); return; } msg_b[len] = '\0'; if (strcmp(msg_a, msg_b) != 0) { led_fail(); ESP_LOGW(TAG, "A -> B: mismatch: %s, %s", msg_a, msg_b); return; } led_pass(); } void app_main(void) { init_gpio(); init_uart(); blink(); while (1) { while (1) { vTaskDelay(10 / portTICK_PERIOD_MS); if (!gpio_get_level(GPIO_BTN_TEST)) { break; } } blink(); test_485(); } }