Merge branch 'master' of https://github.com/adafruit/circuitpython into feature-i2c-gemma

This commit is contained in:
Matt Land 2018-05-16 17:55:43 -04:00
commit 0511becd55
19 changed files with 268 additions and 116 deletions

View File

@ -42,7 +42,11 @@ notifications:
before_script: before_script:
- sudo dpkg --add-architecture i386 - sudo dpkg --add-architecture i386
- sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system - |
sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system ||
sleep 30 ||
sudo apt-get install -y python3 gcc-multilib pkg-config libffi-dev libffi-dev:i386 qemu-system
- ([[ -z "$TRAVIS_TEST" ]] || sudo apt-get install -y qemu-system) - ([[ -z "$TRAVIS_TEST" ]] || sudo apt-get install -y qemu-system)
- ([[ -z "$TRAVIS_BOARD" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2017q4-1~trusty3_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb)) - ([[ -z "$TRAVIS_BOARD" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2017q4-1~trusty3_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
- ([[ $TRAVIS_TEST != "qemu" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2017q4-1~trusty3_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb)) - ([[ $TRAVIS_TEST != "qemu" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2017q4-1~trusty3_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))

View File

@ -188,6 +188,10 @@ Exceptions
.. exception:: RuntimeError .. exception:: RuntimeError
.. exception:: ReloadException
`ReloadException` is used internally to deal with soft restarts.
.. exception:: StopIteration .. exception:: StopIteration
.. exception:: SyntaxError .. exception:: SyntaxError

4
main.c
View File

@ -168,7 +168,7 @@ bool start_mp(safe_mode_t safe_mode) {
reset_status_led(); reset_status_led();
if (result.return_code & PYEXEC_FORCED_EXIT) { if (result.return_code & PYEXEC_FORCED_EXIT) {
return reload_next_character; return reload_requested;
} }
} }
@ -180,7 +180,7 @@ bool start_mp(safe_mode_t safe_mode) {
#ifdef MICROPY_VM_HOOK_LOOP #ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP
#endif #endif
if (reload_next_character) { if (reload_requested) {
return true; return true;
} }

View File

@ -18,3 +18,48 @@
#include "internal_flash.h" #include "internal_flash.h"
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA06 1
#define IGNORE_PIN_PA07 1
#define IGNORE_PIN_PA08 1
#define IGNORE_PIN_PA09 1
#define IGNORE_PIN_PA10 1
#define IGNORE_PIN_PA11 1
#define IGNORE_PIN_PA12 1
#define IGNORE_PIN_PA13 1
#define IGNORE_PIN_PA14 1
#define IGNORE_PIN_PA15 1
#define IGNORE_PIN_PA16 1
#define IGNORE_PIN_PA17 1
#define IGNORE_PIN_PA18 1
#define IGNORE_PIN_PA19 1
#define IGNORE_PIN_PA20 1
#define IGNORE_PIN_PA21 1
#define IGNORE_PIN_PA22 1
#define IGNORE_PIN_PA27 1
#define IGNORE_PIN_PA28 1
#define IGNORE_PIN_PA30 1
#define IGNORE_PIN_PA31 1
#define IGNORE_PIN_PB01 1
#define IGNORE_PIN_PB02 1
#define IGNORE_PIN_PB03 1
#define IGNORE_PIN_PB04 1
#define IGNORE_PIN_PB05 1
#define IGNORE_PIN_PB06 1
#define IGNORE_PIN_PB07 1
#define IGNORE_PIN_PB08 1
#define IGNORE_PIN_PB09 1
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
#define IGNORE_PIN_PB12 1
#define IGNORE_PIN_PB13 1
#define IGNORE_PIN_PB14 1
#define IGNORE_PIN_PB15 1
#define IGNORE_PIN_PB16 1
#define IGNORE_PIN_PB17 1
#define IGNORE_PIN_PB22 1
#define IGNORE_PIN_PB23 1
#define IGNORE_PIN_PB30 1
#define IGNORE_PIN_PB31 1
#define IGNORE_PIN_PB00 1

View File

@ -15,5 +15,47 @@
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) #define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
#define IGNORE_PIN_PA03 1
#define IGNORE_PIN_PA04 1
#define IGNORE_PIN_PA11 1
#define IGNORE_PIN_PA12 1
#define IGNORE_PIN_PA13 1
#define IGNORE_PIN_PA14 1
#define IGNORE_PIN_PA15 1
#define IGNORE_PIN_PA16 1
#define IGNORE_PIN_PA17 1
#define IGNORE_PIN_PA18 1
#define IGNORE_PIN_PA19 1
#define IGNORE_PIN_PA20 1
#define IGNORE_PIN_PA21 1
#define IGNORE_PIN_PA22 1
#define IGNORE_PIN_PA23 1
#define IGNORE_PIN_PA27 1
#define IGNORE_PIN_PA28 1
#define IGNORE_PIN_PA30 1
#define IGNORE_PIN_PA31 1
#define IGNORE_PIN_PB01 1
#define IGNORE_PIN_PB02 1
#define IGNORE_PIN_PB03 1
#define IGNORE_PIN_PB04 1
#define IGNORE_PIN_PB05 1
#define IGNORE_PIN_PB06 1
#define IGNORE_PIN_PB07 1
#define IGNORE_PIN_PB08 1
#define IGNORE_PIN_PB09 1
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
#define IGNORE_PIN_PB12 1
#define IGNORE_PIN_PB13 1
#define IGNORE_PIN_PB14 1
#define IGNORE_PIN_PB15 1
#define IGNORE_PIN_PB16 1
#define IGNORE_PIN_PB17 1
#define IGNORE_PIN_PB22 1
#define IGNORE_PIN_PB23 1
#define IGNORE_PIN_PB30 1
#define IGNORE_PIN_PB31 1
#define IGNORE_PIN_PB00 1
#define DEFAULT_I2C_BUS_SCL (&pin_PA09) #define DEFAULT_I2C_BUS_SCL (&pin_PA09)
#define DEFAULT_I2C_BUS_SDA (&pin_PA08) #define DEFAULT_I2C_BUS_SDA (&pin_PA08)

View File

@ -97,162 +97,162 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
// This maps MCU pin names to pin objects. // This maps MCU pin names to pin objects.
STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = {
// Pins in datasheet order. // Pins in datasheet order.
#ifdef PIN_PA00 #if defined(PIN_PA00) && !defined(IGNORE_PIN_PA00)
{ MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) }, { MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) },
#endif #endif
#ifdef PIN_PA01 #if defined(PIN_PA01) && !defined(IGNORE_PIN_PA01)
{ MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) },
#endif #endif
#ifdef PIN_PA02 #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
{ MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) },
#endif #endif
#ifdef PIN_PA03 #if defined(PIN_PA03) && !defined(IGNORE_PIN_PA03)
{ MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) },
#endif #endif
#ifdef PIN_PB04 #if defined(PIN_PB04) && !defined(IGNORE_PIN_PB04)
{ MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) }, { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) },
#endif #endif
#ifdef PIN_PB05 #if defined(PIN_PB05) && !defined(IGNORE_PIN_PB05)
{ MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) }, { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) },
#endif #endif
#ifdef PIN_PB06 #if defined(PIN_PB06) && !defined(IGNORE_PIN_PB06)
{ MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) }, { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) },
#endif #endif
#ifdef PIN_PB07 #if defined(PIN_PB07) && !defined(IGNORE_PIN_PB07)
{ MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) }, { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) },
#endif #endif
#ifdef PIN_PB08 #if defined(PIN_PB08) && !defined(IGNORE_PIN_PB08)
{ MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) }, { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) },
#endif #endif
#ifdef PIN_PB09 #if defined(PIN_PB09) && !defined(IGNORE_PIN_PB09)
{ MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) }, { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) },
#endif #endif
#ifdef PIN_PA04 #if defined(PIN_PA04) && !defined(IGNORE_PIN_PA04)
{ MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) }, { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) },
#endif #endif
#ifdef PIN_PA05 #if defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
{ MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) }, { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) },
#endif #endif
#ifdef PIN_PA06 #if defined(PIN_PA06) && !defined(IGNORE_PIN_PA06)
{ MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) },
#endif #endif
#ifdef PIN_PA07 #if defined(PIN_PA07) && !defined(IGNORE_PIN_PA07)
{ MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) },
#endif #endif
#ifdef PIN_PA08 #if defined(PIN_PA08) && !defined(IGNORE_PIN_PA08)
{ MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) },
#endif #endif
#ifdef PIN_PA09 #if defined(PIN_PA09) && !defined(IGNORE_PIN_PA09)
{ MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) }, { MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) },
#endif #endif
#ifdef PIN_PA10 #if defined(PIN_PA10) && !defined(IGNORE_PIN_PA10)
{ MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) },
#endif #endif
#ifdef PIN_PA11 #if defined(PIN_PA11) && !defined(IGNORE_PIN_PA11)
{ MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11) }, { MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11) },
#endif #endif
#ifdef PIN_PB10 #if defined(PIN_PB10) && !defined(IGNORE_PIN_PB10)
{ MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) },
#endif #endif
#ifdef PIN_PB11 #if defined(PIN_PB11) && !defined(IGNORE_PIN_PB11)
{ MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) },
#endif #endif
#ifdef PIN_PB12 #if defined(PIN_PB12) && !defined(IGNORE_PIN_PB12)
{ MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) },
#endif #endif
#ifdef PIN_PB13 #if defined(PIN_PB13) && !defined(IGNORE_PIN_PB13)
{ MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) }, { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) },
#endif #endif
#ifdef PIN_PB14 #if defined(PIN_PB14) && !defined(IGNORE_PIN_PB14)
{ MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) }, { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) },
#endif #endif
// Second page. // Second page.
#ifdef PIN_PB15 #if defined(PIN_PB15) && !defined(IGNORE_PIN_PB15)
{ MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) }, { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) },
#endif #endif
#ifdef PIN_PA12 #if defined(PIN_PA12) && !defined(IGNORE_PIN_PA12)
{ MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12) },
#endif #endif
#ifdef PIN_PA13 #if defined(PIN_PA13) && !defined(IGNORE_PIN_PA13)
{ MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) },
#endif #endif
#ifdef PIN_PA14 #if defined(PIN_PA14) && !defined(IGNORE_PIN_PA14)
{ MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) },
#endif #endif
#ifdef PIN_PA15 #if defined(PIN_PA15) && !defined(IGNORE_PIN_PA15)
{ MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) },
#endif #endif
#ifdef PIN_PA16 #if defined(PIN_PA16) && !defined(IGNORE_PIN_PA16)
{ MP_ROM_QSTR(MP_QSTR_PA16), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_PA16), MP_ROM_PTR(&pin_PA16) },
#endif #endif
#ifdef PIN_PA17 #if defined(PIN_PA17) && !defined(IGNORE_PIN_PA17)
{ MP_ROM_QSTR(MP_QSTR_PA17), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_PA17), MP_ROM_PTR(&pin_PA17) },
#endif #endif
#ifdef PIN_PA18 #if defined(PIN_PA18) && !defined(IGNORE_PIN_PA18)
{ MP_ROM_QSTR(MP_QSTR_PA18), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_PA18), MP_ROM_PTR(&pin_PA18) },
#endif #endif
#ifdef PIN_PA19 #if defined(PIN_PA19) && !defined(IGNORE_PIN_PA19)
{ MP_ROM_QSTR(MP_QSTR_PA19), MP_ROM_PTR(&pin_PA19) }, { MP_ROM_QSTR(MP_QSTR_PA19), MP_ROM_PTR(&pin_PA19) },
#endif #endif
#ifdef PIN_PB16 #if defined(PIN_PB16) && !defined(IGNORE_PIN_PB16)
{ MP_ROM_QSTR(MP_QSTR_PB16), MP_ROM_PTR(&pin_PB16) }, { MP_ROM_QSTR(MP_QSTR_PB16), MP_ROM_PTR(&pin_PB16) },
#endif #endif
#ifdef PIN_PB17 #if defined(PIN_PB17) && !defined(IGNORE_PIN_PB17)
{ MP_ROM_QSTR(MP_QSTR_PB17), MP_ROM_PTR(&pin_PB17) }, { MP_ROM_QSTR(MP_QSTR_PB17), MP_ROM_PTR(&pin_PB17) },
#endif #endif
#ifdef PIN_PA20 #if defined(PIN_PA20) && !defined(IGNORE_PIN_PA20)
{ MP_ROM_QSTR(MP_QSTR_PA20), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_PA20), MP_ROM_PTR(&pin_PA20) },
#endif #endif
#ifdef PIN_PA21 #if defined(PIN_PA21) && !defined(IGNORE_PIN_PA21)
{ MP_ROM_QSTR(MP_QSTR_PA21), MP_ROM_PTR(&pin_PA21) }, { MP_ROM_QSTR(MP_QSTR_PA21), MP_ROM_PTR(&pin_PA21) },
#endif #endif
#ifdef PIN_PA22 #if defined(PIN_PA22) && !defined(IGNORE_PIN_PA22)
{ MP_ROM_QSTR(MP_QSTR_PA22), MP_ROM_PTR(&pin_PA22) }, { MP_ROM_QSTR(MP_QSTR_PA22), MP_ROM_PTR(&pin_PA22) },
#endif #endif
#ifdef PIN_PA23 #if defined(PIN_PA23) && !defined(IGNORE_PIN_PA23)
{ MP_ROM_QSTR(MP_QSTR_PA23), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_PA23), MP_ROM_PTR(&pin_PA23) },
#endif #endif
#ifdef PIN_PA24 #if defined(PIN_PA24) && !defined(IGNORE_PIN_PA24)
{ MP_ROM_QSTR(MP_QSTR_PA24), MP_ROM_PTR(&pin_PA24) }, { MP_ROM_QSTR(MP_QSTR_PA24), MP_ROM_PTR(&pin_PA24) },
#endif #endif
#ifdef PIN_PA25 #if defined(PIN_PA25) && !defined(IGNORE_PIN_PA25)
{ MP_ROM_QSTR(MP_QSTR_PA25), MP_ROM_PTR(&pin_PA25) }, { MP_ROM_QSTR(MP_QSTR_PA25), MP_ROM_PTR(&pin_PA25) },
#endif #endif
#ifdef PIN_PB22 #if defined(PIN_PB22) && !defined(IGNORE_PIN_PB22)
{ MP_ROM_QSTR(MP_QSTR_PB22), MP_ROM_PTR(&pin_PB22) }, { MP_ROM_QSTR(MP_QSTR_PB22), MP_ROM_PTR(&pin_PB22) },
#endif #endif
#ifdef PIN_PB23 #if defined(PIN_PB23) && !defined(IGNORE_PIN_PB23)
{ MP_ROM_QSTR(MP_QSTR_PB23), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_PB23), MP_ROM_PTR(&pin_PB23) },
#endif #endif
#ifdef PIN_PA27 #if defined(PIN_PA27) && !defined(IGNORE_PIN_PA27)
{ MP_ROM_QSTR(MP_QSTR_PA27), MP_ROM_PTR(&pin_PA27) }, { MP_ROM_QSTR(MP_QSTR_PA27), MP_ROM_PTR(&pin_PA27) },
#endif #endif
#ifdef PIN_PA28 #if defined(PIN_PA28) && !defined(IGNORE_PIN_PA28)
{ MP_ROM_QSTR(MP_QSTR_PA28), MP_ROM_PTR(&pin_PA28) }, { MP_ROM_QSTR(MP_QSTR_PA28), MP_ROM_PTR(&pin_PA28) },
#endif #endif
#ifdef PIN_PA30 #if defined(PIN_PA30) && !defined(IGNORE_PIN_PA30)
{ MP_ROM_QSTR(MP_QSTR_PA30), MP_ROM_PTR(&pin_PA30) }, { MP_ROM_QSTR(MP_QSTR_PA30), MP_ROM_PTR(&pin_PA30) },
#endif #endif
#ifdef PIN_PA31 #if defined(PIN_PA31) && !defined(IGNORE_PIN_PA31)
{ MP_ROM_QSTR(MP_QSTR_PA31), MP_ROM_PTR(&pin_PA31) }, { MP_ROM_QSTR(MP_QSTR_PA31), MP_ROM_PTR(&pin_PA31) },
#endif #endif
#ifdef PIN_PB30 #if defined(PIN_PB30) && !defined(IGNORE_PIN_PB30)
{ MP_ROM_QSTR(MP_QSTR_PB30), MP_ROM_PTR(&pin_PB30) }, { MP_ROM_QSTR(MP_QSTR_PB30), MP_ROM_PTR(&pin_PB30) },
#endif #endif
#ifdef PIN_PB31 #if defined(PIN_PB31) && !defined(IGNORE_PIN_PB31)
{ MP_ROM_QSTR(MP_QSTR_PB31), MP_ROM_PTR(&pin_PB31) }, { MP_ROM_QSTR(MP_QSTR_PB31), MP_ROM_PTR(&pin_PB31) },
#endif #endif
#ifdef PIN_PB00 #if defined(PIN_PB00) && !defined(IGNORE_PIN_PB00)
{ MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) }, { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) },
#endif #endif
#ifdef PIN_PB01 #if defined(PIN_PB01) && !defined(IGNORE_PIN_PB01)
{ MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) },
#endif #endif
#ifdef PIN_PB02 #if defined(PIN_PB02) && !defined(IGNORE_PIN_PB02)
{ MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) },
#endif #endif
#ifdef PIN_PB03 #if defined(PIN_PB03) && !defined(IGNORE_PIN_PB03)
{ MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) } { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) }
#endif #endif
}; };

