diff --git a/ARM.CMSIS-Compiler.pdsc b/ARM.CMSIS-Compiler.pdsc index e0e3b3e..93a9417 100644 --- a/ARM.CMSIS-Compiler.pdsc +++ b/ARM.CMSIS-Compiler.pdsc @@ -17,6 +17,8 @@ Active Development ... CLANG: - Added standard I/O stream support for LLVM-libc + I/O Retarget: + - Added reargeting to RTT @@ -105,6 +107,11 @@ + + CMSIS-Compiler CORE component and RTT + + + CMSIS-Compiler CORE component and CMSIS-Driver USART @@ -138,6 +145,12 @@ + + ARMCC and CORE component and RTT + + + + ARMCC and CORE component and CMSIS-RTOS2 @@ -328,6 +341,16 @@ + + Redirect STDERR to RTT (Channel 0) + + #define RTE_CMSIS_Compiler_STDERR /* CMSIS-Compiler STDERR */ + #define RTE_CMSIS_Compiler_STDERR_RTT /* CMSIS-Compiler STDERR: RTT */ + + + + + Redirect STDERR to a CMSIS-Driver USART @@ -370,6 +393,16 @@ + + Retrieve STDIN from RTT (Channel 0) + + #define RTE_CMSIS_Compiler_STDIN /* CMSIS-Compiler STDIN */ + #define RTE_CMSIS_Compiler_STDIN_RTT /* CMSIS-Compiler STDIN: RTT */ + + + + + Retrieve STDIN from a CMSIS-Driver USART @@ -422,6 +455,16 @@ + + Redirect STDOUT to RTT (Channel 0) + + #define RTE_CMSIS_Compiler_STDOUT /* CMSIS-Compiler STDOUT */ + #define RTE_CMSIS_Compiler_STDOUT_RTT /* CMSIS-Compiler STDOUT: RTT */ + + + + + Redirect STDOUT to a CMSIS-Driver USART @@ -464,6 +507,16 @@ + + Redirect TTY to RTT (Channel 0) + + #define RTE_CMSIS_Compiler_TTY /* CMSIS-Compiler TTY */ + #define RTE_CMSIS_Compiler_TTY_RTT /* CMSIS-Compiler TTY: RTT */ + + + + + diff --git a/source/stderr/stderr_rtt.c b/source/stderr/stderr_rtt.c new file mode 100644 index 0000000..28fed48 --- /dev/null +++ b/source/stderr/stderr_rtt.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2026 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "retarget_stderr.h" + +#include "SEGGER_RTT.h" + +/** + Put a character to the stderr + + \param[in] ch Character to output + \return The character written, or -1 on write error. +*/ +int stderr_putchar (int ch) { + unsigned res; + + res = SEGGER_RTT_PutChar(0U, (char)ch); + + if (res != 1U) { + return -1; + } + + return (ch); +} diff --git a/source/stdin/stdin_rtt.c b/source/stdin/stdin_rtt.c new file mode 100644 index 0000000..bac8752 --- /dev/null +++ b/source/stdin/stdin_rtt.c @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2026 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "retarget_stdin.h" + +#include "SEGGER_RTT.h" + +/** + Get a character from the stdio + + \return The next character from the input, or -1 on read error. +*/ +int stdin_getchar (void) { + int ret; + + ret = SEGGER_RTT_WaitKey(); + + return ret; +} diff --git a/source/stdout/stdout_rtt.c b/source/stdout/stdout_rtt.c new file mode 100644 index 0000000..a60f72a --- /dev/null +++ b/source/stdout/stdout_rtt.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2026 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "retarget_stdout.h" + +#include "SEGGER_RTT.h" + +/** + Put a character to the stdout + + \param[in] ch Character to output + \return The character written, or -1 on write error. +*/ +int stdout_putchar (int ch) { + unsigned res; + + res = SEGGER_RTT_PutChar(0U, (char)ch); + + if (res != 1U) { + return -1; + } + + return (ch); +} diff --git a/source/tty/tty_rtt.c b/source/tty/tty_rtt.c new file mode 100644 index 0000000..6f38e1c --- /dev/null +++ b/source/tty/tty_rtt.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2026 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "retarget_tty.h" + +#include "SEGGER_RTT.h" + +/** + Put a character to the teletypewritter + + \param[in] ch Character to output +*/ +void ttywrch (int ch) { + SEGGER_RTT_PutChar(0U, (char)ch); +}