blob: 188af2e7dd68fbbcc785417be02aac91984c8372 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/***************************************************************************
* 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);
}
|