View File

@ -28,7 +28,7 @@ int mp_hal_stdin_rx_chr(void) {
#ifdef MICROPY_VM_HOOK_LOOP #ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_LOOP
#endif #endif
// if (reload_next_character) { // if (reload_requested) {
// return CHAR_CTRL_D; // return CHAR_CTRL_D;
// } // }
if (usb_bytes_available()) { if (usb_bytes_available()) {

View File

@ -93,21 +93,21 @@ const mcu_pin_obj_t pin_## p_name = { \
// Pins in datasheet order. // Pins in datasheet order.
// NOTE(tannewt): TC wave out 0 is commented out because the first channel is // NOTE(tannewt): TC wave out 0 is commented out because the first channel is
// used to vary the 16 bit timer's frequency. // used to vary the 16 bit timer's frequency.
#ifdef PIN_PA00 #if defined(PIN_PA00) && !defined(IGNORE_PIN_PA00)
PIN(PA00, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH, PIN(PA00, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(1, 0), SERCOM(1, 0),
TCC(2, 0), TCC(2, 0),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA01 #if defined(PIN_PA01) && !defined(IGNORE_PIN_PA01)
PIN(PA01, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH, PIN(PA01, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(1, 1), SERCOM(1, 1),
TCC(2, 1), TCC(2, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA02 #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02)
// Touch is not allowed on A0 (PA02) on Circuit Playground Express. // Touch is not allowed on A0 (PA02) on Circuit Playground Express.
PIN(PA02, EXTINT_CHANNEL(2), ADC_INPUT(0), PIN(PA02, EXTINT_CHANNEL(2), ADC_INPUT(0),
#ifdef PA02_NO_TOUCH #ifdef PA02_NO_TOUCH
@ -120,140 +120,140 @@ PIN(PA02, EXTINT_CHANNEL(2), ADC_INPUT(0),
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA03 #if defined(PIN_PA03) && !defined(IGNORE_PIN_PA03)
PIN(PA03, EXTINT_CHANNEL(3), ADC_INPUT(1), TOUCH(1), PIN(PA03, EXTINT_CHANNEL(3), ADC_INPUT(1), TOUCH(1),
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB04 #if defined(PIN_PB04) && !defined(IGNORE_PIN_PB04)
PIN(PB04, EXTINT_CHANNEL(4), ADC_INPUT(12), TOUCH(10), PIN(PB04, EXTINT_CHANNEL(4), ADC_INPUT(12), TOUCH(10),
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB05 #if defined(PIN_PB05) && !defined(IGNORE_PIN_PB05)
PIN(PB05, EXTINT_CHANNEL(5), ADC_INPUT(13), TOUCH(11), PIN(PB05, EXTINT_CHANNEL(5), ADC_INPUT(13), TOUCH(11),
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB06 #if defined(PIN_PB06) && !defined(IGNORE_PIN_PB06)
PIN(PB06, EXTINT_CHANNEL(6), ADC_INPUT(14), TOUCH(12), PIN(PB06, EXTINT_CHANNEL(6), ADC_INPUT(14), TOUCH(12),
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB07 #if defined(PIN_PB07) && !defined(IGNORE_PIN_PB07)
PIN(PB07, EXTINT_CHANNEL(7), ADC_INPUT(15), TOUCH(13), PIN(PB07, EXTINT_CHANNEL(7), ADC_INPUT(15), TOUCH(13),
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB08 #if defined(PIN_PB08) && !defined(IGNORE_PIN_PB08)
PIN(PB08, EXTINT_CHANNEL(8), ADC_INPUT(2), TOUCH(14), PIN(PB08, EXTINT_CHANNEL(8), ADC_INPUT(2), TOUCH(14),
NO_SERCOM, NO_SERCOM,
SERCOM(4, 0), SERCOM(4, 0),
TC(4, 0), TC(4, 0),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB09 #if defined(PIN_PB09) && !defined(IGNORE_PIN_PB09)
PIN(PB09, EXTINT_CHANNEL(9), ADC_INPUT(3), TOUCH(15), PIN(PB09, EXTINT_CHANNEL(9), ADC_INPUT(3), TOUCH(15),
NO_SERCOM, NO_SERCOM,
SERCOM(4, 1), SERCOM(4, 1),
TC(4, 1), TC(4, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA04 #if defined(PIN_PA04) && !defined(IGNORE_PIN_PA04)
PIN(PA04, EXTINT_CHANNEL(4), ADC_INPUT(4), TOUCH(2), PIN(PA04, EXTINT_CHANNEL(4), ADC_INPUT(4), TOUCH(2),
NO_SERCOM, NO_SERCOM,
SERCOM(0, 0), SERCOM(0, 0),
TCC(0, 0), TCC(0, 0),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA05 #if defined(PIN_PA05) && !defined(IGNORE_PIN_PA05)
PIN(PA05, EXTINT_CHANNEL(5), ADC_INPUT(5), TOUCH(3), PIN(PA05, EXTINT_CHANNEL(5), ADC_INPUT(5), TOUCH(3),
NO_SERCOM, NO_SERCOM,
SERCOM(0, 1), SERCOM(0, 1),
TCC(0, 1), TCC(0, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA06 #if defined(PIN_PA06) && !defined(IGNORE_PIN_PA06)
PIN(PA06, EXTINT_CHANNEL(6), ADC_INPUT(6), TOUCH(4), PIN(PA06, EXTINT_CHANNEL(6), ADC_INPUT(6), TOUCH(4),
NO_SERCOM, NO_SERCOM,
SERCOM(0, 2), SERCOM(0, 2),
TCC(1, 0), TCC(1, 0),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA07 #if defined(PIN_PA07) && !defined(IGNORE_PIN_PA07)
PIN(PA07, EXTINT_CHANNEL(7), ADC_INPUT(7), TOUCH(5), PIN(PA07, EXTINT_CHANNEL(7), ADC_INPUT(7), TOUCH(5),
NO_SERCOM, NO_SERCOM,
SERCOM(0, 3), SERCOM(0, 3),
TCC(1, 1), TCC(1, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA08 #if defined(PIN_PA08) && !defined(IGNORE_PIN_PA08)
PIN(PA08, NO_EXTINT, ADC_INPUT(16), NO_TOUCH, PIN(PA08, NO_EXTINT, ADC_INPUT(16), NO_TOUCH,
SERCOM(0, 0), SERCOM(0, 0),
SERCOM(2, 0), SERCOM(2, 0),
TCC(0, 0), TCC(0, 0),
TCC(1, 2)); TCC(1, 2));
#endif #endif
#ifdef PIN_PA09 #if defined(PIN_PA09) && !defined(IGNORE_PIN_PA09)
PIN(PA09, EXTINT_CHANNEL(9), ADC_INPUT(17), NO_TOUCH, PIN(PA09, EXTINT_CHANNEL(9), ADC_INPUT(17), NO_TOUCH,
SERCOM(0, 1), SERCOM(0, 1),
SERCOM(2, 1), SERCOM(2, 1),
TCC(0, 1), TCC(0, 1),
TCC(1, 3)); TCC(1, 3));
#endif #endif
#ifdef PIN_PA10 #if defined(PIN_PA10) && !defined(IGNORE_PIN_PA10)
PIN(PA10, EXTINT_CHANNEL(10), ADC_INPUT(18), NO_TOUCH, PIN(PA10, EXTINT_CHANNEL(10), ADC_INPUT(18), NO_TOUCH,
SERCOM(0, 2), SERCOM(0, 2),
SERCOM(2, 2), SERCOM(2, 2),
TCC(1, 0), TCC(1, 0),
TCC(0, 2)); TCC(0, 2));
#endif #endif
#ifdef PIN_PA11 #if defined(PIN_PA11) && !defined(IGNORE_PIN_PA11)
PIN(PA11, EXTINT_CHANNEL(11), ADC_INPUT(19), NO_TOUCH, PIN(PA11, EXTINT_CHANNEL(11), ADC_INPUT(19), NO_TOUCH,
SERCOM(0, 3), SERCOM(0, 3),
SERCOM(2, 3), SERCOM(2, 3),
TCC(1, 1), TCC(1, 1),
TCC(0, 3)); TCC(0, 3));
#endif #endif
#ifdef PIN_PB10 #if defined(PIN_PB10) && !defined(IGNORE_PIN_PB10)
PIN(PB10, EXTINT_CHANNEL(10), NO_ADC, NO_TOUCH, PIN(PB10, EXTINT_CHANNEL(10), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(4, 2), SERCOM(4, 2),
TC(5, 0), TC(5, 0),
TCC(0, 4)); TCC(0, 4));
#endif #endif
#ifdef PIN_PB11 #if defined(PIN_PB11) && !defined(IGNORE_PIN_PB11)
PIN(PB11, EXTINT_CHANNEL(11), NO_ADC, NO_TOUCH, PIN(PB11, EXTINT_CHANNEL(11), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(4, 3), SERCOM(4, 3),
TC(5, 1), TC(5, 1),
TCC(0, 5)); TCC(0, 5));
#endif #endif
#ifdef PIN_PB12 #if defined(PIN_PB12) && !defined(IGNORE_PIN_PB12)
PIN(PB12, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH, PIN(PB12, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH,
SERCOM(4, 0), SERCOM(4, 0),
NO_SERCOM, NO_SERCOM,
TC(4, 0), TC(4, 0),
TCC(0, 6)); TCC(0, 6));
#endif #endif
#ifdef PIN_PB13 #if defined(PIN_PB13) && !defined(IGNORE_PIN_PB13)
PIN(PB13, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH, PIN(PB13, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH,
SERCOM(4, 1), SERCOM(4, 1),
NO_SERCOM, NO_SERCOM,
TC(4, 1), TC(4, 1),
TCC(0, 7)); TCC(0, 7));
#endif #endif
#ifdef PIN_PB14 #if defined(PIN_PB14) && !defined(IGNORE_PIN_PB14)
PIN(PB14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH, PIN(PB14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH,
SERCOM(4, 2), SERCOM(4, 2),
NO_SERCOM, NO_SERCOM,
@ -262,28 +262,28 @@ PIN(PB14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH,
#endif #endif
// Second page. // Second page.
#ifdef PIN_PB15 #if defined(PIN_PB15) && !defined(IGNORE_PIN_PB15)
PIN(PB15, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH, PIN(PB15, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH,
SERCOM(4, 3), SERCOM(4, 3),
NO_SERCOM, NO_SERCOM,
TC(5, 1), TC(5, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA12 #if defined(PIN_PA12) && !defined(IGNORE_PIN_PA12)
PIN(PA12, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH, PIN(PA12, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH,
SERCOM(2, 0), SERCOM(2, 0),
SERCOM(4, 0), SERCOM(4, 0),
TCC(2, 0), TCC(2, 0),
TCC(0, 6)); TCC(0, 6));
#endif #endif
#ifdef PIN_PA13 #if defined(PIN_PA13) && !defined(IGNORE_PIN_PA13)
PIN(PA13, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH, PIN(PA13, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH,
SERCOM(2, 1), SERCOM(2, 1),
SERCOM(4, 1), SERCOM(4, 1),
TCC(2, 1), TCC(2, 1),
TCC(0, 7)); TCC(0, 7));
#endif #endif
#ifdef PIN_PA14 #if defined(PIN_PA14) && !defined(IGNORE_PIN_PA14)
PIN(PA14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH, PIN(PA14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH,
SERCOM(2, 2), SERCOM(2, 2),
#ifdef SERCOM4 #ifdef SERCOM4
@ -294,7 +294,7 @@ PIN(PA14, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH,
TC(3, 0), TC(3, 0),
TCC(0, 4)); TCC(0, 4));
#endif #endif
#ifdef PIN_PA15 #if defined(PIN_PA15) && !defined(IGNORE_PIN_PA15)
PIN(PA15, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH, PIN(PA15, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH,
SERCOM(2, 3), SERCOM(2, 3),
#ifdef SERCOM4 #ifdef SERCOM4
@ -305,35 +305,35 @@ PIN(PA15, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH,
TC(3, 1), TC(3, 1),
TCC(0, 5)); TCC(0, 5));
#endif #endif
#ifdef PIN_PA16 #if defined(PIN_PA16) && !defined(IGNORE_PIN_PA16)
PIN(PA16, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH, PIN(PA16, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
SERCOM(1, 0), SERCOM(1, 0),
SERCOM(3, 0), SERCOM(3, 0),
TCC(2, 0), TCC(2, 0),
TCC(0, 6)); TCC(0, 6));
#endif #endif
#ifdef PIN_PA17 #if defined(PIN_PA17) && !defined(IGNORE_PIN_PA17)
PIN(PA17, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH, PIN(PA17, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
SERCOM(1, 1), SERCOM(1, 1),
SERCOM(3, 1), SERCOM(3, 1),
TCC(2, 1), TCC(2, 1),
TCC(0, 7)); TCC(0, 7));
#endif #endif
#ifdef PIN_PA18 #if defined(PIN_PA18) && !defined(IGNORE_PIN_PA18)
PIN(PA18, EXTINT_CHANNEL(2), NO_ADC, NO_TOUCH, PIN(PA18, EXTINT_CHANNEL(2), NO_ADC, NO_TOUCH,
SERCOM(1, 2), SERCOM(1, 2),
SERCOM(3, 2), SERCOM(3, 2),
TC(3, 0), TC(3, 0),
TCC(0, 2)); TCC(0, 2));
#endif #endif
#ifdef PIN_PA19 #if defined(PIN_PA19) && !defined(IGNORE_PIN_PA19)
PIN(PA19, EXTINT_CHANNEL(3), NO_ADC, NO_TOUCH, PIN(PA19, EXTINT_CHANNEL(3), NO_ADC, NO_TOUCH,
SERCOM(1, 3), SERCOM(1, 3),
SERCOM(3, 3), SERCOM(3, 3),
TC(3, 1), TC(3, 1),
TCC(0, 3)); TCC(0, 3));
#endif #endif
#ifdef PIN_PB16 #if defined(PIN_PB16) && !defined(IGNORE_PIN_PB16)
PIN(PB16, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH, PIN(PB16, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
SERCOM(5, 0), SERCOM(5, 0),
NO_SERCOM, NO_SERCOM,
@ -344,7 +344,7 @@ PIN(PB16, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
#endif #endif
TCC(0, 4)); TCC(0, 4));
#endif #endif
#ifdef PIN_PB17 #if defined(PIN_PB17) && !defined(IGNORE_PIN_PB17)
PIN(PB17, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH, PIN(PB17, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
SERCOM(5, 1), SERCOM(5, 1),
NO_SERCOM, NO_SERCOM,
@ -355,7 +355,7 @@ PIN(PB17, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
#endif #endif
TCC(0, 5)); TCC(0, 5));
#endif #endif
#ifdef PIN_PA20 #if defined(PIN_PA20) && !defined(IGNORE_PIN_PA20)
PIN(PA20, EXTINT_CHANNEL(4), NO_ADC, NO_TOUCH, PIN(PA20, EXTINT_CHANNEL(4), NO_ADC, NO_TOUCH,
SERCOM(5, 2), SERCOM(5, 2),
SERCOM(3, 2), SERCOM(3, 2),
@ -366,7 +366,7 @@ PIN(PA20, EXTINT_CHANNEL(4), NO_ADC, NO_TOUCH,
#endif #endif
TCC(0, 6)); TCC(0, 6));
#endif #endif
#ifdef PIN_PA21 #if defined(PIN_PA21) && !defined(IGNORE_PIN_PA21)
PIN(PA21, EXTINT_CHANNEL(5), NO_ADC, NO_TOUCH, PIN(PA21, EXTINT_CHANNEL(5), NO_ADC, NO_TOUCH,
SERCOM(5, 3), SERCOM(5, 3),
SERCOM(3, 3), SERCOM(3, 3),
@ -377,7 +377,7 @@ PIN(PA21, EXTINT_CHANNEL(5), NO_ADC, NO_TOUCH,
#endif #endif
TCC(0, 7)); TCC(0, 7));
#endif #endif
#ifdef PIN_PA22 #if defined(PIN_PA22) && !defined(IGNORE_PIN_PA22)
PIN(PA22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH, PIN(PA22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH,
SERCOM(3, 0), SERCOM(3, 0),
#ifdef SERCOM5 #ifdef SERCOM5
@ -388,7 +388,7 @@ PIN(PA22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH,
TC(4, 0), TC(4, 0),
TCC(0, 4)); TCC(0, 4));
#endif #endif
#ifdef PIN_PA23 #if defined(PIN_PA23) && !defined(IGNORE_PIN_PA23)
PIN(PA23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH, PIN(PA23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH,
SERCOM(3, 1), SERCOM(3, 1),
#ifdef SERCOM5 #ifdef SERCOM5
@ -399,7 +399,7 @@ PIN(PA23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH,
TC(4, 1), TC(4, 1),
TCC(0, 5)); TCC(0, 5));
#endif #endif
#ifdef PIN_PA24 #if defined(PIN_PA24) && !defined(IGNORE_PIN_PA24)
PIN(PA24, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH, PIN(PA24, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH,
SERCOM(3, 2), SERCOM(3, 2),
#ifdef SERCOM5 #ifdef SERCOM5
@ -410,7 +410,7 @@ PIN(PA24, EXTINT_CHANNEL(12), NO_ADC, NO_TOUCH,
TC(5, 0), TC(5, 0),
TCC(0, 2)); TCC(0, 2));
#endif #endif
#ifdef PIN_PA25 #if defined(PIN_PA25) && !defined(IGNORE_PIN_PA25)
PIN(PA25, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH, PIN(PA25, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH,
SERCOM(3, 3), SERCOM(3, 3),
#ifdef SERCOM5 #ifdef SERCOM5
@ -421,7 +421,7 @@ PIN(PA25, EXTINT_CHANNEL(13), NO_ADC, NO_TOUCH,
TC(5, 1), TC(5, 1),
TCC(1, 3)); TCC(1, 3));
#endif #endif
#ifdef PIN_PB22 #if defined(PIN_PB22) && !defined(IGNORE_PIN_PB22)
PIN(PB22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH, PIN(PB22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(5, 2), SERCOM(5, 2),
@ -432,7 +432,7 @@ PIN(PB22, EXTINT_CHANNEL(6), NO_ADC, NO_TOUCH,
#endif #endif
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB23 #if defined(PIN_PB23) && !defined(IGNORE_PIN_PB23)
PIN(PB23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH, PIN(PB23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(5, 3), SERCOM(5, 3),
@ -443,49 +443,49 @@ PIN(PB23, EXTINT_CHANNEL(7), NO_ADC, NO_TOUCH,
#endif #endif
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA27 #if defined(PIN_PA27) && !defined(IGNORE_PIN_PA27)
PIN(PA27, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH, PIN(PA27, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA28 #if defined(PIN_PA28) && !defined(IGNORE_PIN_PA28)
PIN(PA28, EXTINT_CHANNEL(8), NO_ADC, NO_TOUCH, PIN(PA28, EXTINT_CHANNEL(8), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
NO_SERCOM, NO_SERCOM,
NO_TIMER, NO_TIMER,
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA30 #if defined(PIN_PA30) && !defined(IGNORE_PIN_PA30)
PIN(PA30, EXTINT_CHANNEL(10), NO_ADC, NO_TOUCH, PIN(PA30, EXTINT_CHANNEL(10), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(1, 2), SERCOM(1, 2),
TCC(1, 0), TCC(1, 0),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PA31 #if defined(PIN_PA31) && !defined(IGNORE_PIN_PA31)
PIN(PA31, EXTINT_CHANNEL(11), NO_ADC, NO_TOUCH, PIN(PA31, EXTINT_CHANNEL(11), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(1, 3), SERCOM(1, 3),
TCC(1, 1), TCC(1, 1),
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB30 #if defined(PIN_PB30) && !defined(IGNORE_PIN_PB30)
PIN(PB30, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH, PIN(PB30, EXTINT_CHANNEL(14), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(5, 0), SERCOM(5, 0),
TCC(0, 0), TCC(0, 0),
TCC(1, 2)); TCC(1, 2));
#endif #endif
#ifdef PIN_PB31 #if defined(PIN_PB31) && !defined(IGNORE_PIN_PB31)
PIN(PB31, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH, PIN(PB31, EXTINT_CHANNEL(15), NO_ADC, NO_TOUCH,
NO_SERCOM, NO_SERCOM,
SERCOM(5, 1), SERCOM(5, 1),
TCC(0, 1), TCC(0, 1),
TCC(1, 3)); TCC(1, 3));
#endif #endif
#ifdef PIN_PB00 #if defined(PIN_PB00) && !defined(IGNORE_PIN_PB00)
PIN(PB00, EXTINT_CHANNEL(0), ADC_INPUT(8), TOUCH(6), PIN(PB00, EXTINT_CHANNEL(0), ADC_INPUT(8), TOUCH(6),
NO_SERCOM, NO_SERCOM,
SERCOM(5, 2), SERCOM(5, 2),
@ -496,7 +496,7 @@ PIN(PB00, EXTINT_CHANNEL(0), ADC_INPUT(8), TOUCH(6),
#endif #endif
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB01 #if defined(PIN_PB01) && !defined(IGNORE_PIN_PB01)
PIN(PB01, EXTINT_CHANNEL(1), ADC_INPUT(9), TOUCH(7), PIN(PB01, EXTINT_CHANNEL(1), ADC_INPUT(9), TOUCH(7),
NO_SERCOM, NO_SERCOM,
SERCOM(5, 3)), SERCOM(5, 3)),
@ -507,7 +507,7 @@ PIN(PB01, EXTINT_CHANNEL(1), ADC_INPUT(9), TOUCH(7),
#endif #endif
NO_TIMER; NO_TIMER;
#endif #endif
#ifdef PIN_PB02 #if defined(PIN_PB02) && !defined(IGNORE_PIN_PB02)
PIN(PB02, EXTINT_CHANNEL(2), ADC_INPUT(10), TOUCH(8), PIN(PB02, EXTINT_CHANNEL(2), ADC_INPUT(10), TOUCH(8),
NO_SERCOM, NO_SERCOM,
SERCOM(5, 0), SERCOM(5, 0),
@ -518,7 +518,7 @@ PIN(PB02, EXTINT_CHANNEL(2), ADC_INPUT(10), TOUCH(8),
#endif #endif
NO_TIMER); NO_TIMER);
#endif #endif
#ifdef PIN_PB03 #if defined(PIN_PB03) && !defined(IGNORE_PIN_PB03)
PIN(PB03, EXTINT_CHANNEL(3), ADC_INPUT(11), TOUCH(9), PIN(PB03, EXTINT_CHANNEL(3), ADC_INPUT(11), TOUCH(9),
NO_SERCOM, NO_SERCOM,
SERCOM(5, 1), SERCOM(5, 1),

View File

@ -700,6 +700,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_IndentationError), MP_ROM_PTR(&mp_type_IndentationError) }, { MP_ROM_QSTR(MP_QSTR_IndentationError), MP_ROM_PTR(&mp_type_IndentationError) },
{ MP_ROM_QSTR(MP_QSTR_IndexError), MP_ROM_PTR(&mp_type_IndexError) }, { MP_ROM_QSTR(MP_QSTR_IndexError), MP_ROM_PTR(&mp_type_IndexError) },
{ MP_ROM_QSTR(MP_QSTR_KeyboardInterrupt), MP_ROM_PTR(&mp_type_KeyboardInterrupt) }, { MP_ROM_QSTR(MP_QSTR_KeyboardInterrupt), MP_ROM_PTR(&mp_type_KeyboardInterrupt) },
{ MP_ROM_QSTR(MP_QSTR_ReloadException), MP_ROM_PTR(&mp_type_ReloadException) },
{ MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) }, { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) },
{ MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) }, { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) },
{ MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) }, { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) },

View File

@ -136,6 +136,9 @@ typedef struct _mp_state_vm_t {
mp_obj_exception_t mp_kbd_exception; mp_obj_exception_t mp_kbd_exception;
#endif #endif
// exception object of type ReloadException
mp_obj_exception_t mp_reload_exception;
// dictionary with loaded modules (may be exposed as sys.modules) // dictionary with loaded modules (may be exposed as sys.modules)
mp_obj_dict_t mp_loaded_modules_dict; mp_obj_dict_t mp_loaded_modules_dict;

View File

@ -590,6 +590,7 @@ extern const mp_obj_type_t mp_type_ImportError;
extern const mp_obj_type_t mp_type_IndentationError; extern const mp_obj_type_t mp_type_IndentationError;
extern const mp_obj_type_t mp_type_IndexError; extern const mp_obj_type_t mp_type_IndexError;
extern const mp_obj_type_t mp_type_KeyboardInterrupt; extern const mp_obj_type_t mp_type_KeyboardInterrupt;
extern const mp_obj_type_t mp_type_ReloadException;
extern const mp_obj_type_t mp_type_KeyError; extern const mp_obj_type_t mp_type_KeyError;
extern const mp_obj_type_t mp_type_LookupError; extern const mp_obj_type_t mp_type_LookupError;
extern const mp_obj_type_t mp_type_MemoryError; extern const mp_obj_type_t mp_type_MemoryError;

View File

@ -249,6 +249,7 @@ const mp_obj_type_t mp_type_ ## exc_name = { \
// http://docs.python.org/3/library/exceptions.html // http://docs.python.org/3/library/exceptions.html
MP_DEFINE_EXCEPTION(SystemExit, BaseException) MP_DEFINE_EXCEPTION(SystemExit, BaseException)
MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException) MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
MP_DEFINE_EXCEPTION(ReloadException, BaseException)
MP_DEFINE_EXCEPTION(GeneratorExit, BaseException) MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
MP_DEFINE_EXCEPTION(Exception, BaseException) MP_DEFINE_EXCEPTION(Exception, BaseException)
#if MICROPY_PY_ASYNC_AWAIT #if MICROPY_PY_ASYNC_AWAIT

View File

@ -188,6 +188,7 @@ PY_O_BASENAME = \
objtype.o \ objtype.o \
objzip.o \ objzip.o \
opmethods.o \ opmethods.o \
reload.o \
sequence.o \ sequence.o \
stream.o \ stream.o \
binary.o \ binary.o \

16
py/reload.c Normal file
View File

@ -0,0 +1,16 @@
//
// Created by Roy Hooper on 2018-05-14.
//
#include "reload.h"
#include "py/mpstate.h"
void mp_raise_reload_exception(void) {
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception));
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
}

10
py/reload.h Normal file
View File

@ -0,0 +1,10 @@
//
// Created by Roy Hooper on 2018-05-14.
//
#ifndef CIRCUITPYTHON_RELOAD_H
#define CIRCUITPYTHON_RELOAD_H
void mp_raise_reload_exception(void);
#endif //CIRCUITPYTHON_RELOAD_H

View File

@ -84,6 +84,12 @@ void mp_init(void) {
MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj; MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
#endif #endif
MP_STATE_VM(mp_reload_exception).base.type = &mp_type_ReloadException;
MP_STATE_VM(mp_reload_exception).traceback_alloc = 0;
MP_STATE_VM(mp_reload_exception).traceback_len = 0;
MP_STATE_VM(mp_reload_exception).traceback_data = NULL;
MP_STATE_VM(mp_reload_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
// call port specific initialization if any // call port specific initialization if any
#ifdef MICROPY_PORT_INIT_FUNC #ifdef MICROPY_PORT_INIT_FUNC
MICROPY_PORT_INIT_FUNC; MICROPY_PORT_INIT_FUNC;

View File

@ -25,11 +25,16 @@
*/ */
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/reload.h"
#include "lib/utils/interrupt_char.h"
#include "supervisor/shared/autoreload.h" #include "supervisor/shared/autoreload.h"
#include "supervisor/shared/rgb_led_status.h" #include "supervisor/shared/rgb_led_status.h"
#include "shared-bindings/supervisor/__init__.h" #include "shared-bindings/supervisor/__init__.h"
#include "shared-bindings/supervisor/Runtime.h" #include "shared-bindings/supervisor/Runtime.h"
//| :mod:`supervisor` --- Supervisor settings //| :mod:`supervisor` --- Supervisor settings
//| ================================================= //| =================================================
//| //|
@ -91,12 +96,25 @@ STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){
} }
MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness); MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness);
//| .. method:: reload()
//|
//| Reload the main Python code and run it (equivalent to hitting Ctrl-D at the REPL).
//|
STATIC mp_obj_t supervisor_reload(void) {
reload_requested = true;
mp_raise_reload_exception();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);
STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, { 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_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_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) }, { MP_OBJ_NEW_QSTR(MP_QSTR_set_rgb_status_brightness), MP_ROM_PTR(&supervisor_set_rgb_status_brightness_obj) },
{ MP_ROM_QSTR(MP_QSTR_runtime), MP_ROM_PTR(&common_hal_supervisor_runtime_obj) }, { MP_ROM_QSTR(MP_QSTR_runtime), MP_ROM_PTR(&common_hal_supervisor_runtime_obj) },
{ MP_ROM_QSTR(MP_QSTR_reload), MP_ROM_PTR(&supervisor_reload_obj) },
}; };
STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table); STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table);

View File

@ -26,29 +26,29 @@
#include "autoreload.h" #include "autoreload.h"
#include "lib/utils/interrupt_char.h"
#include "py/mphal.h" #include "py/mphal.h"
#include "py/reload.h"
volatile uint32_t autoreload_delay_ms = 0; volatile uint32_t autoreload_delay_ms = 0;
bool autoreload_enabled = false; bool autoreload_enabled = false;
static bool autoreload_suspended = false; static bool autoreload_suspended = false;
volatile bool reload_next_character = false; volatile bool reload_requested = false;
inline void autoreload_tick() { inline void autoreload_tick() {
if (autoreload_delay_ms == 0) { if (autoreload_delay_ms == 0) {
return; return;
} }
if (autoreload_delay_ms == 1 && autoreload_enabled && if (autoreload_delay_ms == 1 && autoreload_enabled &&
!autoreload_suspended && !reload_next_character) { !autoreload_suspended && !reload_requested) {
mp_keyboard_interrupt(); mp_raise_reload_exception();
reload_next_character = true; reload_requested = true;
} }
autoreload_delay_ms--; autoreload_delay_ms--;
} }
void autoreload_enable() { void autoreload_enable() {
autoreload_enabled = true; autoreload_enabled = true;
reload_next_character = false; reload_requested = false;
} }
void autoreload_disable() { void autoreload_disable() {
@ -73,5 +73,5 @@ void autoreload_start() {
void autoreload_stop() { void autoreload_stop() {
autoreload_delay_ms = 0; autoreload_delay_ms = 0;
reload_next_character = false; reload_requested = false;
} }

View File

@ -29,7 +29,7 @@
#include <stdbool.h> #include <stdbool.h>
extern volatile bool reload_next_character; extern volatile bool reload_requested;
void autoreload_tick(void); void autoreload_tick(void);