I took the minimal set-up code that is at the bottom of the main.c file and moved everything but void stm32_init to a test.c and a test.h file. Then I created a new c-Module called Led and a function called turnOn. At the beginning of the c-Module I included test.h.
Code: Select all
#include "test.h"
[…]
STATIC mp_obj_t Led_turnOn(void) {
gpio_init(GPIOD, 14, GPIO_MODE_OUT, GPIO_PULL_NONE, 0);
gpio_high(GPIOD, 14);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(Led_turnOn_obj, Led_turnOn);
STATIC const mp_map_elem_t Eeprom_globals_table[]= {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_Led) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_turnOn), (mp_obj_t)&Led_turnOn_obj },
};
STATIC MP_DEFINE_CONST_DICT(Led_globals, Led_globals_table);
const mp_obj_module_t Led_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&Led_globals,
};
Is there something, that I have to do to make the board peripherals accessable after compiling?