Skip to content
Permalink
Browse files

LabAPart/micropython: Minimal micropython main()

  • Loading branch information...
oliviermartin committed Feb 21, 2017
1 parent 8e2b4cd commit 15c07476bb013964d802db1f7505865d1b9e8435
@@ -25,4 +25,4 @@
#

# List of modules needed by the application
set(LIST_MODULES CMSIS Lib/PolyMCU)
set(LIST_MODULES CMSIS Lib/PolyMCU Lib/MicroPython)
@@ -29,7 +29,8 @@ cmake_minimum_required(VERSION 2.6)
find_package(Board)
find_package(CMSIS)
find_package(PolyMCU)
find_package(MicroPython)

set(Firmware_SRCS main.c)
set(Firmware_LIBS ${Board_LIBRARIES} ${PolyMCU_LIBRARIES})
set(Firmware_LIBS ${Board_LIBRARIES} ${PolyMCU_LIBRARIES} ${MicroPython_LIBRARIES})
BUILD_FIRMWARE(Firmware micropython "${Firmware_SRCS}" "${Firmware_LIBS}")
@@ -25,13 +25,57 @@
*/

#include "board.h"

#include "py/nlr.h"
#include "py/compile.h"
#include "py/runtime.h"
#include "py/repl.h"
#include "py/gc.h"
#include "lib/utils/pyexec.h"

#include <stdio.h>

static char heap[2048];

// The processor clock is initialized by CMSIS startup + system file
int main (void) {
set_led(1, 1);
#if MICROPY_ENABLE_GC
gc_init(heap, heap + sizeof(heap));
#endif

mp_init();

while (1) {
puts("Hello World!");
#if MICROPY_REPL_EVENT_DRIVEN
pyexec_event_repl_init();
for (;;) {
int c = mp_hal_stdin_rx_chr();
if (pyexec_event_repl_process_char(c)) {
break;
}
}
#else
pyexec_friendly_repl();
#endif

//do_str("print('hello world!', list(x+1 for x in range(10)), end='eol\\n')", MP_PARSE_SINGLE_INPUT);
//do_str("for i in range(10):\r\n print(i)", MP_PARSE_FILE_INPUT);

mp_deinit();
return 0;
}

void nlr_jump_fail(void *val) {
}

mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return NULL;
}

mp_import_stat_t mp_import_stat(const char *path) {
return MP_IMPORT_STAT_NO_EXIST;
}

mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);

0 comments on commit 15c0747

Please sign in to comment.
You can’t perform that action at this time.