mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
shared/runtime/semihosting_arm: Add mp_semihosting_exit.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#define SYS_WRITE 0x05
|
||||
#define SYS_READ 0x06
|
||||
#define SYS_READC 0x07
|
||||
#define SYS_EXIT 0x18
|
||||
|
||||
// Constants:
|
||||
#define OPEN_MODE_READ (0) // mode "r"
|
||||
@@ -88,6 +89,13 @@ void mp_semihosting_init() {
|
||||
mp_semihosting_stdout = mp_semihosting_open_console(OPEN_MODE_WRITE);
|
||||
}
|
||||
|
||||
void mp_semihosting_exit(int status) {
|
||||
if (status == 0) {
|
||||
status = 0x20026;
|
||||
}
|
||||
mp_semihosting_call(SYS_EXIT, (void *)(uintptr_t)status);
|
||||
}
|
||||
|
||||
int mp_semihosting_rx_char() {
|
||||
return mp_semihosting_call(SYS_READC, NULL);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ If mp_semihosting_rx_char() doesn't work then try mp_semihosting_rx_chars(str, 1
|
||||
#include <stdint.h>
|
||||
|
||||
void mp_semihosting_init();
|
||||
void mp_semihosting_exit(int status);
|
||||
int mp_semihosting_rx_char();
|
||||
int mp_semihosting_rx_chars(char *str, size_t len);
|
||||
uint32_t mp_semihosting_tx_strn(const char *str, size_t len);
|
||||
|
||||
Reference in New Issue
Block a user