Merge pull request #441 from tannewt/samd_reenable

Create supervisor module.
crypto-aes
Dan Halbert 5 years ago committed by GitHub
commit ea4b08de20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -290,18 +290,14 @@ int __attribute__((used)) main(void) {
bool first_run = true;
for (;;) {
if (!skip_repl) {
// The REPL mode can change, or it can request a reload.
bool autoreload_on = autoreload_is_enabled();
autoreload_disable();
autoreload_suspend();
new_status_color(REPL_RUNNING);
if (pyexec_mode_kind == PYEXEC_MODE_RAW_REPL) {
exit_code = pyexec_raw_repl();
} else {
exit_code = pyexec_friendly_repl();
}
if (autoreload_on) {
autoreload_enable();
}
autoreload_resume();
reset_port();
reset_board();
reset_mp();

@ -221,7 +221,6 @@ SRC_C = \
tick.c \
usb.c \
usb_mass_storage.c \
bindings/samd/__init__.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
lib/oofatfs/ff.c \
@ -314,6 +313,7 @@ SRC_BINDINGS_ENUMS = \
digitalio/Pull.c \
help.c \
math/__init__.c \
supervisor/__init__.c \
util.c
SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \

@ -168,7 +168,7 @@ extern const struct _mp_obj_module_t cpy_nvm_module;
extern const struct _mp_obj_module_t neopixel_write_module;
extern const struct _mp_obj_module_t uheap_module;
extern const struct _mp_obj_module_t ustack_module;
extern const struct _mp_obj_module_t samd_module;
extern const struct _mp_obj_module_t supervisor_module;
extern const struct _mp_obj_module_t gamepad_module;
extern const struct _mp_obj_module_t touchio_module;
extern const struct _mp_obj_module_t usb_hid_module;
@ -216,7 +216,6 @@ extern const struct _mp_obj_module_t usb_hid_module;
// { MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module },
// { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module },
// { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module },
// { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module },
#define MICROPY_PORT_BUILTIN_MODULES \
@ -228,6 +227,7 @@ extern const struct _mp_obj_module_t usb_hid_module;
{ MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_struct), (mp_obj_t)&struct_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module },
EXTRA_BUILTIN_MODULES

@ -32,6 +32,7 @@ Module / Port SAMD21 SAMD21 Express ESP8266
`random` **Yes** **Yes** **Yes**
`storage` **Yes** **Yes** **Yes**
`struct` **Yes** **Yes** **Yes**
`supervisor` **Yes** **Yes** No
`time` **Yes** **Yes** **Yes**
`touchio` **Yes** **Yes** No
`uheap` Debug Debug Debug

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2016-2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -28,11 +28,11 @@
#include "supervisor/shared/autoreload.h"
#include "supervisor/shared/rgb_led_status.h"
//| :mod:`samd` --- SAMD implementation settings
//| :mod:`supervisor` --- Supervisor settings
//| =================================================
//|
//| .. module:: samd
//| :synopsis: SAMD implementation settings
//| .. module:: supervisor
//| :synopsis: Supervisor settings
//| :platform: SAMD21
//|
@ -40,29 +40,29 @@
//|
//| Enable autoreload based on USB file write activity.
//|
STATIC mp_obj_t samd_enable_autoreload(void) {
STATIC mp_obj_t supervisor_enable_autoreload(void) {
autoreload_enable();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(samd_enable_autoreload_obj, samd_enable_autoreload);
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_enable_autoreload_obj, supervisor_enable_autoreload);
//| .. method:: disable_autoreload()
//|
//| Disable autoreload based on USB file write activity until
//| `enable_autoreload` is called.
//|
STATIC mp_obj_t samd_disable_autoreload(void) {
STATIC mp_obj_t supervisor_disable_autoreload(void) {
autoreload_disable();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(samd_disable_autoreload_obj, samd_disable_autoreload);
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload);
//| .. method:: set_rgb_status_brightness()
//|
//| Set brightness of status neopixel from 0-255
//| `set_rgb_status_brightness` is called.
//|
STATIC mp_obj_t samd_set_rgb_status_brightness(mp_obj_t lvl){
STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
// This must be int. If cast to uint8_t first, will never raise a ValueError.
int brightness_int = mp_obj_get_int(lvl);
if(brightness_int < 0 || brightness_int > 255){
@ -71,18 +71,18 @@ STATIC mp_obj_t samd_set_rgb_status_brightness(mp_obj_t lvl){
set_rgb_status_brightness((uint8_t)brightness_int);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(samd_set_rgb_status_brightness_obj, samd_set_rgb_status_brightness);
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness);
STATIC const mp_rom_map_elem_t samd_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_samd) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&samd_enable_autoreload_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&samd_disable_autoreload_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&samd_set_rgb_status_brightness_obj)},
STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable_autoreload), MP_ROM_PTR(&supervisor_disable_autoreload_obj)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj)},
};
STATIC MP_DEFINE_CONST_DICT(samd_module_globals, samd_module_globals_table);
STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table);
const mp_obj_module_t samd_module = {
const mp_obj_module_t supervisor_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&samd_module_globals,
.globals = (mp_obj_dict_t*)&supervisor_module_globals,
};

@ -31,13 +31,15 @@
volatile uint32_t autoreload_delay_ms = 0;
bool autoreload_enabled = false;
static bool autoreload_suspended = false;
volatile bool reload_next_character = false;
inline void autoreload_tick() {
if (autoreload_delay_ms == 0) {
return;
}
if (autoreload_delay_ms == 1 && autoreload_enabled && !reload_next_character) {
if (autoreload_delay_ms == 1 && autoreload_enabled &&
!autoreload_suspended && !reload_next_character) {
mp_keyboard_interrupt();
reload_next_character = true;
}
@ -53,6 +55,14 @@ void autoreload_disable() {
autoreload_enabled = false;
}
void autoreload_suspend() {
autoreload_suspended = true;
}
void autoreload_resume() {
autoreload_suspended = false;
}
inline bool autoreload_is_enabled() {
return autoreload_enabled;
}

@ -39,4 +39,8 @@ void autoreload_enable(void);
void autoreload_disable(void);
bool autoreload_is_enabled(void);
// Temporarily turn it off. Used during the REPL.
void autoreload_suspend(void);
void autoreload_resume(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_AUTORELOAD_H

@ -1,3 +1,6 @@
import skip_if
skip_if.no_reverse_ops()
class A:
def __init__(self, v):

@ -1,4 +1,6 @@
import skip_if
# TODO(tannewt): Remove this when we add nvm support to 3.x
skip_if.always()
skip_if.board_not_in("metro_m0_express", "feather_m0_express", "circuitplayground_express")
import microcontroller

@ -27,6 +27,9 @@ def skip():
print("SKIP")
raise SystemExit
def always():
skip()
def no_reversed():
import builtins
if "reversed" not in dir(builtins):
@ -89,3 +92,13 @@ def no_slice_assign():
m2[1:3] = m1[0:2]
except TypeError:
skip()
def no_reverse_ops():
class Foo:
def __radd__(self, other):
pass
try:
5 + Foo()
except TypeError:
skip()

Loading…
Cancel
Save