mirror of
https://github.com/G42makes/mp-s7.git
synced 2025-04-05 12:37:29 +00:00
not compiling with some sembelance of working, but does nothing and there is no way to quit the app
This commit is contained in:
parent
5a9f8fda90
commit
2df5273c21
@ -25,12 +25,23 @@ install(TARGETS RetroConsole DESTINATION lib)
|
||||
#micropython/lib/utils - library
|
||||
add_library(mp_lib_utils
|
||||
../micropython/lib/utils/stdout_helpers.c
|
||||
../micropython/lib/utils/pyexec.h
|
||||
../micropython/lib/utils/pyexec.c
|
||||
)
|
||||
target_include_directories(mp_lib_utils PUBLIC
|
||||
../micropython/
|
||||
../micropython/ports/minimal/build/
|
||||
./
|
||||
)
|
||||
add_library(mp_lib_readline
|
||||
../micropython/lib/mp-readline/readline.h
|
||||
../micropython/lib/mp-readline/readline.c
|
||||
)
|
||||
target_include_directories(mp_lib_readline PUBLIC
|
||||
../micropython/
|
||||
../micropython/ports/minimal/build/
|
||||
./
|
||||
)
|
||||
|
||||
#micropython/py - main codebase
|
||||
file(GLOB mp_py_SRC
|
||||
@ -39,7 +50,7 @@ file(GLOB mp_py_SRC
|
||||
../micropython/ports/minimal/build/_frozen_mpy.c
|
||||
mpconfigport.h
|
||||
mphalport.h
|
||||
stringio.c
|
||||
stringio.cc
|
||||
)
|
||||
add_library(mp_py ${mp_py_SRC})
|
||||
target_include_directories(mp_py PUBLIC
|
||||
@ -56,8 +67,8 @@ file(GLOB micropython_SRC
|
||||
mpconfigport.h
|
||||
mphalport.h
|
||||
mphalport.c
|
||||
stringio.c
|
||||
main.c
|
||||
stringio.cc
|
||||
main.cc
|
||||
)
|
||||
add_application(MPTests ${micropython_SRC})
|
||||
|
||||
@ -70,7 +81,7 @@ target_include_directories(MPTests
|
||||
target_link_libraries(MPTests
|
||||
RetroConsole
|
||||
mp_lib_utils
|
||||
mp_lib_readline
|
||||
mp_py
|
||||
# MP
|
||||
)
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
//#include "retro/Console.h"
|
||||
#include "retro/Console.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
//Here we start to merge the C code from the MP minimal example with the C++ code from the Retro68 Console example
|
||||
extern "C" {
|
||||
|
||||
#include "py/compile.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/repl.h"
|
||||
@ -10,6 +14,11 @@
|
||||
#include "py/mperrno.h"
|
||||
#include "lib/utils/pyexec.h"
|
||||
|
||||
}
|
||||
|
||||
extern "C" int mp_hal_stdin_rx_chr(void);
|
||||
extern "C" void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
|
||||
|
||||
#if MICROPY_ENABLE_COMPILER
|
||||
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
|
||||
nlr_buf_t nlr;
|
||||
@ -32,12 +41,11 @@ static char *stack_top;
|
||||
static char heap[2048];
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
namespace retro
|
||||
{
|
||||
void InitConsole();
|
||||
}
|
||||
*/
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -49,11 +57,19 @@ int main()
|
||||
#endif
|
||||
mp_init();
|
||||
|
||||
/*
|
||||
|
||||
retro::InitConsole();
|
||||
std::string out = "Hello, world.\nEnter \"exit\" to quit.\n";
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
|
||||
pyexec_event_repl_init();
|
||||
for (;;) {
|
||||
int c = mp_hal_stdin_rx_chr();
|
||||
if (pyexec_event_repl_process_char(c)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string in;
|
||||
do
|
||||
{
|
||||
@ -61,11 +77,14 @@ int main()
|
||||
out = "You Entered: " + in;
|
||||
retro::Console::currentInstance->write(out.data(), out.size());
|
||||
} while(in != "exit\n");
|
||||
|
||||
|
||||
mp_deinit();
|
||||
return 0;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void gc_collect(void) {
|
||||
extern "C" void gc_collect(void) {
|
||||
// WARNING: This gc_collect implementation doesn't try to get root
|
||||
// pointers from CPU registers, and thus may function incorrectly.
|
||||
void *dummy;
|
||||
@ -74,4 +93,3 @@ void gc_collect(void) {
|
||||
gc_collect_end();
|
||||
gc_dump_info();
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_GC_ALLOC_THRESHOLD (0)
|
||||
#define MICROPY_REPL_EVENT_DRIVEN (0)
|
||||
#define MICROPY_REPL_EVENT_DRIVEN (1)
|
||||
#define MICROPY_HELPER_REPL (1)
|
||||
#define MICROPY_HELPER_LEXER_UNIX (0)
|
||||
#define MICROPY_ENABLE_SOURCE_LINE (0)
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include <unistd.h>
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
/*
|
||||
* Core UART functions to implement for a port
|
||||
*/
|
||||
|
||||
// Receive single character
|
||||
int mp_hal_stdin_rx_chr(void) {
|
||||
unsigned char c = 0;
|
||||
int r = read(0, &c, 1);
|
||||
(void)r;
|
||||
return c;
|
||||
}
|
||||
|
||||
// Send string of given length
|
||||
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
|
||||
int r = write(1, str, len);
|
||||
(void)r;
|
||||
}
|
22
mp-s7-src/stringio.cc
Normal file
22
mp-s7-src/stringio.cc
Normal file
@ -0,0 +1,22 @@
|
||||
//#include "retro/Console.h"
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
#include "py/mpconfig.h"
|
||||
}
|
||||
|
||||
extern "C" int mp_hal_stdin_rx_chr(void);
|
||||
extern "C" void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
|
||||
|
||||
// Receive single character
|
||||
int mp_hal_stdin_rx_chr(void) {
|
||||
unsigned char c = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
// Send string of given length
|
||||
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
|
||||
//int r = write(1, str, len);
|
||||
//retro::Console::currentInstance->write(str, len);
|
||||
//(void)r;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user