Skip to content
Snippets Groups Projects
Verified Commit cac1586b authored by rahix's avatar rahix
Browse files

Merge branch 'rahix/micropyhton'


Signed-off-by: default avatarRahix <rahix@rahix.de>
parents 78dfac6c d748ba4b
No related branches found
No related tags found
No related merge requests found
Showing
with 552 additions and 3 deletions
flags = -DBOARD_CARD10=1 -D_FILE_OFFSET_BITS=64 -DTARGET=32665 -DTARGET_REV=0x4131 -Ihw-tests/bmatest -Ihw-tests/bmetest -Ihw-tests/ecgtest -Ihw-tests/hello-freertos -Ihw-tests/hello-freertos/./ -Ihw-tests/hello-world -Ihw-tests/imutest -Ihw-tests/ips -Ilib/./card10/./ -Ilib/card10 -Ilib/./gfx/./ -Ilib/gfx -Ilib/./gfx/./Fonts/ -Ilib/./gfx/./GUI_DEV/ -Ilib/./gfx/./LCD/ -Ilib/sdk/Libraries/Boards/card10 -Ilib/./sdk/./Libraries/Boards/card10/../Include/ -Ilib/./sdk/./Libraries/Boards/card10/./Include/ -Ilib/sdk/Libraries/CMSIS/Device/Maxim/MAX32665 -Ilib/./sdk/./Libraries/FreeRTOS/../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/ -Ilib/./sdk/./Libraries/FreeRTOS/./Source/include/ -Ilib/./sdk/./Libraries/FreeRTOS/./Source/portable/GCC/ARM_CM4F/ -Ilib/sdk/Libraries/MAX32665PeriphDriver -Ilib/./sdk/./Libraries/MAX32665PeriphDriver/../CMSIS/Device/Maxim/MAX32665/Include/ -Ilib/./sdk/./Libraries/MAX32665PeriphDriver/../CMSIS/Include/ -Ilib/./sdk/./Libraries/MAX32665PeriphDriver/Include/ -Ilib/vendor/Bosch/BHy1 -Ilib/./vendor/Bosch/BHy1/../../../card10/ -Ilib/./vendor/Bosch/BHy1/./driver/inc/ -Ilib/./vendor/Bosch/BHy1/./examples/firmware/ -Ilib/./vendor/Bosch/BMA400/./ -Ilib/vendor/Bosch/BMA400 -Ilib/./vendor/Bosch/BME680/./ -Ilib/vendor/Bosch/BME680 -Ilib/./vendor/Maxim/MAX77650/./ -Ilib/vendor/Maxim/MAX77650
flags = -DBOARD_CARD10=1 -D_FILE_OFFSET_BITS=64 -DTARGET=32665 -DTARGET_REV=0x4131 -Ibuild/../hw-tests/api-demo -Ibuild/hw-tests/api-demo/ -Ibuild/hw-tests/api-demo/53736c5@@api-demo-core0.elf@exe -Ibuild/hw-tests/api-demo/53736c5@@api-demo-core1.elf@exe -Ibuild/../hw-tests/bmatest -Ibuild/hw-tests/bmatest/ -Ibuild/hw-tests/bmatest/9cb7b92@@bmatest.elf@exe -Ibuild/../hw-tests/bmetest -Ibuild/hw-tests/bmetest/ -Ibuild/hw-tests/bmetest/6886391@@bmetest.elf@exe -Ibuild/../hw-tests/dual-core -Ibuild/hw-tests/dual-core/ -Ibuild/hw-tests/dual-core/b5198ad@@dual-core0.elf@exe -Ibuild/hw-tests/dual-core/b5198ad@@dual-core1.elf@exe -Ibuild/../hw-tests/ecgtest -Ibuild/hw-tests/ecgtest/ -Ibuild/hw-tests/ecgtest/8ae72c4@@ecgtest.elf@exe -Ibuild/../hw-tests/hello-freertos -Ibuild/../hw-tests/hello-freertos/./ -Ibuild/hw-tests/hello-freertos/ -Ibuild/hw-tests/hello-freertos/./ -Ibuild/hw-tests/hello-freertos/b7270e9@@freertos-sdk@sta -Ibuild/hw-tests/hello-freertos/b7270e9@@hello-freertos.elf@exe -Ibuild/../hw-tests/hello-world -Ibuild/hw-tests/hello-world/ -Ibuild/hw-tests/hello-world/96b467b@@hello-world.elf@exe -Ibuild/../hw-tests/imutest -Ibuild/hw-tests/imutest/ -Ibuild/hw-tests/imutest/438301c@@imutest.elf@exe -Ibuild/../hw-tests/ips -Ibuild/hw-tests/ips/ -Ibuild/hw-tests/ips/3a8d6c1@@ips.elf@exe -Ibuild/../hw-tests/upy-minimal -Ibuild/hw-tests/upy-minimal/ -Ibuild/hw-tests/upy-minimal/59d35c7@@micropython@sta -Ibuild/hw-tests/upy-minimal/59d35c7@@upy-minimal.elf@exe -Ibuild/../lib/./card10/./ -Ibuild/../lib/card10 -Ibuild/lib/./card10/ -Ibuild/lib/./card10/./ -Ibuild/lib/./card10/7eaaaa5@@card10@sta -Ibuild/../lib/./gfx/./ -Ibuild/../lib/gfx -Ibuild/lib/./gfx/ -Ibuild/lib/./gfx/./ -Ibuild/lib/./gfx/2308dff@@gfx@sta -Ibuild/../lib/./gfx/./Fonts/ -Ibuild/../lib/./gfx/./GUI_DEV/ -Ibuild/../lib/./gfx/./LCD/ -Ibuild/../lib/./micropython/./micropython/ -Ibuild/../lib/./micropython/./micropython/extmod/ -Ibuild/../lib/./micropython/./micropython/lib/utils -Ibuild/../lib/sdk/Libraries/Boards/card10 -Ibuild/lib/./sdk/./Libraries/Boards/card10/ -Ibuild/lib/./sdk/./Libraries/Boards/card10/9eeeac4@@board-card10@sta -Ibuild/../lib/./sdk/./Libraries/Boards/card10/../Include/ -Ibuild/../lib/./sdk/./Libraries/Boards/card10/./Include/ -Ibuild/../lib/sdk/Libraries/CMSIS/Device/Maxim/MAX32665 -Ibuild/lib/./sdk/./Libraries/CMSIS/Device/Maxim/MAX32665/ -Ibuild/lib/./sdk/./Libraries/CMSIS/Device/Maxim/MAX32665/a500f70@@max32665-startup-core0@sta -Ibuild/lib/./sdk/./Libraries/CMSIS/Device/Maxim/MAX32665/a500f70@@max32665-startup-core1@sta -Ibuild/lib/./sdk/./Libraries/CMSIS/Device/Maxim/MAX32665/a500f70@@max32665-startup@sta -Ibuild/../lib/./sdk/./Libraries/FreeRTOS/../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI/ -Ibuild/../lib/./sdk/./Libraries/FreeRTOS/./Source/include/ -Ibuild/../lib/./sdk/./Libraries/FreeRTOS/./Source/portable/GCC/ARM_CM4F/ -Ibuild/../lib/sdk/Libraries/MAX32665PeriphDriver -Ibuild/lib/./sdk/./Libraries/MAX32665PeriphDriver/ -Ibuild/lib/./sdk/./Libraries/MAX32665PeriphDriver/0d96707@@PeriphDriver@sta -Ibuild/../lib/./sdk/./Libraries/MAX32665PeriphDriver/../CMSIS/Device/Maxim/MAX32665/Include/ -Ibuild/../lib/./sdk/./Libraries/MAX32665PeriphDriver/../CMSIS/Include/ -Ibuild/../lib/./sdk/./Libraries/MAX32665PeriphDriver/Include/ -Ibuild/../lib/vendor/Bosch/BHy1 -Ibuild/lib/./vendor/Bosch/BHy1/ -Ibuild/lib/./vendor/Bosch/BHy1/6298ab9@@bhy1@sta -Ibuild/../lib/./vendor/Bosch/BHy1/../../../card10/ -Ibuild/lib/./vendor/Bosch/BHy1/../../../card10/ -Ibuild/../lib/./vendor/Bosch/BHy1/./driver/inc/ -Ibuild/../lib/./vendor/Bosch/BHy1/./examples/firmware/ -Ibuild/../lib/./vendor/Bosch/BMA400/./ -Ibuild/../lib/vendor/Bosch/BMA400 -Ibuild/lib/./vendor/Bosch/BMA400/ -Ibuild/lib/./vendor/Bosch/BMA400/./ -Ibuild/lib/./vendor/Bosch/BMA400/b6b0216@@bma400@sta -Ibuild/../lib/./vendor/Bosch/BME680/./ -Ibuild/../lib/vendor/Bosch/BME680 -Ibuild/lib/./vendor/Bosch/BME680/ -Ibuild/lib/./vendor/Bosch/BME680/./ -Ibuild/lib/./vendor/Bosch/BME680/ef6f079@@bme680@sta -Ibuild/../lib/./vendor/Maxim/MAX77650/./ -Ibuild/../lib/vendor/Maxim/MAX77650 -Ibuild/lib/./vendor/Maxim/MAX77650/ -Ibuild/lib/./vendor/Maxim/MAX77650/./ -Ibuild/lib/./vendor/Maxim/MAX77650/cc369b8@@max77650@sta
[submodule "lib/micropython/micropython"]
path = lib/micropython/micropython
url = https://github.com/micropython/micropython.git
#!/bin/sh
set -xe
cd "$(dirname "$0")" || exit 1
cd "$(dirname "$0")"
test -d build/ && rm -r build/
git submodule update --init --recursive
git submodule update --init ./lib/micropython
meson --cross-file card10-cross.ini build/
set +x
......
#include <stdio.h>
#include "card10.h"
int main(void)
{
card10_init();
card10_diag();
printf("Staring core1 payload ...\n");
core1_start();
}
name = 'epicardium'
elf = executable(
name + '.elf',
'main.c',
dependencies: [libcard10, max32665_startup_core0],
link_whole: [max32665_startup_core0_lib, board_card10_lib],
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
],
)
custom_target(
name + '.bin',
build_by_default: true,
output: name + '.bin',
input: elf,
command: [build_image, '@INPUT@', '@OUTPUT0@'],
)
......@@ -7,3 +7,4 @@ subdir('hello-freertos/')
subdir('hello-world/')
subdir('imutest/')
subdir('ips/')
subdir('upy-minimal/')
file ../../build/hw-tests/upy-minimal/upy-minimal.elf
source ../../.gdbinit
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "py/compile.h"
#include "py/runtime.h"
#include "py/repl.h"
#include "py/gc.h"
#include "py/mperrno.h"
#include "lib/utils/pyexec.h"
#include "leds.h"
static char *stack_top;
#if MICROPY_ENABLE_GC
static char heap[4096];
#endif
int mp_hal_stdin_rx_chr(void);
int main(int argc, char **argv) {
int stack_dummy;
stack_top = (char*)&stack_dummy;
leds_init();
#if MICROPY_ENABLE_GC
gc_init(heap, heap + sizeof(heap));
#endif
mp_init();
pyexec_friendly_repl();
mp_deinit();
return 0;
}
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;
gc_collect_start();
gc_collect_root(&dummy, ((mp_uint_t)stack_top - (mp_uint_t)&dummy) / sizeof(mp_uint_t));
gc_collect_end();
gc_dump_info();
}
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
mp_raise_OSError(MP_ENOENT);
}
mp_import_stat_t mp_import_stat(const char *path) {
return MP_IMPORT_STAT_NO_EXIST;
}
mp_obj_t mp_builtin_open(size_t 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);
void nlr_jump_fail(void *val) {
while (1);
}
void NORETURN __fatal_error(const char *msg) {
while (1);
}
#ifndef NDEBUG
void MP_WEAK __assert_func(const char *file, int line, const char *func, const char *expr) {
printf("Assertion '%s' failed, at file %s:%d\n", expr, file, line);
__fatal_error("Assertion failed");
}
#endif
name = 'upy-minimal'
modsrc = files(
'modules/buzzer.c',
'modules/leds.c',
'modules/utime.c',
)
#################################
# MicroPython Generated Headers #
#################################
version_h = custom_target(
'mpversion.h',
output: 'mpversion.h',
command: [micropython_gen_version, '@OUTPUT@'],
)
modules_h = custom_target(
'moduledefs.h',
output: 'moduledefs.h',
input: [micropython_sources, modsrc],
command: [micropython_gen_modules, '@OUTPUT@', '@INPUT@'],
)
qstr_h = custom_target(
'qstrdefs.generated.h',
output: 'qstrdefs.generated.h',
input: ['modules/qstrdefs.h', micropython_sources],
depends: [modules_h, version_h],
command: [micropython_gen_qstr, meson.current_source_dir(), '@OUTPUT@', '@INPUT@'],
)
###################
# MicroPython Lib #
###################
upy = static_library(
'micropython',
micropython_sources,
micropython_additional_sources,
modules_h,
qstr_h,
version_h,
include_directories: micropython_includes,
)
executable(
name + '.elf',
'main.c',
'uart.c',
'systick.c',
modsrc,
qstr_h,
include_directories: micropython_includes,
dependencies: [libcard10, max32665_startup],
link_whole: [max32665_startup_lib, board_card10_lib],
link_with: upy,
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
],
)
#include "py/obj.h"
#include "py/runtime.h"
#include "py/builtin.h"
#include <stdio.h>
#include "gpio.h"
static const gpio_cfg_t motor_pin = {
PORT_0, PIN_8, GPIO_FUNC_OUT, GPIO_PAD_NONE
};
STATIC mp_obj_t buzzer_set(mp_obj_t state_obj)
{
if (state_obj == mp_const_true) {
printf("Buzzer ON!\n");
GPIO_OutSet(&motor_pin);
} else if (state_obj == mp_const_false){
printf("Buzzer OFF!\n");
GPIO_OutClr(&motor_pin);
} else {
mp_raise_TypeError("expected bool");
}
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(buzzer_set_obj, buzzer_set);
// Define all properties of the example module.
// Table entries are key/value pairs of the attribute name (a string)
// and the MicroPython object reference.
// All identifiers and strings are written as MP_QSTR_xxx and will be
// optimized to word-sized integers by the build system (interned strings).
STATIC const mp_rom_map_elem_t buzzer_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_buzzer) },
{ MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&buzzer_set_obj) },
};
STATIC MP_DEFINE_CONST_DICT(buzzer_module_globals, buzzer_module_globals_table);
// Define module object.
const mp_obj_module_t buzzer_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&buzzer_module_globals,
};
// Register the module to make it available in Python
MP_REGISTER_MODULE(MP_QSTR_buzzer, buzzer_module, MODULE_BUZZER_ENABLED);
#include "py/obj.h"
#include "py/runtime.h"
#include "py/builtin.h"
#include <stdio.h>
STATIC mp_obj_t mp_leds_set(size_t n_args, const mp_obj_t *args)
{
assert (n_args == 4);
int led = mp_obj_get_int (args[0]);
int r = mp_obj_get_int (args[1]);
int g = mp_obj_get_int (args[2]);
int b = mp_obj_get_int (args[3]);
if ( (0 > led || 256 < led) &&
(0 > r || 256 < r) &&
(0 > g || 256 < g) &&
(0 > b || 256 < b) )
{
mp_raise_ValueError("out of bounds");
}
printf("Set %u to (%x %x %x)\n", led, r, g, b);
leds_set (led, r, g, b);
leds_update ();
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(leds_set_obj, 4, 4, mp_leds_set);
STATIC mp_obj_t mp_leds_set_dim(mp_obj_t led_obj, mp_obj_t dim_obj)
{
int led = mp_obj_get_int (led_obj);
int dim = mp_obj_get_int (dim_obj);
if ( (0 > led || 256 < led) &&
(0 > dim || 256 < dim) )
{
mp_raise_ValueError("out of bounds");
}
leds_set_dim (led, dim);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(leds_set_dim_obj, mp_leds_set_dim);
// Define all properties of the example module.
// Table entries are key/value pairs of the attribute name (a string)
// and the MicroPython object reference.
// All identifiers and strings are written as MP_QSTR_xxx and will be
// optimized to word-sized integers by the build system (interned strings).
STATIC const mp_rom_map_elem_t leds_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_leds) },
{ MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&leds_set_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_dim), MP_ROM_PTR(&leds_set_dim_obj) },
};
STATIC MP_DEFINE_CONST_DICT(leds_module_globals, leds_module_globals_table);
// Define module object.
const mp_obj_module_t leds_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&leds_module_globals,
};
// Register the module to make it available in Python
MP_REGISTER_MODULE(MP_QSTR_leds, leds_module, MODULE_LEDS_ENABLED);
#include "py/mpconfig.h"
/* buzzer */
Q(buzzer)
/* leds */
Q(leds)
Q(set_dim)
/* utime */
Q(utime)
Q(sleep)
Q(sleep_ms)
Q(sleep_us)
Q(ticks_ms)
Q(ticks_us)
Q(ticks_cpu)
Q(ticks_add)
Q(ticks_diff)
#include <stdio.h>
#include <string.h>
#include "py/runtime.h"
#include "py/smallint.h"
#include "py/obj.h"
#include "lib/timeutils/timeutils.h"
#include "extmod/utime_mphal.h"
STATIC const mp_rom_map_elem_t time_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) },
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_utime_sleep_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_utime_sleep_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_utime_sleep_us_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&mp_utime_ticks_ms_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_us), MP_ROM_PTR(&mp_utime_ticks_us_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) },
};
STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);
const mp_obj_module_t mp_module_utime = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&time_module_globals,
};
// Register the module to make it available in Python
MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MODULE_UTIME_ENABLED);
#include <stdint.h>
// options to control how MicroPython is built
// You can disable the built-in MicroPython compiler by setting the following
// config option to 0. If you do this then you won't get a REPL prompt, but you
// will still be able to execute pre-compiled scripts, compiled with mpy-cross.
#define MICROPY_ENABLE_COMPILER (1)
#define MICROPY_QSTR_BYTES_IN_HASH (1)
// #define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
#define MICROPY_ALLOC_PATH_MAX (256)
#define MICROPY_ALLOC_PARSE_CHUNK_INIT (16)
#define MICROPY_EMIT_X64 (0)
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_COMP_MODULE_CONST (0)
#define MICROPY_COMP_CONST (0)
#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (0)
#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0)
#define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_GC_ALLOC_THRESHOLD (0)
#define MICROPY_HELPER_REPL (1)
#define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (1)
#define MICROPY_ENABLE_DOC_STRING (1)
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED)
#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0)
#define MICROPY_PY_ASYNC_AWAIT (0)
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1)
#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
#define MICROPY_PY_BUILTINS_ENUMERATE (1)
#define MICROPY_PY_BUILTINS_FILTER (1)
#define MICROPY_PY_BUILTINS_FROZENSET (1)
#define MICROPY_PY_BUILTINS_REVERSED (1)
#define MICROPY_PY_BUILTINS_SET (1)
#define MICROPY_PY_BUILTINS_SLICE (1)
#define MICROPY_PY_BUILTINS_PROPERTY (1)
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
#define MICROPY_PY_BUILTINS_STR_COUNT (1)
#define MICROPY_PY_BUILTINS_STR_OP_MODULO (0)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_PY___FILE__ (0)
#define MICROPY_PY_GC (0)
#define MICROPY_PY_ARRAY (1)
#define MICROPY_PY_ATTRTUPLE (1)
#define MICROPY_PY_COLLECTIONS (1)
#define MICROPY_PY_MATH (1)
#define MICROPY_PY_CMATH (1)
#define MICROPY_PY_IO (1)
#define MICROPY_PY_STRUCT (1)
#define MICROPY_PY_SYS (1)
#define MICROPY_MODULE_FROZEN_MPY (0)
#define MICROPY_CPYTHON_COMPAT (0)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MODULE_BUZZER_ENABLED (1)
#define MODULE_UTIME_ENABLED (1)
#define MODULE_LEDS_ENABLED (1)
// type definitions for the specific machine
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
// This port is intended to be 32-bit, but unfortunately, int32_t for
// different targets may be defined in different ways - either as int
// or as long. This requires different printf formatting specifiers
// to print such value. So, we avoid int32_t and use int directly.
#define UINT_FMT "%u"
#define INT_FMT "%d"
typedef int mp_int_t; // must be pointer size
typedef unsigned mp_uint_t; // must be pointer size
typedef long mp_off_t;
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
// extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \
{ MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) },
// We need to provide a declaration/definition of alloca()
#include <alloca.h>
#define MICROPY_HW_BOARD_NAME "card10"
#define MICROPY_HW_MCU_NAME "max32665"
#define MP_STATE_PORT MP_STATE_VM
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[8];
#pragma once
void mp_hal_set_interrupt_char(char c);
#include "py/mpconfig.h"
#include "mxc_delay.h"
void mp_hal_delay_ms(mp_uint_t ms) {
mxc_delay (ms * 1000); // TODO check return value
}
void mp_hal_delay_us(mp_uint_t us) {
mxc_delay (us); // TODO check return value
}
mp_uint_t mp_hal_ticks_ms(void) {
return 0;
}
mp_uint_t mp_hal_ticks_us(void) {
return 0;
}
mp_uint_t mp_hal_ticks_cpu(void) {
return 0;
}
#include <unistd.h>
#include "py/mpconfig.h"
#include "uart.h"
/*
* Core UART functions to implement for a port
*/
extern mxc_uart_regs_t * ConsoleUart;
// Receive single character
int mp_hal_stdin_rx_chr(void) {
return UART_ReadByte(ConsoleUart);
}
// Send string of given length
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
UART_Write(ConsoleUart, (uint8_t*)str, len);
}
void mp_hal_set_interrupt_char(char c) {
return;
}
......@@ -6,5 +6,7 @@ subdir('./vendor/Bosch/BMA400/')
subdir('./vendor/Maxim/MAX77650/')
subdir('./gfx/')
subdir('./micropython/')
subdir('./card10/')
subdir('./ff13/')
#!/usr/bin/env python3
# Usage: gen-modules.py <source path> <output.h> <input.c ...>
import sys
import os
def main():
# Get 'official' makemoduledefs.py
path = sys.argv[1] + "/micropython/py"
sys.path.insert(0, path)
import makemoduledefs
modules = set()
for source in sys.argv[3:]:
modules |= makemoduledefs.find_module_registrations(source)
stdout = sys.stdout
with open(sys.argv[2], "w") as f:
sys.stdout = f
makemoduledefs.generate_module_table_header(sorted(modules))
sys.stdout = stdout
try:
os.mkdir(os.path.dirname(sys.argv[2]) + "/genhdr")
except FileExistsError:
pass
linkname = os.path.dirname(sys.argv[2]) + "/genhdr/" + os.path.basename(sys.argv[2])
if os.path.exists(linkname):
os.unlink(linkname)
os.symlink(
"../" + os.path.basename(sys.argv[2]),
linkname,
)
if __name__ == "__main__":
main()
#!/bin/bash
set -e
PYTHON="$1"
SOURCE_DIR="$2"
PROJECT_SRC="$3"
OUTPUT="$4"
CUSTOM_QSTR="$5"
shift 5
OUTPUT_DIR="$(dirname "$OUTPUT")"
mkdir -p "$OUTPUT_DIR/genhdr"
ln -sfr "$OUTPUT" "$OUTPUT_DIR/genhdr/$(basename "$OUTPUT")"
# call gcc -E to generate qstr.i.last
gcc -E -DNO_QSTR -I"$SOURCE_DIR/micropython" -I"$PROJECT_SRC" -I"$OUTPUT_DIR" "$@" >"$OUTPUT_DIR/qstr.i.last"
# Generate qstr.split
"$PYTHON" "$SOURCE_DIR/micropython/py/makeqstrdefs.py" split \
"$OUTPUT_DIR/qstr.i.last" "$OUTPUT_DIR/qstr" "$OUTPUT_DIR/qstrdefs.collected.h" >/dev/null
# Generate qstr.collected.h
"$PYTHON" "$SOURCE_DIR/micropython/py/makeqstrdefs.py" cat \
"$OUTPUT_DIR/qstr.i.last" "$OUTPUT_DIR/qstr" "$OUTPUT_DIR/qstrdefs.collected.h" >/dev/null
# Preprocess Header ... I did not come up with this, this is code copied from
# the official make file. Seriously.
cat "$SOURCE_DIR/micropython/py/qstrdefs.h" "$CUSTOM_QSTR" "$OUTPUT_DIR/qstrdefs.collected.h" \
| sed 's/^Q(.*)/"&"/' \
| gcc -E -DNO_QSTR -I"$SOURCE_DIR/micropython" -I"$PROJECT_SRC" -I"$OUTPUT_DIR" - \
| sed 's/^\"\(Q(.*)\)\"/\1/' \
>"$OUTPUT_DIR/qstrdefs.preprocessed.h"
# Call makeqstrdata
"$PYTHON" "$SOURCE_DIR/micropython/py/makeqstrdata.py" "$OUTPUT_DIR/qstrdefs.preprocessed.h" >"$OUTPUT"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment