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

feat(pycardium): Enable custom modules


Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 9d6cdd9c
No related branches found
No related tags found
No related merge requests found
name = 'pycardium'
modsrc = files(
'modules/utime.c',
)
#################################
......@@ -24,7 +25,7 @@ qstr_h = custom_target(
'qstrdefs.generated.h',
output: 'qstrdefs.generated.h',
input: [
# 'modules/qstrdefs.h',
'modules/qstrdefs.h',
'mpconfigport.h',
micropython_sources,
],
......@@ -54,8 +55,8 @@ executable(
mp_headers,
include_directories: micropython_includes,
dependencies: [max32665_startup_core1, board_card10, periphdriver, api_caller],
link_whole: [max32665_startup_core1_lib, board_card10_lib],
link_with: upy,
link_whole: [max32665_startup_core1_lib, board_card10_lib],
link_args: [
'-Wl,-Map=' + meson.current_build_dir() + '/' + name + '.map',
],
......
#include "py/mpconfig.h"
/* 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 "py/mpconfig.h"
#include "extmod/utime_mphal.h"
#include "mxc_delay.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)},
#if 0
/* TODO: Implement those */
{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)},
#endif
};
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);
......@@ -17,6 +17,10 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_PY_UTIME_MP_HAL (1)
/* Modules */
#define MODULE_UTIME_ENABLED (1)
/*
* This port is intended to be 32-bit, but unfortunately, int32_t for
......
......@@ -24,6 +24,20 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len)
epic_uart_write_str(str, len);
}
/******************************************************************************
* Time & Delay
*/
void mp_hal_delay_ms(mp_uint_t ms)
{
mxc_delay(ms * 1000);
}
void mp_hal_delay_us(mp_uint_t us)
{
mxc_delay(us);
}
/******************************************************************************
* Fatal Errors
*/
......
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