mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 12:25:20 +03:00
Adding RP2350 SDK and target framework (#13988)
* Adding RP2350 SDK and target framework * Spacing * Removing board definitions
This commit is contained in:
parent
462cb05930
commit
2dd6f95aad
576 changed files with 435012 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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 ENABLED)` 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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(void);
|
||||
|
||||
/*! \brief Explicitly deinitialize 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_deinit_all() if `pico_stdio_semihosting` is included in the build
|
||||
*/
|
||||
void stdio_semihosting_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 stdio_semihosting_out_chars(const char *buf, int length) {
|
||||
// must be volatile or the buffer gets put in registers & optimized away
|
||||
volatile struct {
|
||||
// https://developer.arm.com/documentation/dui0375/g/What-is-Semihosting-/SYS-WRITE--0x05-
|
||||
// arguments, in order:
|
||||
// word 0 = file handle (1 = stdout)
|
||||
// word 1 = pointer to buffer
|
||||
// word 2 = length of buffer
|
||||
size_t fd;
|
||||
const char *buf;
|
||||
size_t len;
|
||||
} args;
|
||||
|
||||
args.fd = 1; // 1 = stdout
|
||||
args.buf = buf;
|
||||
args.len = length;
|
||||
|
||||
pico_default_asm (
|
||||
#ifdef __riscv
|
||||
// a0 encodes the semihosting call number, 0x05 = SYS_WRITE
|
||||
"li a0, 0x05\n"
|
||||
// a1 points to the arguments
|
||||
"mv a1, %[args]\n"
|
||||
// Magic three-instruction sequence, containing a breakpoint. Note the
|
||||
// RISC-V unpriv spec implies the final instruction might encode the
|
||||
// call number (passed in a1) but openocd source shows this is just a
|
||||
// constant value of 0x07. These instructions must be uncompressed:
|
||||
".option push\n"
|
||||
".option norvc\n"
|
||||
"slli x0, x0, 0x1f\n"
|
||||
"ebreak\n"
|
||||
"srai x0, x0, 0x07\n"
|
||||
".option pop\n"
|
||||
:
|
||||
: [args] "r" (&args)
|
||||
: "a0", "a1"
|
||||
#else
|
||||
// r1 must contain a pointer to the arguments
|
||||
"movs r1, %[args]\n"
|
||||
// semihosting call number 0x05 = SYS_WRITE
|
||||
"movs r0, #5\n"
|
||||
// make the semihosting call: https://developer.arm.com/documentation/dui0375/g/What-is-Semihosting-/The-semihosting-interface
|
||||
"bkpt 0xab\n"
|
||||
:
|
||||
: [args] "r" (&args)
|
||||
: "r0", "r1", "cc", "memory"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
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(void) {
|
||||
#if !PICO_NO_BI_STDIO_SEMIHOSTING
|
||||
bi_decl_if_func_used(bi_program_feature("semihosting stdout"));
|
||||
#endif
|
||||
stdio_set_driver_enabled(&stdio_semihosting, true);
|
||||
}
|
||||
|
||||
void stdio_semihosting_deinit(void) {
|
||||
stdio_set_driver_enabled(&stdio_semihosting, false);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue