Commit 314a22e5 authored by schneider's avatar schneider

fix(interrupts): Add the callbacks to the list of root pointers

parent 0fd6d958
Pipeline #4477 passed with stages
in 45 seconds
......@@ -2,10 +2,12 @@
#include "api/caller.h"
#include "mphalport.h"
#include "card10-version.h"
#include "modules/interrupt.h"
#include "max32665.h"
#include "lib/utils/pyexec.h"
#include "lib/mp-readline/readline.h"
#include "py/gc.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
......@@ -45,6 +47,9 @@ int main(void)
mp_init();
readline_init0();
interrupt_init0();
/* request by badge.team */
mp_obj_list_init(mp_sys_path, 0);
mp_obj_list_append(mp_sys_path, MP_ROM_QSTR(MP_QSTR_));
......
......@@ -7,20 +7,22 @@
#include "py/obj.h"
#include "py/runtime.h"
// TODO: these should be intialized as mp_const_none
mp_obj_t callbacks[EPIC_INT_NUM] = {
0,
};
void interrupt_init0(void)
{
int id;
for (id = 0; id < EPIC_INT_NUM; id++) {
MP_STATE_PORT(interrupt_callbacks)[id] = NULL;
}
}
void epic_isr_default_handler(api_int_id_t id)
{
// TODO: check if id is out of rante
// TOOD: check against mp_const_none
mp_obj_t callback = MP_STATE_PORT(interrupt_callbacks)[id];
if (id < EPIC_INT_NUM) {
if (callbacks[id]) {
mp_sched_schedule(
callbacks[id], MP_OBJ_NEW_SMALL_INT(id)
);
if (callback) {
mp_sched_schedule(callback, MP_OBJ_NEW_SMALL_INT(id));
}
}
}
......@@ -35,7 +37,7 @@ mp_obj_t mp_interrupt_set_callback(mp_obj_t id_in, mp_obj_t callback_obj)
// TODO: throw error if id is out of range
if (id < EPIC_INT_NUM) {
callbacks[id] = callback_obj;
MP_STATE_PORT(interrupt_callbacks)[id] = callback_obj;
}
return mp_const_none;
......
......@@ -2,6 +2,8 @@
#include "py/obj.h"
void interrupt_init0(void);
mp_obj_t mp_interrupt_set_callback(mp_obj_t id_in, mp_obj_t callback_obj);
mp_obj_t mp_interrupt_enable_callback(mp_obj_t id_in);
mp_obj_t mp_interrupt_disable_callback(mp_obj_t id_in);
// TODO: we need this define, but the header is not found...
//#include "epicardium/epicardium.h"
#define EPIC_INT_NUM 9
/* Hardware Name */
#define MICROPY_HW_BOARD_NAME "card10"
#define MICROPY_HW_MCU_NAME "max32666"
......@@ -95,5 +99,6 @@ typedef long mp_off_t;
/* For some reason, we need to define readline history manually */
#define MICROPY_PORT_ROOT_POINTERS \
const char *readline_hist[16];
const char *readline_hist[16]; \
mp_obj_t interrupt_callbacks[EPIC_INT_NUM]; \
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