Initial Release

This commit is contained in:
graham sanderson
2021-01-20 10:44:27 -06:00
commit 26653ea81e
404 changed files with 135614 additions and 0 deletions

View File

@ -0,0 +1,13 @@
add_library(pico_stdio_semihosting INTERFACE)
target_sources(pico_stdio_semihosting INTERFACE
${CMAKE_CURRENT_LIST_DIR}/stdio_semihosting.c
)
target_include_directories(pico_stdio_semihosting INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_compile_definitions(pico_stdio_semihosting INTERFACE
PICO_STDIO_SEMIHOSTING=1
)
target_link_libraries(pico_stdio_semihosting INTERFACE pico_stdio)

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _PICO_STDIO_SEMIHOSTING_H
#define _PICO_STDIO_SEMIHOSTING_H
#include "pico/stdio.h"
/** \brief Experimental support for stdout using RAM semihosting
* \defgroup pico_stdio_semihosting pico_stdio_semihosting
* \ingroup pico_stdio
*
* Linking this library or calling `pico_enable_stdio_semihosting(TARGET)` in the CMake (which
* achieves the same thing) will add semihosting to the drivers used for standard output
*/
// PICO_CONFIG: PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF, Default state of CR/LF translation for semihosting output, type=bool, default=PICO_STDIO_DEFAULT_CRLF, group=pico_stdio_semihosting
#ifndef PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF
#define PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF PICO_STDIO_DEFAULT_CRLF
#endif
extern stdio_driver_t stdio_semihosting;
/*! \brief Explicitly initialize stdout over semihosting and add it to the current set of stdout targets
* \ingroup pico_stdio_semihosting
*
* \note this method is automatically called by \ref stdio_init_all() if `pico_stdio_semihosting` is included in the build
*/
void stdio_semihosting_init();
#endif

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "pico/stdio/driver.h"
#include "pico/stdio_semihosting.h"
#include "pico/binary_info.h"
//static void __attribute__((naked)) semihosting_puts(const char *s) {
// __asm (
//
// "mov r1, r0\n"
// "mov r0, #4\n"
// "bkpt 0xab\n"
// "bx lr\n"
// );
//}
static void __attribute__((naked)) semihosting_putc(char c) {
__asm (
"mov r1, r0\n"
"mov r0, #3\n"
"bkpt 0xab\n"
"bx lr\n"
);
}
static void stdio_semihosting_out_chars(const char *buf, int length) {
for (uint i = 0; i <length; i++) {
semihosting_putc(buf[i]);
}
}
stdio_driver_t stdio_semihosting = {
.out_chars = stdio_semihosting_out_chars,
#if PICO_STDIO_ENABLE_CRLF_SUPPORT
.crlf_enabled = PICO_STDIO_SEMIHOSTING_DEFAULT_CRLF
#endif
};
void stdio_semihosting_init() {
#if !PICO_NO_BI_STDIO_SEMIHOSTING
bi_decl_if_func_used(bi_program_feature("semihosting stdout"));
#endif
stdio_set_driver_enabled(&stdio_semihosting, true);
}