Skip to content

Commit 1ed0e45

Browse files
committed
Add i2cslave.I2CSlave bindings
1 parent b6822b8 commit 1ed0e45

6 files changed

Lines changed: 642 additions & 0 deletions

File tree

lib/utils/interrupt_char.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@ void mp_keyboard_interrupt(void) {
4747
#endif
4848
}
4949

50+
// Check to see if we've been CTRL-C'ed by autoreload or the user.
51+
bool mp_hal_is_interrupted(void) {
52+
return MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
53+
}
54+
5055
#endif

lib/utils/interrupt_char.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
#ifndef MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
2727
#define MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H
2828

29+
#include <stdbool.h>
30+
2931
extern int mp_interrupt_char;
3032
void mp_hal_set_interrupt_char(int c);
3133
void mp_keyboard_interrupt(void);
34+
bool mp_hal_is_interrupted(void);
3235

3336
#endif // MICROPY_INCLUDED_LIB_UTILS_INTERRUPT_CHAR_H

py/obj.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ typedef struct _mp_rom_obj_t { mp_const_obj_t o; } mp_rom_obj_t;
293293
#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) \
294294
const mp_obj_fun_builtin_var_t obj_name = \
295295
{{&mp_type_fun_builtin_var}, true, n_args_min, MP_OBJ_FUN_ARGS_MAX, .fun.kw = fun_name}
296+
#define MP_DEFINE_CONST_PROP_GET(obj_name, fun_name) \
297+
const mp_obj_fun_builtin_fixed_t fun_name##_obj = {{&mp_type_fun_builtin_1}, .fun._1 = fun_name}; \
298+
const mp_obj_property_t obj_name = { \
299+
.base.type = &mp_type_property, \
300+
.proxy = {(mp_obj_t)&fun_name##_obj, \
301+
(mp_obj_t)&mp_const_none_obj, \
302+
(mp_obj_t)&mp_const_none_obj}, }
296303

297304
// These macros are used to define constant map/dict objects
298305
// You can put "static" in front of the definition to make it local

0 commit comments

Comments
 (0)