kopia lustrzana https://github.com/micropython/micropython
ports/embed: Enable use of extmod modules.
To include extmod and its dependencies in the output, include the word "extmod" in make variable EMBED_EXTRA when building the port. Ideally this would be deduced automatically from the set of modules enabled in mpconfigport.h (in a more fine-grained way too), but I can't think of a simple way of achieving that. Change in mphalport.h: fixes compiler error "type name requires a specifier or qualifier" in machine_i2c.h, included from machine_i2c.c. Signed-off-by: Christian Walther <cwalther@gmx.ch>pull/11430/head
rodzic
5e1ea0b5e9
commit
1be753fb7e
|
@ -15,7 +15,10 @@ CFLAGS += -I$(EMBED_DIR)/port
|
|||
CFLAGS += -Wall -Og -fno-common
|
||||
|
||||
SRC += main.c mphal.c
|
||||
SRC += $(wildcard $(EMBED_DIR)/*/*.c) $(wildcard $(EMBED_DIR)/*/*/*.c)
|
||||
SRC += $(wildcard $(EMBED_DIR)/*/*.c)
|
||||
# Filter out lib because the files in there cannot be compiled separately, they
|
||||
# are #included by other .c files.
|
||||
SRC += $(filter-out $(EMBED_DIR)/lib/%.c,$(wildcard $(EMBED_DIR)/*/*/*.c))
|
||||
OBJ += $(SRC:.c=.o)
|
||||
|
||||
$(PROG): $(OBJ)
|
||||
|
|
|
@ -28,6 +28,12 @@ static const char *example_2 =
|
|||
"help('modules')\n"
|
||||
"import sys\n"
|
||||
"help(sys)\n"
|
||||
"import os\n"
|
||||
"help(os)\n"
|
||||
"import random\n"
|
||||
"help(random)\n"
|
||||
"import time\n"
|
||||
"help(time)\n"
|
||||
"\n"
|
||||
"print('finish')\n"
|
||||
;
|
||||
|
|
|
@ -5,5 +5,8 @@
|
|||
# Set the location of the top of the MicroPython repository.
|
||||
MICROPYTHON_TOP = ../..
|
||||
|
||||
# Include modules from extmod in the output.
|
||||
EMBED_EXTRA = extmod
|
||||
|
||||
# Include the main makefile fragment to build the MicroPython component.
|
||||
include $(MICROPYTHON_TOP)/ports/embed/embed.mk
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
// Requires shared/readline/readline.h, don't bother as we have no input.
|
||||
#define MICROPY_PY_BUILTINS_INPUT (0)
|
||||
|
||||
// Requires MICROPY_EVENT_POLL_HOOK, don't bother as we have no pollable objects.
|
||||
#define MICROPY_PY_SELECT (0)
|
||||
|
||||
// Can be enabled once extmod/moductypes.c is included in the build.
|
||||
#define MICROPY_PY_UCTYPES (0)
|
||||
|
||||
|
|
|
@ -26,6 +26,32 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open);
|
|||
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_ASYNCIO
|
||||
|
||||
mp_uint_t mp_hal_ticks_ms(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_TIME
|
||||
|
||||
void mp_hal_delay_ms(mp_uint_t ms) {
|
||||
}
|
||||
|
||||
void mp_hal_delay_us(mp_uint_t us) {
|
||||
}
|
||||
|
||||
mp_uint_t mp_hal_ticks_us(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
mp_uint_t mp_hal_ticks_cpu(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Text-mode standard output
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
|
||||
// This is a simplistic implementation for demonstration purposes. A real
|
||||
|
|
|
@ -12,6 +12,9 @@ include $(MICROPYTHON_TOP)/py/mkenv.mk
|
|||
|
||||
# Include py core make definitions.
|
||||
include $(TOP)/py/py.mk
|
||||
ifeq ($(filter extmod,$(EMBED_EXTRA)),extmod)
|
||||
include $(TOP)/extmod/extmod.mk
|
||||
endif
|
||||
|
||||
# Set the location of the MicroPython embed port.
|
||||
MICROPYTHON_EMBED_PORT = $(MICROPYTHON_TOP)/ports/embed
|
||||
|
@ -43,6 +46,9 @@ clean-micropython-embed-package:
|
|||
|
||||
PACKAGE_DIR ?= micropython_embed
|
||||
PACKAGE_DIR_LIST = $(addprefix $(PACKAGE_DIR)/,py extmod shared/runtime genhdr port)
|
||||
ifeq ($(filter extmod,$(EMBED_EXTRA)),extmod)
|
||||
PACKAGE_DIR_LIST += $(addprefix $(PACKAGE_DIR)/,lib/uzlib lib/crypto-algorithms lib/re1.5)
|
||||
endif
|
||||
|
||||
.PHONY: micropython-embed-package
|
||||
micropython-embed-package: $(GENHDR_OUTPUT)
|
||||
|
@ -52,7 +58,15 @@ micropython-embed-package: $(GENHDR_OUTPUT)
|
|||
$(ECHO) "- py"
|
||||
$(Q)$(CP) $(TOP)/py/*.[ch] $(PACKAGE_DIR)/py
|
||||
$(ECHO) "- extmod"
|
||||
ifeq ($(filter extmod,$(EMBED_EXTRA)),extmod)
|
||||
$(Q)$(CP) $(TOP)/extmod/*.[ch] $(PACKAGE_DIR)/extmod
|
||||
$(ECHO) "- lib"
|
||||
$(Q)$(CP) $(TOP)/lib/uzlib/*.[ch] $(PACKAGE_DIR)/lib/uzlib
|
||||
$(Q)$(CP) $(TOP)/lib/crypto-algorithms/*.[ch] $(PACKAGE_DIR)/lib/crypto-algorithms
|
||||
$(Q)$(CP) $(TOP)/lib/re1.5/*.[ch] $(PACKAGE_DIR)/lib/re1.5
|
||||
else
|
||||
$(Q)$(CP) $(TOP)/extmod/modplatform.h $(PACKAGE_DIR)/extmod
|
||||
endif
|
||||
$(ECHO) "- shared"
|
||||
$(Q)$(CP) $(TOP)/shared/runtime/gchelper.h $(PACKAGE_DIR)/shared/runtime
|
||||
$(Q)$(CP) $(TOP)/shared/runtime/gchelper_generic.c $(PACKAGE_DIR)/shared/runtime
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Define so there's no dependency on extmod/virtpin.h
|
||||
#define mp_hal_pin_obj_t
|
||||
#define mp_hal_pin_obj_t mp_obj_t
|
||||
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
void mp_hal_set_interrupt_char(int c);
|
||||
|
|
Ładowanie…
Reference in New Issue