[python] Restore the should_interrupt routine

This commit is contained in:
Romain Goyet
2018-04-11 10:27:18 +02:00
parent 28b9e8c301
commit 8aef4d996c
5 changed files with 22 additions and 20 deletions

View File

@@ -182,7 +182,7 @@ python/src/extmod/modurandom.o: SFLAGS += -DMP_QSTR_urandom="MP_QSTR_random"
port_objs += $(addprefix python/port/,\
port.o \
builtins.o\
interrupt_helper.o \
helpers.o \
modkandinsky.o \
modkandinsky_impl.o \
mphalport.o \

View File

@@ -1,10 +1,10 @@
#include "interrupt_helper.h"
#include "helpers.h"
#include <ion.h>
extern "C" {
#include "mphalport.h"
}
void shouldInterrupt() {
void micropython_port_should_interrupt() {
static int c = 0;
c++;
if (c%20000 != 0) {

16
python/port/helpers.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef PYTHON_PORT_HELPERS_H
#define PYTHON_PORT_HELPERS_H
#ifdef __cplusplus
extern "C" {
#endif
/* should_interrupt effectively does something once every 20000 calls. It checks
* if a key is down to raise an interruption flag. */
void micropython_port_should_interrupt();
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,17 +0,0 @@
#ifndef PYTHON_INTERRUPT_HELPER_H
#define PYTHON_INTERRUPT_HELPER_H
#ifdef __cplusplus
extern "C" {
#endif
/* shouldInterrupt effectively does something once every 20000 calls. It checks
* if a key is down to raise an interruption flag. */
void shouldInterrupt();
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,4 +1,5 @@
#include <stdint.h>
#include "helpers.h"
// options to control how Micro Python is built
@@ -55,6 +56,8 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_VM_HOOK_LOOP micropython_port_should_interrupt();
// type definitions for the specific machine
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))