/*************************************************************************** * Copyright (c) 2026 Eclipse ThreadX contributors * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. * * AI Disclosure: This file was largely AI-generated by Codex (GPT-6-Sol). * The AI-generated portions may be considered public domain (CC0-1.0) * and not subject to the project's licence. The human contributor has * reviewed and verified that the code is correct. * * SPDX-License-Identifier: MIT and CC0-1.0 ***************************************************************************/ #include "tx_api.h" #include "uart.h" #include "hwtimer.h" #define TEST_TEXT_SIZE 160000u static TX_THREAD test_thread; static UCHAR test_stack[2048]; static char test_text[TEST_TEXT_SIZE + 1u]; /* Run the kernel with the board's normal interrupt setup. */ int main(void) { tx_kernel_enter(); return 0; } /* Print long enough to span several hardware timer intervals. */ static void test_entry(ULONG input) { uint64_t start; uint64_t elapsed; ULONG ticks_before; ULONG ticks_after; size_t i; (void)input; for (i = 0u; i < TEST_TEXT_SIZE; i++) { test_text[i] = 'X'; } test_text[TEST_TEXT_SIZE] = '\0'; /* MISRA C:2012 Rule 11.4 deviation: the timer has a fixed MMIO address. */ start = *(volatile uint64_t *)ERBIUM_MTIME; ticks_before = tx_time_get(); (void)uart_puts(test_text); elapsed = *(volatile uint64_t *)ERBIUM_MTIME - start; ticks_after = tx_time_get(); if (elapsed <= (2u * TICKNUM_PER_TIMER)) { uart_puts("TEST_UART_TOO_SHORT"); } else if ((ticks_after - ticks_before) < 2u) { uart_puts("TEST_UART_LOST_TICKS"); } else { uart_puts("TEST_UART_NO_LOST_TICKS"); } for (;;) { } } /* Start one test thread. */ void tx_application_define(void *first_unused_memory) { (void)first_unused_memory; (void)tx_thread_create(&test_thread, "uart test", test_entry, 0u, test_stack, sizeof(test_stack), 1u, 1u, TX_NO_TIME_SLICE, TX_AUTO_START); }