diff options
author | Keith Packard <keithpac@amazon.com> | 2023-03-02 12:55:57 -0800 |
---|---|---|
committer | Paul Bartell <paul.bartell@gmail.com> | 2023-03-30 12:32:55 -0700 |
commit | f807222c85118002f1f980dfe4ec00befb083ded (patch) | |
tree | 61d1427a3f1ec82c4bf70854bdc4ec55c8af1894 | |
parent | 0ecd0f5188108449af89fa0805e816bf882268a9 (diff) | |
download | freertos-git-f807222c85118002f1f980dfe4ec00befb083ded.tar.gz |
Demo/CORTEX_M3_MPS2_QEMU_GCC: Provide picolibc syscall implementation
Instead of a set of POSIX-compatible APIs as needed by newlib,
picolibc needs a FILE struct allocated that references a function to
output a single character. Picolibc also doesn't need sbrk as it has
its own version
Signed-off-by: Keith Packard <keithpac@amazon.com>
-rw-r--r-- | FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c index 6ca04f8da..2a2e95581 100644 --- a/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c +++ b/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c @@ -50,8 +50,6 @@ extern unsigned long _heap_bottom; extern unsigned long _heap_top; extern unsigned long g_ulBase; -static void * heap_end = 0; - /** * @brief initializes the UART emulated hardware */ @@ -61,6 +59,34 @@ void uart_init() UART0_ADDR->CTRL = UART_CTRL_TX_EN; } +#ifdef __PICOLIBC__ + +#include <stdio.h> + +/** + * @brief Write byte to the UART channel to be displayed on the command line + * with qemu + * @param [in] c byte to send + * @param [in] file ignored + * @returns the character written (cast to unsigned so it is not an error value) + */ + +int +_uart_putc(char c, FILE *file) +{ + (void) file; + UART_DR( UART0_ADDR ) = c; + return (unsigned char) c; +} + +static FILE __stdio = FDEV_SETUP_STREAM(_uart_putc, NULL, NULL, _FDEV_SETUP_WRITE); + +FILE *const stdout = &__stdio; + +#else + +static void * heap_end = 0; + /** * @brief not used anywhere in the code * @todo implement if necessary @@ -132,6 +158,8 @@ void * _sbrk( int incr ) return prev_heap_end; } +#endif + #ifdef __cplusplus } #endif |