Verified Commit 1ec76efa authored by Anne Jan Brouwer's avatar Anne Jan Brouwer 💬

Merge branch 'wip-bootstrap' of...

Merge branch 'wip-bootstrap' of git.card10.badge.events.ccc.de:card10/micropython into wip-bootstrap
parents 13597678 c3f20b00
Pipeline #306 failed with stage
in 1 minute and 50 seconds
file build/firmware.elf
target remote localhost:3333
define reset
mon mww 0x40000004 0x80000000
end
......@@ -18,6 +18,7 @@ INC += -I$(SDK_LOCATION)/Libraries/CMSIS/Device/Maxim/MAX32665/Include
INC += -I$(SDK_LOCATION)/Libraries/CMSIS/Include
INC += -I$(SDK_LOCATION)/Libraries/Boards/card10/Include
INC += -I$(SDK_LOCATION)/Libraries/Boards/Include
INC += -I$(SDK_LOCATION)/../lib/card10/
# CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
# CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
......@@ -44,13 +45,19 @@ LIBS =
SRC_C = \
main.c \
uart_core.c \
buzzer.c \
modutime.c \
systick.c \
lib/utils/printf.c \
lib/utils/stdout_helpers.c \
lib/utils/pyexec.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
OBJ = $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
SRC_QSTR += buzzer.c modutime.c
USER_C_MODULES += buzzer.c modutime.c
# SDK compilation hack
......@@ -82,7 +89,7 @@ SDK_BOARD_SRC = $(wildcard $(SDK_LOCATION)/Libraries/Boards/Source/*.c)
SDK_BOARD_OBJ = $(foreach src, $(SDK_BOARD_SRC), \
$(patsubst $(SDK_LOCATION)/Libraries/Boards/Source/%.c, $(BUILD)/sdk/board/%.o, $(src))\
)
BOARD_ADDITIONAL = board.o startup_max32665.o heap.o system_max32665.o
BOARD_ADDITIONAL = board.o startup_max32665.o heap.o system_max32665.o leds.o
SDK_BOARD_OBJ += $(foreach obj, $(BOARD_ADDITIONAL), $(BUILD)/sdk/board/$(obj))
.PHONY: board
......@@ -91,6 +98,10 @@ board: $(BUILD)/sdk/board $(SDK_BOARD_OBJ)
$(BUILD)/sdk/board:
@mkdir -p $(BUILD)/sdk/board
$(BUILD)/sdk/board/leds.o: $(SDK_LOCATION)/../lib/card10/leds.c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
$(BUILD)/sdk/board/board.o: $(SDK_LOCATION)/Libraries/Boards/card10/Source/board.c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
......
#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);
......@@ -8,6 +8,7 @@
#include "py/gc.h"
#include "py/mperrno.h"
#include "lib/utils/pyexec.h"
#include "leds.h"
static char *stack_top;
......@@ -20,6 +21,7 @@ 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));
......
#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);
......@@ -58,6 +58,9 @@
#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)
// type definitions for the specific machine
......
#include "py/mpconfig.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) {}
mp_uint_t mp_hal_ticks_us(void) {}
mp_uint_t mp_hal_ticks_cpu(void) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment