From a63555abc1ce07fe4e9420b5835865282adcd1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sun, 7 Oct 2018 15:37:57 +0200 Subject: [PATCH 01/42] py/builtinimport: Set __file__ on MPY modules This sets the __file__ property on MPY modules like how it's done on pure python modules. --- py/builtinimport.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/py/builtinimport.c b/py/builtinimport.c index fee875b608..6ed0a75940 100755 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -155,11 +155,9 @@ STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { #endif #if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY -STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code) { +STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, const char *filename) { #if MICROPY_PY___FILE__ - // TODO - //qstr source_name = lex->source_name; - //mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(source_name)); + mp_store_attr(module_obj, MP_QSTR___file__, MP_OBJ_NEW_QSTR(qstr_from_str(filename))); #endif // execute the module in its context @@ -222,7 +220,7 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { // its data) in the list of frozen files, execute it. #if MICROPY_MODULE_FROZEN_MPY if (frozen_type == MP_FROZEN_MPY) { - do_execute_raw_code(module_obj, modref); + do_execute_raw_code(module_obj, modref, file_str); return; } #endif @@ -235,7 +233,7 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { #if MICROPY_PERSISTENT_CODE_LOAD if (file_str[file->len - 3] == 'm') { mp_raw_code_t *raw_code = mp_raw_code_load_file(file_str); - do_execute_raw_code(module_obj, raw_code); + do_execute_raw_code(module_obj, raw_code, file_str); return; } #endif From b897603cfa6f0f37dea4e1f9592a78d34d809f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sun, 7 Oct 2018 15:54:36 +0200 Subject: [PATCH 02/42] py/objboundmeth: Support __func__ property as in CPython This gives access to the function underlying the bound method. Used in the converted CPython stdlib logging.Formatter class to handle overrriding a default converter method bound to a class variable. The method becomes bound when accessed from an instance of that class. I didn't investigate why CircuitPython turns it into a bound method. --- py/objboundmeth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/objboundmeth.c b/py/objboundmeth.c index b0df6a68a7..a05680d410 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -92,6 +92,9 @@ STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (attr == MP_QSTR___name__) { mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in); dest[0] = MP_OBJ_NEW_QSTR(mp_obj_fun_get_name(o->meth)); + } else if (attr == MP_QSTR___func__) { + mp_obj_bound_meth_t *o = MP_OBJ_TO_PTR(self_in); + dest[0] = o->meth; } } #endif From db4a8f5d1a4d26b36d58ab2017501f63bd1cbe03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Thu, 6 Sep 2018 23:07:00 +0200 Subject: [PATCH 03/42] modsys: exc_info: Add traceback Add traceback chain to sys.exec_info()[2]. No actual frame info is added, but just enough to recreate the printed exception traceback. Used by the unittest module which collects errors and failures and prints them at the end. --- py/builtinimport.c | 0 py/modsys.c | 2 +- py/obj.h | 1 + py/objexcept.c | 162 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 164 insertions(+), 1 deletion(-) mode change 100755 => 100644 py/builtinimport.c diff --git a/py/builtinimport.c b/py/builtinimport.c old mode 100755 new mode 100644 diff --git a/py/modsys.c b/py/modsys.c index e32841923f..68e048d91d 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -135,7 +135,7 @@ STATIC mp_obj_t mp_sys_exc_info(void) { t->items[0] = MP_OBJ_FROM_PTR(mp_obj_get_type(cur_exc)); t->items[1] = cur_exc; - t->items[2] = mp_const_none; + t->items[2] = mp_obj_exception_get_traceback_obj(cur_exc); return MP_OBJ_FROM_PTR(t); } MP_DEFINE_CONST_FUN_OBJ_0(mp_sys_exc_info_obj, mp_sys_exc_info); diff --git a/py/obj.h b/py/obj.h index 59cce08366..8b67728730 100644 --- a/py/obj.h +++ b/py/obj.h @@ -717,6 +717,7 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type); void mp_obj_exception_clear_traceback(mp_obj_t self_in); void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block); void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values); +mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in); mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); diff --git a/py/objexcept.c b/py/objexcept.c index 8bd6245a4c..1ddc2174e5 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -30,6 +30,7 @@ #include #include "py/objlist.h" +#include "py/objnamedtuple.h" #include "py/objstr.h" #include "py/objtuple.h" #include "py/objtype.h" @@ -531,3 +532,164 @@ void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values *values = self->traceback_data; } } + +#if MICROPY_PY_SYS_EXC_INFO +STATIC const mp_obj_namedtuple_type_t code_type_obj = { + .base = { + .base = { + .type = &mp_type_type + }, + .name = MP_QSTR_code, + .print = namedtuple_print, + .make_new = namedtuple_make_new, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .attr = namedtuple_attr, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, + .parent = &mp_type_tuple, + }, + .n_fields = 15, + .fields = { + MP_QSTR_co_argcount, + MP_QSTR_co_kwonlyargcount, + MP_QSTR_co_nlocals, + MP_QSTR_co_stacksize, + MP_QSTR_co_flags, + MP_QSTR_co_code, + MP_QSTR_co_consts, + MP_QSTR_co_names, + MP_QSTR_co_varnames, + MP_QSTR_co_freevars, + MP_QSTR_co_cellvars, + MP_QSTR_co_filename, + MP_QSTR_co_name, + MP_QSTR_co_firstlineno, + MP_QSTR_co_lnotab, + }, +}; + +STATIC mp_obj_t code_make_new(qstr file, qstr block) { + mp_obj_t elems[15] = { + mp_obj_new_int(0), // co_argcount + mp_obj_new_int(0), // co_kwonlyargcount + mp_obj_new_int(0), // co_nlocals + mp_obj_new_int(0), // co_stacksize + mp_obj_new_int(0), // co_flags + mp_obj_new_bytearray(0, NULL), // co_code + mp_obj_new_tuple(0, NULL), // co_consts + mp_obj_new_tuple(0, NULL), // co_names + mp_obj_new_tuple(0, NULL), // co_varnames + mp_obj_new_tuple(0, NULL), // co_freevars + mp_obj_new_tuple(0, NULL), // co_cellvars + MP_OBJ_NEW_QSTR(file), // co_filename + MP_OBJ_NEW_QSTR(block), // co_name + mp_obj_new_int(1), // co_firstlineno + mp_obj_new_bytearray(0, NULL), // co_lnotab + }; + + return namedtuple_make_new((const mp_obj_type_t*)&code_type_obj, 15, 0, elems); +} + +STATIC const mp_obj_namedtuple_type_t frame_type_obj = { + .base = { + .base = { + .type = &mp_type_type + }, + .name = MP_QSTR_frame, + .print = namedtuple_print, + .make_new = namedtuple_make_new, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .attr = namedtuple_attr, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, + .parent = &mp_type_tuple, + }, + .n_fields = 8, + .fields = { + MP_QSTR_f_back, + MP_QSTR_f_builtins, + MP_QSTR_f_code, + MP_QSTR_f_globals, + MP_QSTR_f_lasti, + MP_QSTR_f_lineno, + MP_QSTR_f_locals, + MP_QSTR_f_trace, + }, +}; + +STATIC mp_obj_t frame_make_new(mp_obj_t f_code, int f_lineno) { + mp_obj_t elems[8] = { + mp_const_none, // f_back + mp_obj_new_dict(0), // f_builtins + f_code, // f_code + mp_obj_new_dict(0), // f_globals + mp_obj_new_int(0), // f_lasti + mp_obj_new_int(f_lineno), // f_lineno + mp_obj_new_dict(0), // f_locals + mp_const_none, // f_trace + }; + + return namedtuple_make_new((const mp_obj_type_t*)&frame_type_obj, 8, 0, elems); +} + +STATIC const mp_obj_namedtuple_type_t traceback_type_obj = { + .base = { + .base = { + .type = &mp_type_type + }, + .name = MP_QSTR_traceback, + .print = namedtuple_print, + .make_new = namedtuple_make_new, + .unary_op = mp_obj_tuple_unary_op, + .binary_op = mp_obj_tuple_binary_op, + .attr = namedtuple_attr, + .subscr = mp_obj_tuple_subscr, + .getiter = mp_obj_tuple_getiter, + .parent = &mp_type_tuple, + }, + .n_fields = 4, + .fields = { + MP_QSTR_tb_frame, + MP_QSTR_tb_lasti, + MP_QSTR_tb_lineno, + MP_QSTR_tb_next, + }, +}; + +STATIC mp_obj_t traceback_from_values(size_t *values, mp_obj_t tb_next) { + int lineno = values[1]; + + mp_obj_t elems[4] = { + frame_make_new(code_make_new(values[0], values[2]), lineno), + mp_obj_new_int(0), + mp_obj_new_int(lineno), + tb_next, + }; + + return namedtuple_make_new((const mp_obj_type_t*)&traceback_type_obj, 4, 0, elems); +}; + +mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in) { + mp_obj_exception_t *self = MP_OBJ_TO_PTR(self_in); + + if (!mp_obj_is_exception_instance(self)) { + return mp_const_none; + } + + size_t n, *values; + mp_obj_exception_get_traceback(self, &n, &values); + if (n == 0) { + return mp_const_none; + } + + mp_obj_t tb_next = mp_const_none; + + for (size_t i = 0; i < n; i += 3) { + tb_next = traceback_from_values(&values[i], tb_next); + } + + return tb_next; +} +#endif From a1d539941dfd39aa2d6c54d527212a391e08d3c6 Mon Sep 17 00:00:00 2001 From: Carlos Date: Mon, 8 Oct 2018 22:05:30 -0500 Subject: [PATCH 04/42] Translation of strings on Unix directory --- locale/es.po | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/locale/es.po b/locale/es.po index 28d68a0135..ff5471c745 100644 --- a/locale/es.po +++ b/locale/es.po @@ -848,15 +848,15 @@ msgstr "Longitud de string UUID inválida" #: ports/unix/modffi.c:138 msgid "Unknown type" -msgstr "" +msgstr "Tipo desconocido" #: ports/unix/modffi.c:207 ports/unix/modffi.c:265 msgid "Error in ffi_prep_cif" -msgstr "" +msgstr "Error en ffi_prep_cif" #: ports/unix/modffi.c:270 msgid "ffi_prep_closure_loc" -msgstr "" +msgstr "ffi_prep_closure_loc" #: ports/unix/modffi.c:413 msgid "Don't know how to pass object to native function" @@ -865,30 +865,30 @@ msgstr "" #: ports/unix/modusocket.c:474 #, c-format msgid "[addrinfo error %d]" -msgstr "" +msgstr "[addrinfo error %d]" #: py/argcheck.c:44 msgid "function does not take keyword arguments" -msgstr "" +msgstr "la función no tiene argumentos por palabra clave" #: py/argcheck.c:54 py/bc.c:85 py/objnamedtuple.c:104 #, c-format msgid "function takes %d positional arguments but %d were given" -msgstr "" +msgstr "la función toma %d argumentos posicionales pero le fueron dados %d" #: py/argcheck.c:64 #, c-format msgid "function missing %d required positional arguments" -msgstr "" +msgstr "a la función le hacen falta %d argumentos posicionales requeridos" #: py/argcheck.c:72 #, c-format msgid "function expected at most %d arguments, got %d" -msgstr "" +msgstr "la función esperaba a lo sumo %d argumentos, tiene %d" #: py/argcheck.c:97 msgid "'%q' argument required" -msgstr "" +msgstr "argumento '%q' requerido" #: py/argcheck.c:122 msgid "extra positional arguments given" @@ -912,11 +912,11 @@ msgstr "" #: py/bc.c:197 py/bc.c:215 msgid "unexpected keyword argument" -msgstr "" +msgstr "argumento por palabra clave inesperado" #: py/bc.c:199 msgid "keywords must be strings" -msgstr "" +msgstr "palabras clave deben ser strings" #: py/bc.c:206 py/objnamedtuple.c:138 msgid "function got multiple values for argument '%q'" From b5e26130d79d1f1b05bb83c8baf4934cb23dd747 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 10 Oct 2018 11:21:35 -0700 Subject: [PATCH 05/42] Support rev D for the Trellis M4 Express --- ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h | 4 ++-- ports/atmel-samd/boards/trellis_m4_express/pins.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h index fbc5300e24..05f2be0bcb 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/trellis_m4_express/mpconfigboard.h @@ -3,7 +3,7 @@ #define CIRCUITPY_MCU_FAMILY samd51 -// This is for a purple prototype which is Rev C +// This is for Rev D #define MICROPY_HW_APA102_MOSI (&pin_PA01) #define MICROPY_HW_APA102_SCK (&pin_PA00) @@ -28,7 +28,7 @@ #include "external_flash/devices.h" #define EXTERNAL_FLASH_DEVICE_COUNT 1 -#define EXTERNAL_FLASH_DEVICES W25Q128JV_SQ +#define EXTERNAL_FLASH_DEVICES GD25Q64C #include "external_flash/external_flash.h" diff --git a/ports/atmel-samd/boards/trellis_m4_express/pins.c b/ports/atmel-samd/boards/trellis_m4_express/pins.c index 57abfeba4d..44ffc6eaf8 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/pins.c +++ b/ports/atmel-samd/boards/trellis_m4_express/pins.c @@ -15,6 +15,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB08) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB09) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_PA12) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_PA13) }, + // Key Grid columns { MP_OBJ_NEW_QSTR(MP_QSTR_COL0), MP_ROM_PTR(&pin_PA14) }, { MP_OBJ_NEW_QSTR(MP_QSTR_COL1), MP_ROM_PTR(&pin_PA15) }, From 1c953d44b03b9574595e07c341f8f41b2321a7e4 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Oct 2018 18:47:56 -0500 Subject: [PATCH 06/42] .travis.yml: move the esp-open-sdk SDK up a dir Otherwise, an error occurs when installing TRAVIS_SDK=esp8266 *AND* trying to do TRAVIS_TESTS=docs in the same sub-build, with an error like Warning, treated as error: .../icmp.h:77:undecodable source characters, replacing with "?" due to non-ASCII characters in some header file within the esp-open-sdk --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78fc863aa7..9985002b55 100755 --- a/.travis.yml +++ b/.travis.yml @@ -45,8 +45,8 @@ before_script: - (! var_search "${TRAVIS_SDK-}" nrf || sudo ports/nrf/drivers/bluetooth/download_ble_stack.sh) # For huzzah builds - - (! var_search "${TRAVIS_SDK-}" esp8266 || (wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar xavf xtensa-lx106-elf-standalone.tar.gz)) - - if var_search "${TRAVIS_SDK-}" esp8266 ; then PATH=$(readlink -f xtensa-lx106-elf/bin):$PATH; fi + - (! var_search "${TRAVIS_SDK-}" esp8266 || (wget https://github.com/jepler/esp-open-sdk/releases/download/2018-06-10/xtensa-lx106-elf-standalone.tar.gz && tar -C .. -xavf xtensa-lx106-elf-standalone.tar.gz)) + - if var_search "${TRAVIS_SDK-}" esp8266 ; then PATH=$(readlink -f ../xtensa-lx106-elf/bin):$PATH; fi # For coverage testing (upgrade is used to get latest urllib3 version) - ([[ -z "$TRAVIS_TESTS" ]] || sudo apt-get install -y python3-pip) From 6ff614caae1eacb3495b798278131295536d1f1f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Oct 2018 17:43:23 -0500 Subject: [PATCH 07/42] .travis.yml: reorganize to squeeze out a little more speed --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9985002b55..8f4a192353 100755 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,7 @@ git: # Put a representative board from each port or sub-port near the top # to determine more quickly whether that port is going to build or not. env: - - TRAVIS_TESTS="unix docs translations" - - TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056" TRAVIS_SDK=arm:nrf:esp8266 - # Group nrf builds together.. - - TRAVIS_BOARDS="pca10056 pca10059 feather_nrf52832 feather_nrf52840_express" TRAVIS_SDK=arm:nrf + - TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express" TRAVIS_SDK=arm:nrf:esp8266 # The rest of the M0/M4 boards, in arbitrary order. - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express" TRAVIS_SDK=arm From c7629bdd5616ee4f90d7ac8521521a56264b1e4b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 10 Oct 2018 19:24:45 -0500 Subject: [PATCH 08/42] .travis.yml: Comment on the rationale for the organization of the sub-builds --- .travis.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8f4a192353..65983fc92f 100755 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,22 @@ compiler: git: depth: 1 -# Put a representative board from each port or sub-port near the top -# to determine more quickly whether that port is going to build or not. +# Each item under 'env' is a separate Travis job to execute. +# They run in separate environments, so each one must take the time +# to clone the repository and submodules; to download and install SDKs, +# pip packages, and so forth. By gathering activities together in optimal +# ways, the "run time" and "total time" of the travis jobs can be minimized. +# +# Since at the time of writing Travis generally starts 5 or 6 jobs, the +# builds have been organized into 5 groups of *approximately* equal durations. +# Additionally, the jobs that need extra SDKs are also organized together. +# +# When adding new boards, take a look on the travis CI page +# https://travis-ci.org/adafruit/circuitpython to which build that installs +# that SDK is shortest and add it there. In the case of major re-organizations, +# just try to make the builds "about equal in run time" env: - TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express" TRAVIS_SDK=arm:nrf:esp8266 - # The rest of the M0/M4 boards, in arbitrary order. - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero" TRAVIS_SDK=arm @@ -51,7 +62,7 @@ before_script: - (! var_search "${TRAVIS_TESTS-}" docs || sudo pip install 'Sphinx<1.8.0' sphinx-rtd-theme recommonmark) - (! var_search "${TRAVIS_TESTS-}" translations || sudo pip3 install polib) - # report some good version numbers to the buil + # report some good version numbers to the build - gcc --version - (! var_search "${TRAVIS_SDK-}" elf || arm-none-eabi-gcc --version) - (! var_search "${TRAVIS_SDK-}" esp8266 || xtensa-lx106-elf-gcc --version) From 88af5815ee976d26b79041575e3ae6487ab91038 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 13 Oct 2018 09:51:29 -0700 Subject: [PATCH 09/42] Increase clone depth (#1247) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65983fc92f..d4f21a398d 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: c compiler: - gcc git: - depth: 1 + depth: 6 # Each item under 'env' is a separate Travis job to execute. # They run in separate environments, so each one must take the time From f1028b5f964117fdcca2e35c479026da4153b505 Mon Sep 17 00:00:00 2001 From: Paul Sajna Date: Sat, 13 Oct 2018 10:17:13 -0700 Subject: [PATCH 10/42] add pin def for BAT --- ports/atmel-samd/boards/feather_m0_adalogger/pins.c | 1 + ports/atmel-samd/boards/feather_m0_basic/pins.c | 1 + ports/atmel-samd/boards/feather_m0_express/pins.c | 1 + ports/atmel-samd/boards/feather_m0_express_crickit/pins.c | 1 + ports/atmel-samd/boards/feather_m0_rfm69/pins.c | 1 + ports/atmel-samd/boards/feather_m0_rfm9x/pins.c | 1 + ports/atmel-samd/boards/feather_m0_supersized/pins.c | 1 + ports/atmel-samd/boards/feather_m4_express/pins.c | 1 + ports/atmel-samd/boards/hallowing_m0_express/pins.c | 2 +- ports/atmel-samd/boards/itsybitsy_m0_express/pins.c | 1 + ports/atmel-samd/boards/itsybitsy_m4_express/pins.c | 1 + ports/atmel-samd/boards/ugame10/pins.c | 2 +- 12 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/pins.c b/ports/atmel-samd/boards/feather_m0_adalogger/pins.c index da97bd253a..0e010e5bf0 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/pins.c +++ b/ports/atmel-samd/boards/feather_m0_adalogger/pins.c @@ -28,6 +28,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GREEN_LED), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_basic/pins.c b/ports/atmel-samd/boards/feather_m0_basic/pins.c index b5bd45a2f8..7cdd49e0a5 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/pins.c +++ b/ports/atmel-samd/boards/feather_m0_basic/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_express/pins.c b/ports/atmel-samd/boards/feather_m0_express/pins.c index 1a6aad45b7..d8456c83a7 100644 --- a/ports/atmel-samd/boards/feather_m0_express/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c b/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c index 1a6aad45b7..d8456c83a7 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/pins.c b/ports/atmel-samd/boards/feather_m0_rfm69/pins.c index 072eb4f88c..de8e3a3a53 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/pins.c +++ b/ports/atmel-samd/boards/feather_m0_rfm69/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c b/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c index 696d2239dd..049d495a38 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_supersized/pins.c b/ports/atmel-samd/boards/feather_m0_supersized/pins.c index 1a6aad45b7..d8456c83a7 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/pins.c +++ b/ports/atmel-samd/boards/feather_m0_supersized/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m4_express/pins.c b/ports/atmel-samd/boards/feather_m4_express/pins.c index b9b04e0acf..1ef0d933fb 100644 --- a/ports/atmel-samd/boards/feather_m4_express/pins.c +++ b/ports/atmel-samd/boards/feather_m4_express/pins.c @@ -28,6 +28,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index d1f8609ffa..4c4a62688d 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -55,7 +55,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PA28) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_PA27) }, - { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c index 25407bc147..ff0515b950 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c @@ -17,6 +17,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c index 2a89c3037e..f6aff8717f 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c @@ -37,6 +37,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/ugame10/pins.c b/ports/atmel-samd/boards/ugame10/pins.c index 87ace5e96f..e291e95b21 100644 --- a/ports/atmel-samd/boards/ugame10/pins.c +++ b/ports/atmel-samd/boards/ugame10/pins.c @@ -9,7 +9,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_MUTE), MP_ROM_PTR(&pin_PA23) }, - { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_UP), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_LEFT), MP_ROM_PTR(&pin_PA04) }, From 1447df3fa608d644564df72e4292541766370071 Mon Sep 17 00:00:00 2001 From: Paul Sajna Date: Sun, 14 Oct 2018 23:34:49 -0700 Subject: [PATCH 11/42] change BAT to BATTERY --- ports/atmel-samd/boards/feather_m0_adalogger/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_basic/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_express/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_express_crickit/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_rfm69/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_rfm9x/pins.c | 2 +- ports/atmel-samd/boards/feather_m0_supersized/pins.c | 2 +- ports/atmel-samd/boards/feather_m4_express/pins.c | 2 +- ports/atmel-samd/boards/hallowing_m0_express/pins.c | 2 +- ports/atmel-samd/boards/itsybitsy_m0_express/pins.c | 2 +- ports/atmel-samd/boards/itsybitsy_m4_express/pins.c | 2 +- ports/atmel-samd/boards/ugame10/pins.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/pins.c b/ports/atmel-samd/boards/feather_m0_adalogger/pins.c index 0e010e5bf0..0029bba1a3 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/pins.c +++ b/ports/atmel-samd/boards/feather_m0_adalogger/pins.c @@ -28,7 +28,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_GREEN_LED), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_basic/pins.c b/ports/atmel-samd/boards/feather_m0_basic/pins.c index 7cdd49e0a5..4400a253da 100644 --- a/ports/atmel-samd/boards/feather_m0_basic/pins.c +++ b/ports/atmel-samd/boards/feather_m0_basic/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_express/pins.c b/ports/atmel-samd/boards/feather_m0_express/pins.c index d8456c83a7..cd6c351d49 100644 --- a/ports/atmel-samd/boards/feather_m0_express/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c b/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c index d8456c83a7..cd6c351d49 100644 --- a/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c +++ b/ports/atmel-samd/boards/feather_m0_express_crickit/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_rfm69/pins.c b/ports/atmel-samd/boards/feather_m0_rfm69/pins.c index de8e3a3a53..7e14b3f251 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm69/pins.c +++ b/ports/atmel-samd/boards/feather_m0_rfm69/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c b/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c index 049d495a38..4e77b7fb97 100644 --- a/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c +++ b/ports/atmel-samd/boards/feather_m0_rfm9x/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m0_supersized/pins.c b/ports/atmel-samd/boards/feather_m0_supersized/pins.c index d8456c83a7..cd6c351d49 100644 --- a/ports/atmel-samd/boards/feather_m0_supersized/pins.c +++ b/ports/atmel-samd/boards/feather_m0_supersized/pins.c @@ -22,7 +22,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/feather_m4_express/pins.c b/ports/atmel-samd/boards/feather_m4_express/pins.c index 1ef0d933fb..5004254c52 100644 --- a/ports/atmel-samd/boards/feather_m4_express/pins.c +++ b/ports/atmel-samd/boards/feather_m4_express/pins.c @@ -28,7 +28,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PB01) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 4c4a62688d..d1f8609ffa 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -55,7 +55,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PA28) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_PA27) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c index ff0515b950..786c1a54c2 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c @@ -17,7 +17,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c index f6aff8717f..210b2387bb 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c @@ -37,7 +37,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB02) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/ugame10/pins.c b/ports/atmel-samd/boards/ugame10/pins.c index e291e95b21..87ace5e96f 100644 --- a/ports/atmel-samd/boards/ugame10/pins.c +++ b/ports/atmel-samd/boards/ugame10/pins.c @@ -9,7 +9,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_PA02) }, { MP_ROM_QSTR(MP_QSTR_MUTE), MP_ROM_PTR(&pin_PA23) }, - { MP_ROM_QSTR(MP_QSTR_BAT), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA10) }, { MP_ROM_QSTR(MP_QSTR_UP), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_LEFT), MP_ROM_PTR(&pin_PA04) }, From c103a05579e1d325dc66b9793681fbfa7cc397c6 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Mon, 15 Oct 2018 19:17:04 -0500 Subject: [PATCH 12/42] Add board Meow Meow by Electronic Cats https://github.com/ElectronicCats/MeowMeow --- ports/atmel-samd/boards/meowmeow/board.c | 38 ++++++++++++++++ .../boards/meowmeow/mpconfigboard.h | 36 ++++++++++++++++ .../boards/meowmeow/mpconfigboard.mk | 11 +++++ ports/atmel-samd/boards/meowmeow/pins.c | 43 +++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 ports/atmel-samd/boards/meowmeow/board.c create mode 100644 ports/atmel-samd/boards/meowmeow/mpconfigboard.h create mode 100644 ports/atmel-samd/boards/meowmeow/mpconfigboard.mk create mode 100644 ports/atmel-samd/boards/meowmeow/pins.c diff --git a/ports/atmel-samd/boards/meowmeow/board.c b/ports/atmel-samd/boards/meowmeow/board.c new file mode 100644 index 0000000000..881e15e0c5 --- /dev/null +++ b/ports/atmel-samd/boards/meowmeow/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Andrés Sabas for Electronic Cats + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" + +void board_init(void) +{ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h new file mode 100644 index 0000000000..3ce00b04f7 --- /dev/null +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h @@ -0,0 +1,36 @@ +#define MICROPY_HW_BOARD_NAME "Meow Meow" +#define MICROPY_HW_MCU_NAME "samd21g18" + + +// These are pins not to reset. +// PA24 and PA25 are USB. +#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25) +#define MICROPY_PORT_B (0) +#define MICROPY_PORT_C (0) + +#include "internal_flash.h" + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code. +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 + +#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000) + +#define CALIBRATE_CRYSTALLESS 1 + +// Explanation of how a user got into safe mode. +#define BOARD_USER_SAFE_MODE_ACTION "pressing both buttons at start up" + +#define DEFAULT_I2C_BUS_SCL (&pin_PA01) +#define DEFAULT_I2C_BUS_SDA (&pin_PA00) + +#define DEFAULT_SPI_BUS_SCK (&pin_PA15) +#define DEFAULT_SPI_BUS_MOSI (&pin_PA14) +#define DEFAULT_SPI_BUS_MISO (&pin_PA12) + +#define DEFAULT_UART_BUS_RX (&pin_PA11) +#define DEFAULT_UART_BUS_TX (&pin_PA10) + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk new file mode 100644 index 0000000000..31015ad175 --- /dev/null +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.mk @@ -0,0 +1,11 @@ +LD_FILE = boards/samd21x18-bootloader.ld +USB_VID = 0xBAB1 +USB_PID = 0x1209 +USB_PRODUCT = "Meow Meow" +USB_MANUFACTURER = "Electronic Cats" + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 \ No newline at end of file diff --git a/ports/atmel-samd/boards/meowmeow/pins.c b/ports/atmel-samd/boards/meowmeow/pins.c new file mode 100644 index 0000000000..59c51f4ebf --- /dev/null +++ b/ports/atmel-samd/boards/meowmeow/pins.c @@ -0,0 +1,43 @@ +#include "shared-bindings/board/__init__.h" + +#include "board_busses.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB22) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA30) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA31) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PB23) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); From f6c0a23fa8d93e0341af8ec1aee9554ce5696b91 Mon Sep 17 00:00:00 2001 From: Carlos Date: Mon, 15 Oct 2018 21:41:05 -0500 Subject: [PATCH 13/42] Translate strings on Mixer module --- locale/es.po | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/locale/es.po b/locale/es.po index 324fe0720e..60452ae348 100644 --- a/locale/es.po +++ b/locale/es.po @@ -2074,34 +2074,32 @@ msgid "" msgstr "" #: shared-bindings/audioio/Mixer.c:94 -#, fuzzy msgid "Invalid voice count" -msgstr "Dirección inválida." +msgstr "Cuenta de voces inválida" #: shared-bindings/audioio/Mixer.c:99 -#, fuzzy msgid "Invalid channel count" -msgstr "argumentos inválidos" +msgstr "Cuenta de canales inválida" #: shared-bindings/audioio/Mixer.c:103 -#, fuzzy msgid "Sample rate must be positive" -msgstr "STA debe estar activo" +msgstr "Sample rate debe ser positivo" #: shared-bindings/audioio/Mixer.c:107 -#, fuzzy msgid "bits_per_sample must be 8 or 16" -msgstr "bits debe ser 8" +msgstr "bits_per_sample debe ser 8 o 16" #: shared-bindings/audioio/RawSample.c:98 msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" msgstr "" +"sample_source buffer debe ser un bytearray o un array de tipo 'h', 'H', 'b' o" +"'B'" #: shared-bindings/audioio/RawSample.c:104 msgid "buffer must be a bytes-like object" -msgstr "" +msgstr "buffer debe de ser un objeto bytes-like" #: shared-bindings/audioio/WaveFile.c:78 #: shared-bindings/displayio/OnDiskBitmap.c:85 @@ -2387,31 +2385,31 @@ msgstr "" #: shared-module/audioio/Mixer.c:47 shared-module/audioio/WaveFile.c:117 msgid "Couldn't allocate first buffer" -msgstr "" +msgstr "No se pudo asignar el primer buffer" #: shared-module/audioio/Mixer.c:53 shared-module/audioio/WaveFile.c:123 msgid "Couldn't allocate second buffer" -msgstr "" +msgstr "No se pudo asignar el segundo buffer" #: shared-module/audioio/Mixer.c:82 msgid "Voice index too high" -msgstr "" +msgstr "Index de voz demasiado alto" #: shared-module/audioio/Mixer.c:85 msgid "The sample's sample rate does not match the mixer's" -msgstr "" +msgstr "El sample rate del sample no iguala al del mixer" #: shared-module/audioio/Mixer.c:88 msgid "The sample's channel count does not match the mixer's" -msgstr "" +msgstr "La cuenta de canales del sample no iguala a las del mixer" #: shared-module/audioio/Mixer.c:91 msgid "The sample's bits_per_sample does not match the mixer's" -msgstr "" +msgstr "Los bits_per_sample del sample no igualan a los del mixer" #: shared-module/audioio/Mixer.c:100 msgid "The sample's signedness does not match the mixer's" -msgstr "" +msgstr "El signo del sample no iguala al del mixer" #: shared-module/audioio/WaveFile.c:61 msgid "Invalid wave file" From 2262efc31155cfb498c5ecbfb64be16839cf4641 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 16 Oct 2018 11:05:02 -0400 Subject: [PATCH 14/42] PulseOut working --- ports/nrf/Makefile | 2 + ports/nrf/common-hal/analogio/AnalogOut.c | 9 +- ports/nrf/common-hal/board/__init__.c | 2 +- ports/nrf/common-hal/busio/I2C.c | 1 + ports/nrf/common-hal/busio/UART.c | 4 +- ports/nrf/common-hal/pulseio/PWMOut.c | 4 +- ports/nrf/common-hal/pulseio/PulseOut.c | 123 ++++++++++++++++++++-- ports/nrf/common-hal/pulseio/PulseOut.h | 6 +- ports/nrf/nrfx_config.h | 24 ++++- ports/nrf/peripherals/nrf/pins.h | 2 +- ports/nrf/peripherals/nrf/timers.c | 88 ++++++++++++++++ ports/nrf/peripherals/nrf/timers.h | 32 ++++++ ports/nrf/supervisor/port.c | 19 ++-- shared-bindings/pulseio/PulseOut.c | 7 +- 14 files changed, 281 insertions(+), 42 deletions(-) create mode 100644 ports/nrf/peripherals/nrf/timers.c create mode 100644 ports/nrf/peripherals/nrf/timers.h diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 93ca783760..8b84f43df4 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -90,6 +90,7 @@ LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc SRC_NRFX = $(addprefix nrfx/,\ drivers/src/nrfx_power.c \ drivers/src/nrfx_spim.c \ + drivers/src/nrfx_timer.c \ drivers/src/nrfx_twim.c \ drivers/src/nrfx_uarte.c \ ) @@ -123,6 +124,7 @@ SRC_C += \ peripherals/nrf/clocks.c \ peripherals/nrf/$(MCU_CHIP)/pins.c \ peripherals/nrf/$(MCU_CHIP)/power.c \ + peripherals/nrf/timers.c \ supervisor/shared/memory.c DRIVERS_SRC_C += $(addprefix modules/,\ diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c index dc0f53740d..7c60e324df 100644 --- a/ports/nrf/common-hal/analogio/AnalogOut.c +++ b/ports/nrf/common-hal/analogio/AnalogOut.c @@ -3,14 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2013, 2014 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. diff --git a/ports/nrf/common-hal/board/__init__.c b/ports/nrf/common-hal/board/__init__.c index 287f546d5c..350f2eea5e 100644 --- a/ports/nrf/common-hal/board/__init__.c +++ b/ports/nrf/common-hal/board/__init__.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2018 Dan Halbert 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 diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index c2a6cab702..4c42e58cdf 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -56,6 +56,7 @@ STATIC twim_peripheral_t twim_peripherals[] = { void i2c_reset(void) { for (size_t i = 0 ; i < MP_ARRAY_SIZE(twim_peripherals); i++) { + nrf_twim_disable(twim_peripherals[i].twim.p_twim); twim_peripherals[i].in_use = false; } } diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index b2dbb56a1f..b9e79381ab 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Damien P. George + * Copyright (c) 2018 Ha Thach 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 @@ -179,7 +179,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t self->rx_count = -1; _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt)); } - + // queue 1-byte transfer for rx_characters_available() if ( self->rx_count == 0 ) { self->rx_count = -1; diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c index 5d94bab794..f321f848d3 100644 --- a/ports/nrf/common-hal/pulseio/PWMOut.c +++ b/ports/nrf/common-hal/pulseio/PWMOut.c @@ -3,8 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * Copyright (c) 2016 Damien P. George + * Copyright (c) 2018 Dan Halbert 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 @@ -168,6 +167,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, self->frequency = frequency; self->variable_frequency = variable_frequency; + // Note this is standard, not strong drive. nrf_gpio_cfg_output(self->pin_number); // disable before mapping pin channel diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c index 3495f38f7d..044c4d3a8d 100644 --- a/ports/nrf/common-hal/pulseio/PulseOut.c +++ b/ports/nrf/common-hal/pulseio/PulseOut.c @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2016 Damien P. George + * Copyright (c) 2018 Dan Halbert 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 @@ -29,31 +29,136 @@ #include #include "mpconfigport.h" +#include "nrf/pins.h" +#include "nrf/timers.h" #include "py/gc.h" #include "py/runtime.h" - #include "shared-bindings/pulseio/PulseOut.h" +#include "shared-bindings/pulseio/PWMOut.h" +#include "supervisor/shared/translate.h" -//void pulse_finish(struct tc_module *const module) { -// -//} +// A single timer is shared amongst all PulseOut objects under the assumption that +// the code is single threaded. +static uint8_t refcount = 0; -void pulseout_reset() { +static nrfx_timer_t *timer = NULL; +static uint16_t *pulse_array = NULL; +static volatile uint16_t pulse_array_index = 0; +static uint16_t pulse_array_length; + +static void turn_on(pulseio_pulseout_obj_t *pulseout) { + pulseout->pwmout->pwm->PSEL.OUT[0] = pulseout->pwmout->pin_number; } -void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, const pulseio_pwmout_obj_t* carrier) { - mp_raise_NotImplementedError(NULL); +static void turn_off(pulseio_pulseout_obj_t *pulseout) { + // Disconnect pin from PWM. + pulseout->pwmout->pwm->PSEL.OUT[0] = 0xffffffff; + // Make sure pin is low. + nrf_gpio_pin_clear(pulseout->pwmout->pin_number); +} + +static void start_timer(void) { + nrfx_timer_clear(timer); + // true enables interrupt. + nrfx_timer_compare(timer, NRF_TIMER_CC_CHANNEL0, pulse_array[pulse_array_index], true); + nrfx_timer_resume(timer); +} + +static void pulseout_event_handler(nrf_timer_event_t event_type, void *p_context) { + pulseio_pulseout_obj_t *pulseout = (pulseio_pulseout_obj_t*) p_context; + if (event_type != NRF_TIMER_EVENT_COMPARE0) { + // Spurious event. + return; + } + nrfx_timer_pause(timer); + + pulse_array_index++; + + // No more pulses. Turn off output and don't restart. + if (pulse_array_index >= pulse_array_length) { + turn_off(pulseout); + return; + } + + // Alternate on and off, starting with on. + if (pulse_array_index % 2 == 0) { + turn_on(pulseout); + } else { + turn_off(pulseout); + } + + // Count up to the next given value. + start_timer(); +} + +void pulseout_reset() { + if (timer != NULL) { + nrf_peripherals_free_timer(timer); + } + refcount = 0; +} + +void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, + const pulseio_pwmout_obj_t* carrier) { + if (refcount == 0) { + timer = nrf_peripherals_allocate_timer(); + if (timer == NULL) { + mp_raise_RuntimeError(translate("All timers in use")); + } + } + refcount++; + + nrfx_timer_config_t timer_config = { + // PulseOut durations are in microseconds, so this is convenient. + .frequency = NRF_TIMER_FREQ_1MHz, + .mode = NRF_TIMER_MODE_TIMER, + .bit_width = NRF_TIMER_BIT_WIDTH_32, + .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY, + .p_context = self, + }; + + self->pwmout = carrier; + + nrfx_timer_init(timer, &timer_config, &pulseout_event_handler); + turn_off(self); } bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) { - return 1; + return self->pwmout == NULL; } void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) { + if (common_hal_pulseio_pulseout_deinited(self)) { + return; + } + turn_on(self); + self->pwmout = NULL; + refcount--; + if (refcount == 0) { + nrf_peripherals_free_timer(timer); + } } void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) { + pulse_array = pulses; + pulse_array_index = 0; + pulse_array_length = length; + nrfx_timer_enable(timer); + + turn_on(self); + // Count up to the next given value. + start_timer(); + + while(pulse_array_index < length) { + // Do other things while we wait. The interrupts will handle sending the + // signal. + #ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP + #endif + } + + nrfx_timer_disable(timer); } diff --git a/ports/nrf/common-hal/pulseio/PulseOut.h b/ports/nrf/common-hal/pulseio/PulseOut.h index 9a764e3023..42ec52e30e 100644 --- a/ports/nrf/common-hal/pulseio/PulseOut.h +++ b/ports/nrf/common-hal/pulseio/PulseOut.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2018 Dan Halbert 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,13 +28,13 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PULSEOUT_H #include "common-hal/microcontroller/Pin.h" +#include "common-hal/pulseio/PWMOut.h" #include "py/obj.h" typedef struct { mp_obj_base_t base; -// __IO PORT_PINCFG_Type *pincfg; - uint8_t pin; + const pulseio_pwmout_obj_t *pwmout; } pulseio_pulseout_obj_t; void pulseout_reset(void); diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h index f217cb0534..69b8e6a0cb 100644 --- a/ports/nrf/nrfx_config.h +++ b/ports/nrf/nrfx_config.h @@ -27,8 +27,10 @@ // Enable SPIM2 and SPIM3 (if available) #define NRFX_SPIM2_ENABLED 1 -#ifdef NRF52840_XXAA +#ifdef NRF_SPIM3 #define NRFX_SPIM3_ENABLED 1 +#else + #define NRFX_SPIM3_ENABLED 0 #endif @@ -59,4 +61,24 @@ #define NRFX_PWM3_ENABLED 0 #endif +// TIMERS +#define NRFX_TIMER_ENABLED 1 +// Don't enable TIMER0: it's used by the SoftDevice. +#define NRFX_TIMER1_ENABLED 1 +#define NRFX_TIMER2_ENABLED 1 + +#ifdef NRFX_TIMER3 +#define NRFX_TIMER3_ENABLED 1 +#else +#define NRFX_TIMER3_ENABLED 0 +#endif + +#ifdef NRFX_TIMER4 +#define NRFX_TIMER4_ENABLED 1 +#else +#define NRFX_TIMER4_ENABLED 0 +#endif + +#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7 + #endif // NRFX_CONFIG_H__ diff --git a/ports/nrf/peripherals/nrf/pins.h b/ports/nrf/peripherals/nrf/pins.h index 01aa9e956e..33462d7114 100644 --- a/ports/nrf/peripherals/nrf/pins.h +++ b/ports/nrf/peripherals/nrf/pins.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2013, 2014 Damien P. George + * Copyright (c) 2018 Dan Halbert 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 diff --git a/ports/nrf/peripherals/nrf/timers.c b/ports/nrf/peripherals/nrf/timers.c new file mode 100644 index 0000000000..0027d526f4 --- /dev/null +++ b/ports/nrf/peripherals/nrf/timers.c @@ -0,0 +1,88 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "common-hal/pulseio/PulseOut.h" + +#include + +#include "nrfx.h" +#include "nrfx_timer.h" + +#include "mpconfigport.h" +#include "py/runtime.h" + +STATIC nrfx_timer_t nrfx_timers[] = { +#if NRFX_CHECK(NRFX_TIMER0_ENABLED) + // Note that TIMER0 is reserved for use by the SoftDevice, so it should not usually be enabled. + NRFX_TIMER_INSTANCE(0), +#endif +#if NRFX_CHECK(NRFX_TIMER1_ENABLED) + NRFX_TIMER_INSTANCE(1), +#endif +#if NRFX_CHECK(NRFX_TIMER2_ENABLED) + NRFX_TIMER_INSTANCE(2), +#endif +#if NRFX_CHECK(NRFX_TIMER3_ENABLED) + NRFX_TIMER_INSTANCE(3), +#endif +#if NRFX_CHECK(NRFX_TIMER4_ENABLED) + NRFX_TIMER_INSTANCE(4), +#endif +}; + +static bool nrfx_timer_allocated[ARRAY_SIZE(nrfx_timers)]; + +void timers_reset(void) { + for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) { + nrfx_timer_uninit(&nrfx_timers[i]); + nrfx_timer_allocated[i] = false; + } +} + +// Returns a free nrfx_timer instance, and marks it as allocated. +// The caller should init as with the desired config. +// Returns NULL if no timer is available. +nrfx_timer_t* nrf_peripherals_allocate_timer(void) { + for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) { + if (!nrfx_timer_allocated[i]) { + nrfx_timer_allocated[i] = true; + return &nrfx_timers[i]; + } + } + return NULL; +} + +// Free a timer, which may or may not have been initialized. +void nrf_peripherals_free_timer(nrfx_timer_t* timer) { + for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) { + if (timer == &nrfx_timers[i]) { + nrfx_timer_allocated[i] = false; + // Safe to call even if not initialized. + nrfx_timer_uninit(timer); + return; + } + } +} diff --git a/ports/nrf/peripherals/nrf/timers.h b/ports/nrf/peripherals/nrf/timers.h new file mode 100644 index 0000000000..7d3815579a --- /dev/null +++ b/ports/nrf/peripherals/nrf/timers.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "nrfx.h" +#include "nrfx_timer.h" + +void timers_reset(void); +nrfx_timer_t* nrf_peripherals_allocate_timer(void); +void nrf_peripherals_free_timer(nrfx_timer_t* timer); diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index c858a36485..f98b05f5a4 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -31,12 +31,14 @@ #include "nrf/cache.h" #include "nrf/clocks.h" #include "nrf/power.h" +#include "nrf/timers.h" #include "shared-module/gamepad/__init__.h" #include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/I2C.h" #include "common-hal/busio/SPI.h" #include "common-hal/pulseio/PWMOut.h" +#include "common-hal/pulseio/PulseOut.h" #include "tick.h" safe_mode_t port_init(void) { @@ -81,6 +83,8 @@ void reset_port(void) { i2c_reset(); spi_reset(); pwmout_reset(); + pulseout_reset(); + timers_reset(); reset_all_pins(); } @@ -88,16 +92,7 @@ void reset_port(void) { void HardFault_Handler(void) { -// static volatile uint32_t reg; -// static volatile uint32_t reg2; -// static volatile uint32_t bfar; -// reg = SCB->HFSR; -// reg2 = SCB->CFSR; -// bfar = SCB->BFAR; -// for (int i = 0; i < 0; i++) -// { -// (void)reg; -// (void)reg2; -// (void)bfar; -// } + while (true) { + asm(""); + } } diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 1c97c37c36..e9834c12a7 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -47,7 +47,7 @@ //| //| .. class:: PulseOut(carrier) //| -//| Create a PulseOut object associated with the given PWM out experience. +//| Create a PulseOut object associated with the given PWMout object. //| //| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin. //| @@ -57,9 +57,10 @@ //| import pulseio //| import board //| -//| pwm = pulseio.PWMOut(board.D13, duty_cycle=2 ** 15) +//| # 50% duty cycle at 38kHz. +//| pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768) //| pulse = pulseio.PulseOut(pwm) -//| # on off on off on +//| # on off on off on //| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) //| pulse.send(pulses) //| From b3c7746a7f48d5fa47a26a745f39b9a3e9656d2b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 16 Oct 2018 11:09:37 -0400 Subject: [PATCH 15/42] fix copyright notice --- ports/nrf/common-hal/analogio/AnalogOut.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c index 7c60e324df..adafa15d5c 100644 --- a/ports/nrf/common-hal/analogio/AnalogOut.c +++ b/ports/nrf/common-hal/analogio/AnalogOut.c @@ -5,6 +5,13 @@ * * Copyright (c) 2018 Dan Halbert 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * From ab02a034f69eaed97f6bc4b49546ff726524a79d Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 16 Oct 2018 14:08:54 -0400 Subject: [PATCH 16/42] Update frozen libraries for 4.0.0-alpha.2 --- frozen/Adafruit_CircuitPython_BusDevice | 2 +- frozen/Adafruit_CircuitPython_CircuitPlayground | 2 +- frozen/Adafruit_CircuitPython_Crickit | 2 +- frozen/Adafruit_CircuitPython_DotStar | 2 +- frozen/Adafruit_CircuitPython_HID | 2 +- frozen/Adafruit_CircuitPython_IRRemote | 2 +- frozen/Adafruit_CircuitPython_LIS3DH | 2 +- frozen/Adafruit_CircuitPython_Motor | 2 +- frozen/Adafruit_CircuitPython_NeoPixel | 2 +- frozen/Adafruit_CircuitPython_Thermistor | 2 +- frozen/Adafruit_CircuitPython_seesaw | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 0791964147..97d4129b81 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 07919641470edb602585c6a91f7b8eacf17e664b +Subproject commit 97d4129b8117d177df2675839ec4081b3570838d diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index d0aa6dc56d..36ec7b371f 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit d0aa6dc56d66decfae92daced7384c1e3518a666 +Subproject commit 36ec7b371f1751961de6d2c910533618d931f109 diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index 44f52c5dac..bbf2d897ae 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit 44f52c5dacd9fc605565e5794e95c9a785aaf693 +Subproject commit bbf2d897ae116531bfa15af3bcb32b0123acc435 diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index af25424ee7..03c24157d4 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit af25424ee7dbebea3e5d77390c017018ffa52d36 +Subproject commit 03c24157d46672c723021686f7a838cfeb2db2ba diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index 5c2f6ef1ed..99c71a6c1e 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit 5c2f6ef1ed80f24b6a3878067d40350d3725e198 +Subproject commit 99c71a6c1ea00bc14f0a4507116ff216beafafbd diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index c29e10b590..ec11164ec6 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit c29e10b590efbdf06163897b49cd0c2bea82ad6e +Subproject commit ec11164ec6682094a48d0f9848d2c4c89c08f3bc diff --git a/frozen/Adafruit_CircuitPython_LIS3DH b/frozen/Adafruit_CircuitPython_LIS3DH index c4152a0d87..377910d5a9 160000 --- a/frozen/Adafruit_CircuitPython_LIS3DH +++ b/frozen/Adafruit_CircuitPython_LIS3DH @@ -1 +1 @@ -Subproject commit c4152a0d87a04903ae0e612eb381af440c9e28b3 +Subproject commit 377910d5a9bfbf833dfd3064f80c5b2ae0c78c9a diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index e0b709f171..00326214fc 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit e0b709f1710555da67705360870ba0d14ced7e06 +Subproject commit 00326214fc2ece8b31c07a654b192797e6a08043 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index e9f50cb667..4b9563d6a7 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit e9f50cb6678a1684591ee021b95a3c4b51786fee +Subproject commit 4b9563d6a74c6089d0ef5466975d11ef52851bca diff --git a/frozen/Adafruit_CircuitPython_Thermistor b/frozen/Adafruit_CircuitPython_Thermistor index 00f4ebca6c..1570b23f7a 160000 --- a/frozen/Adafruit_CircuitPython_Thermistor +++ b/frozen/Adafruit_CircuitPython_Thermistor @@ -1 +1 @@ -Subproject commit 00f4ebca6c740b76c1c464f83d514ac20b0600e1 +Subproject commit 1570b23f7a6d62e169d2fd15969e507a1da05374 diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 340cd17fad..e3e3021d85 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 340cd17fad0c29d3a70d6e298a30ecc753df054e +Subproject commit e3e3021d8578fde450511b47a085d9d56ab46741 From 6a1a2c7c7bb89d1ef54d1b6faea463eb5626b557 Mon Sep 17 00:00:00 2001 From: sabas1080 Date: Tue, 16 Oct 2018 13:51:37 -0500 Subject: [PATCH 17/42] add auto-built by Travis --- .travis.yml | 2 +- tools/build_adafruit_bins.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 65983fc92f..d51b034fb2 100755 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ git: env: - TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express" TRAVIS_SDK=arm:nrf:esp8266 - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express" TRAVIS_SDK=arm + - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero" TRAVIS_SDK=arm - TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express" TRAVIS_SDK=arm diff --git a/tools/build_adafruit_bins.sh b/tools/build_adafruit_bins.sh index 595d5ba5d2..291a1d46e3 100755 --- a/tools/build_adafruit_bins.sh +++ b/tools/build_adafruit_bins.sh @@ -27,6 +27,7 @@ itsybitsy_m0_express \ itsybitsy_m4_express \ metro_m0_express \ metro_m4_express \ +meowmeow \ pca10056 \ pca10059 \ pirkey_m0 \ From 089e2cc09901c049d30bac490a51ea49ea6d07d5 Mon Sep 17 00:00:00 2001 From: Paul Sajna Date: Tue, 16 Oct 2018 14:55:21 -0700 Subject: [PATCH 18/42] remove BATTERY from itsybitsy --- ports/atmel-samd/boards/itsybitsy_m0_express/pins.c | 1 - ports/atmel-samd/boards/itsybitsy_m4_express/pins.c | 1 - 2 files changed, 2 deletions(-) diff --git a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c index 786c1a54c2..25407bc147 100644 --- a/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m0_express/pins.c @@ -17,7 +17,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) }, { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) }, - { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PA07) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) }, { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) }, diff --git a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c index 210b2387bb..2a89c3037e 100644 --- a/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c +++ b/ports/atmel-samd/boards/itsybitsy_m4_express/pins.c @@ -37,7 +37,6 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PB03) }, { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PB02) }, - { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, From c209165d4357708c5d9ed08f150206cad36e6281 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 9 Oct 2018 13:56:02 -0700 Subject: [PATCH 19/42] Ramp values to and from a default value while active. This reduces the popping sound on initial playback of an audio sample. The M4 DAC has a pop on startup that cannot be prevented. It also does not allow readback so current values of the DAC are ignored. Fixes #1090 --- .../common-hal/analogio/AnalogOut.c | 12 --- .../atmel-samd/common-hal/audioio/AudioOut.c | 87 ++++++++++++++++++- .../atmel-samd/common-hal/audioio/AudioOut.h | 1 + ports/atmel-samd/supervisor/port.c | 2 +- shared-bindings/audioio/AudioOut.c | 9 +- shared-bindings/audioio/AudioOut.h | 2 +- 6 files changed, 93 insertions(+), 20 deletions(-) diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 2e42abdd45..8419927fe7 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -138,16 +138,4 @@ void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, } void analogout_reset(void) { - #if defined(SAMD21) && !defined(PIN_PA02) - return; - #endif - #ifdef SAMD21 - while (DAC->STATUS.reg & DAC_STATUS_SYNCBUSY) {} - #endif - #ifdef SAMD51 - while (DAC->SYNCBUSY.reg & DAC_SYNCBUSY_SWRST) {} - #endif - DAC->CTRLA.reg |= DAC_CTRLA_SWRST; - - // TODO(tannewt): Turn off the DAC clocks to save power. } diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 0592775a56..b15c642b53 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -33,6 +33,7 @@ #include "py/runtime.h" #include "common-hal/audioio/AudioOut.h" #include "shared-bindings/audioio/AudioOut.h" +#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" @@ -52,11 +53,73 @@ #include "samd/pins.h" #include "samd/timers.h" +#ifdef SAMD21 +static void ramp_value(uint16_t start, uint16_t end) { + start = DAC->DATA.reg; + int32_t diff = (int32_t) end - start; + int32_t step = 49; + int32_t steps = diff / step; + if (diff < 0) { + steps *= -1; + step *= -1; + } + for (int32_t i = 0; i < steps; i++) { + uint32_t value = start + step * i; + DAC->DATA.reg = value; + DAC->DATABUF.reg = value; + common_hal_mcu_delay_us(50); + #ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP + #endif + } +} +#endif + +#ifdef SAMD51 +static void ramp_value(uint16_t start, uint16_t end) { + int32_t diff = (int32_t) end - start; + int32_t step = 49; + int32_t steps = diff / step; + if (diff < 0) { + steps *= -1; + step *= -1; + } + + for (int32_t i = 0; i < steps; i++) { + uint16_t value = start + step * i; + DAC->DATA[0].reg = value; + DAC->DATABUF[0].reg = value; + DAC->DATA[1].reg = value; + DAC->DATABUF[1].reg = value; + + common_hal_mcu_delay_us(50); + #ifdef MICROPY_VM_HOOK_LOOP + MICROPY_VM_HOOK_LOOP + #endif + } +} +#endif + void audioout_reset(void) { + #if defined(SAMD21) && !defined(PIN_PA02) + return; + #endif + #ifdef SAMD21 + while (DAC->STATUS.reg & DAC_STATUS_SYNCBUSY) {} + #endif + #ifdef SAMD51 + while (DAC->SYNCBUSY.reg & DAC_SYNCBUSY_SWRST) {} + #endif + if (DAC->CTRLA.bit.ENABLE) { + ramp_value(0x8000, 0); + } + DAC->CTRLA.reg |= DAC_CTRLA_SWRST; + + // TODO(tannewt): Turn off the DAC clocks to save power. } void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, - const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel) { + const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value) { #ifdef SAMD51 bool dac_clock_enabled = hri_mclk_get_APBDMASK_DAC_bit(MCLK); #endif @@ -94,12 +157,10 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, if (right_channel != NULL) { claim_pin(right_channel); self->right_channel = right_channel; - gpio_set_pin_function(self->right_channel->number, GPIO_PIN_FUNCTION_B); audio_dma_init(&self->right_dma); } #endif self->left_channel = left_channel; - gpio_set_pin_function(self->left_channel->number, GPIO_PIN_FUNCTION_B); audio_dma_init(&self->left_dma); #ifdef SAMD51 @@ -118,6 +179,10 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, DAC->CTRLA.bit.SWRST = 1; while (DAC->CTRLA.bit.SWRST == 1) {} + // Make sure there are no outstanding access errors. (Reading DATA can cause this.) + #ifdef SAMD51 + PAC->INTFLAGD.reg = PAC_INTFLAGD_DAC; + #endif bool channel0_enabled = true; #ifdef SAMD51 @@ -159,6 +224,8 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, #endif #ifdef SAMD51 while (DAC->SYNCBUSY.bit.ENABLE == 1) {} + while (channel0_enabled && DAC->STATUS.bit.READY0 == 0) {} + while (channel1_enabled && DAC->STATUS.bit.READY1 == 0) {} #endif // Use a timer to coordinate when DAC conversions occur. @@ -220,13 +287,21 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, #ifdef SAMD51 connect_event_user_to_channel(EVSYS_ID_USER_DAC_START_1, channel); + if (right_channel != NULL) { + gpio_set_pin_function(self->right_channel->number, GPIO_PIN_FUNCTION_B); + } #define EVSYS_ID_USER_DAC_START EVSYS_ID_USER_DAC_START_0 #endif connect_event_user_to_channel(EVSYS_ID_USER_DAC_START, channel); + gpio_set_pin_function(self->left_channel->number, GPIO_PIN_FUNCTION_B); init_async_event_channel(channel, tc_gen_id); self->tc_to_dac_event_channel = channel; + // Ramp the DAC up. + self->default_value = default_value; + ramp_value(0, default_value); + // Leave the DMA setup to playback. } @@ -239,6 +314,9 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) { return; } + // Ramp the DAC down. + ramp_value(self->default_value, 0); + DAC->CTRLA.bit.ENABLE = 0; #ifdef SAMD21 while (DAC->STATUS.bit.SYNCBUSY == 1) {} @@ -381,6 +459,9 @@ void common_hal_audioio_audioout_stop(audioio_audioout_obj_t* self) { #ifdef SAMD51 audio_dma_stop(&self->right_dma); #endif + // Ramp the DAC to default. The start is ignored when the current value can be readback. + // Otherwise, we just set it immediately. + ramp_value(self->default_value, self->default_value); } bool common_hal_audioio_audioout_get_playing(audioio_audioout_obj_t* self) { diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.h b/ports/atmel-samd/common-hal/audioio/AudioOut.h index efbfe2a1d6..9e5a7390d5 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.h +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.h @@ -44,6 +44,7 @@ typedef struct { uint8_t tc_to_dac_event_channel; bool playing; + uint16_t default_value; } audioio_audioout_obj_t; void audioout_reset(void); diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 2349a74182..45b8ed1a4c 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -249,11 +249,11 @@ void reset_port(void) { } #if defined(EXPRESS_BOARD) && !defined(__SAMR21G18A__) + audio_dma_reset(); audioout_reset(); #if !defined(__SAMD51G19A__) && !defined(__SAMD51G18A__) i2sout_reset(); #endif - audio_dma_reset(); //pdmin_reset(); #endif #ifdef SAMD21 diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index db5b371e22..8c4b927855 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -43,13 +43,15 @@ //| //| AudioOut can be used to output an analog audio signal on a given pin. //| -//| .. class:: AudioOut(left_channel, right_channel=None) +//| .. class:: AudioOut(left_channel, *, right_channel=None, default_value=0x8000) //| //| Create a AudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). //| //| :param ~microcontroller.Pin left_channel: The pin to output the left channel to //| :param ~microcontroller.Pin right_channel: The pin to output the right channel to +//| :param int default_value: The default output value. Samples should start and end with this +//| value to prevent popping. //| //| Simple 8ksps 440 Hz sin wave:: //| @@ -95,10 +97,11 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar mp_arg_check_num(n_args, n_kw, 1, 2, true); mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); - enum { ARG_left_channel, ARG_right_channel }; + enum { ARG_left_channel, ARG_right_channel, ARG_default_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_right_channel, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = mp_const_none} }, + { MP_QSTR_default_value, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -117,7 +120,7 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar // create AudioOut object from the given pin audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t); self->base.type = &audioio_audioout_type; - common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin); + common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_default_value].u_int); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/audioio/AudioOut.h b/shared-bindings/audioio/AudioOut.h index 751473605d..d09a5c9caa 100644 --- a/shared-bindings/audioio/AudioOut.h +++ b/shared-bindings/audioio/AudioOut.h @@ -35,7 +35,7 @@ extern const mp_obj_type_t audioio_audioout_type; // left_channel will always be non-NULL but right_channel may be for mono output. void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, - const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel); + const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value); void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self); bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t* self); From 4eb1fe18e5dfa4df03625b7d009ffbea75ea8f63 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 17 Oct 2018 11:31:08 -0700 Subject: [PATCH 20/42] Tweaks from feedback: * default_value is now quiescent_value * Use step = -step format for sign switch * Add note about analogout_reset being empty --- .../atmel-samd/common-hal/analogio/AnalogOut.c | 1 + ports/atmel-samd/common-hal/audioio/AudioOut.c | 18 +++++++++--------- ports/atmel-samd/common-hal/audioio/AudioOut.h | 2 +- shared-bindings/audioio/AudioOut.c | 12 ++++++------ 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 8419927fe7..19475e00bf 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -138,4 +138,5 @@ void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, } void analogout_reset(void) { + // AudioOut resets the DAC in case its been used for audio which requires special handling. } diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index b15c642b53..596f3214af 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -60,8 +60,8 @@ static void ramp_value(uint16_t start, uint16_t end) { int32_t step = 49; int32_t steps = diff / step; if (diff < 0) { - steps *= -1; - step *= -1; + steps = -steps; + step = -step; } for (int32_t i = 0; i < steps; i++) { uint32_t value = start + step * i; @@ -81,8 +81,8 @@ static void ramp_value(uint16_t start, uint16_t end) { int32_t step = 49; int32_t steps = diff / step; if (diff < 0) { - steps *= -1; - step *= -1; + steps = -steps; + step = -step; } for (int32_t i = 0; i < steps; i++) { @@ -119,7 +119,7 @@ void audioout_reset(void) { } void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, - const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value) { + const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) { #ifdef SAMD51 bool dac_clock_enabled = hri_mclk_get_APBDMASK_DAC_bit(MCLK); #endif @@ -299,8 +299,8 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, self->tc_to_dac_event_channel = channel; // Ramp the DAC up. - self->default_value = default_value; - ramp_value(0, default_value); + self->quiescent_value = quiescent_value; + ramp_value(0, quiescent_value); // Leave the DMA setup to playback. } @@ -315,7 +315,7 @@ void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self) { } // Ramp the DAC down. - ramp_value(self->default_value, 0); + ramp_value(self->quiescent_value, 0); DAC->CTRLA.bit.ENABLE = 0; #ifdef SAMD21 @@ -461,7 +461,7 @@ void common_hal_audioio_audioout_stop(audioio_audioout_obj_t* self) { #endif // Ramp the DAC to default. The start is ignored when the current value can be readback. // Otherwise, we just set it immediately. - ramp_value(self->default_value, self->default_value); + ramp_value(self->quiescent_value, self->quiescent_value); } bool common_hal_audioio_audioout_get_playing(audioio_audioout_obj_t* self) { diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.h b/ports/atmel-samd/common-hal/audioio/AudioOut.h index 9e5a7390d5..56b6b75c89 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.h +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.h @@ -44,7 +44,7 @@ typedef struct { uint8_t tc_to_dac_event_channel; bool playing; - uint16_t default_value; + uint16_t quiescent_value; } audioio_audioout_obj_t; void audioout_reset(void); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 8c4b927855..18d908eef8 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -43,15 +43,15 @@ //| //| AudioOut can be used to output an analog audio signal on a given pin. //| -//| .. class:: AudioOut(left_channel, *, right_channel=None, default_value=0x8000) +//| .. class:: AudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) //| //| Create a AudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). //| //| :param ~microcontroller.Pin left_channel: The pin to output the left channel to //| :param ~microcontroller.Pin right_channel: The pin to output the right channel to -//| :param int default_value: The default output value. Samples should start and end with this -//| value to prevent popping. +//| :param int quiescent_value: The output value when no signal is present. Samples should start +//| and end with this value to prevent audible popping. //| //| Simple 8ksps 440 Hz sin wave:: //| @@ -97,11 +97,11 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar mp_arg_check_num(n_args, n_kw, 1, 2, true); mp_map_t kw_args; mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); - enum { ARG_left_channel, ARG_right_channel, ARG_default_value }; + enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_right_channel, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = mp_const_none} }, - { MP_QSTR_default_value, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, + { MP_QSTR_quiescent_value, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -120,7 +120,7 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar // create AudioOut object from the given pin audioio_audioout_obj_t *self = m_new_obj(audioio_audioout_obj_t); self->base.type = &audioio_audioout_type; - common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_default_value].u_int); + common_hal_audioio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); return MP_OBJ_FROM_PTR(self); } From 4f9c8b7361db7967fa794ea4d911ef350f23061a Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 17 Oct 2018 17:45:47 -0700 Subject: [PATCH 21/42] Add debug info to the generated frozen_mpy.c It adds size info and uses macros for byte code to make it more readable. --- py/mkrules.mk | 2 +- tools/mpy-tool.py | 70 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/py/mkrules.mk b/py/mkrules.mk index e619f2bddd..aa94ba412e 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -130,7 +130,7 @@ xargs -n1 "$(abspath $(MPY_CROSS))" $(MPY_CROSS_FLAGS) # to build frozen_mpy.c from all .mpy files # You need to define MPY_TOOL_LONGINT_IMPL in mpconfigport.mk # if the default will not work (mpz is the default). -$(BUILD)/frozen_mpy.c: $(BUILD)/frozen_mpy $(BUILD)/genhdr/qstrdefs.generated.h +$(BUILD)/frozen_mpy.c: $(BUILD)/frozen_mpy $(BUILD)/genhdr/qstrdefs.generated.h $(TOP)/tools/mpy-tool.py $(STEPECHO) "Creating $@" $(Q)$(MPY_TOOL) $(MPY_TOOL_LONGINT_IMPL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(shell $(FIND) -L $(BUILD)/frozen_mpy -type f -name '*.mpy') > $@ endif diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 7deb76a8d3..9e103ec607 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -78,6 +78,18 @@ MP_BC_LOAD_GLOBAL = 0x1d MP_BC_LOAD_ATTR = 0x1e MP_BC_STORE_ATTR = 0x26 +# load opcode names +opcode_names = {} +with open("../../py/bc0.h") as f: + for line in f.readlines(): + if line.startswith("#define"): + s = line.split(maxsplit=3) + if len(s) < 3: + continue + _, name, value = s[:3] + opcode = int(value.strip("()"), 0) + opcode_names[opcode] = name + def make_opcode_format(): def OC4(a, b, c, d): return a | (b << 2) | (c << 4) | (d << 6) @@ -252,35 +264,48 @@ class RawCode: i += 1 RawCode.escaped_names.add(self.escaped_name) + sizes = {"bytecode": 0, "strings": 0, "raw_code_overhead": 0, "const_table_overhead": 0, "string_overhead": 0, "number_overhead": 0} # emit children first for rc in self.raw_codes: - rc.freeze(self.escaped_name + '_') + subsize = rc.freeze(self.escaped_name + '_') + for k in sizes: + sizes[k] += subsize[k] + # generate bytecode data print() print('// frozen bytecode for file %s, scope %s%s' % (self.source_file.str, parent_name, self.simple_name.str)) + print("// bytecode size", len(self.bytecode)) print('STATIC ', end='') if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: print('const ', end='') print('byte bytecode_data_%s[%u] = {' % (self.escaped_name, len(self.bytecode))) + sizes["bytecode"] += len(self.bytecode) print(' ', end='') for i in range(self.ip2): print(' 0x%02x,' % self.bytecode[i], end='') print() + print(" // simple name") print(' ', self.simple_name.qstr_id, '& 0xff,', self.simple_name.qstr_id, '>> 8,') + print(" // source file") print(' ', self.source_file.qstr_id, '& 0xff,', self.source_file.qstr_id, '>> 8,') print(' ', end='') for i in range(self.ip2 + 4, self.ip): - print(' 0x%02x,' % self.bytecode[i], end='') + opcode = self.bytecode[i] print() ip = self.ip while ip < len(self.bytecode): f, sz = mp_opcode_format(self.bytecode, ip) + opcode = self.bytecode[ip] + if opcode in opcode_names: + opcode = opcode_names[opcode] + else: + opcode = '0x%02x' % opcode if f == 1: qst = self._unpack_qstr(ip + 1).qstr_id - print(' ', '0x%02x,' % self.bytecode[ip], qst, '& 0xff,', qst, '>> 8,') + print(' {}, {} & 0xff, {} >> 8,'.format(opcode, qst, qst)) else: - print(' ', ''.join('0x%02x, ' % self.bytecode[ip + i] for i in range(sz))) + print(' {},{}'.format(opcode, ''.join(' 0x%02x,' % self.bytecode[ip + i] for i in range(1, sz)))) ip += sz print('};') @@ -295,9 +320,12 @@ class RawCode: obj_type = 'mp_type_str' else: obj_type = 'mp_type_bytes' - print('STATIC const mp_obj_str_t %s = {{&%s}, %u, %u, (const byte*)"%s"};' + print('STATIC const mp_obj_str_t %s = {{&%s}, %u, %u, (const byte*)"%s"}; // %s' % (obj_name, obj_type, qstrutil.compute_hash(obj, config.MICROPY_QSTR_BYTES_IN_HASH), - len(obj), ''.join(('\\x%02x' % b) for b in obj))) + len(obj), ''.join(('\\x%02x' % b) for b in obj), obj)) + sizes["strings"] += len(obj) + sizes["string_overhead"] += 16 + elif is_int_type(obj): if config.MICROPY_LONGINT_IMPL == config.MICROPY_LONGINT_IMPL_NONE: # TODO check if we can actually fit this long-int into a small-int @@ -321,14 +349,17 @@ class RawCode: print('STATIC const mp_obj_int_t %s = {{&mp_type_int}, ' '{.neg=%u, .fixed_dig=1, .alloc=%u, .len=%u, .dig=(uint%u_t[]){%s}}};' % (obj_name, neg, ndigs, ndigs, bits_per_dig, digs)) + sizes["number_overhead"] += 16 elif type(obj) is float: print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') print('STATIC const mp_obj_float_t %s = {{&mp_type_float}, %.16g};' % (obj_name, obj)) print('#endif') + sizes["number_overhead"] += 8 elif type(obj) is complex: print('STATIC const mp_obj_complex_t %s = {{&mp_type_complex}, %.16g, %.16g};' % (obj_name, obj.real, obj.imag)) + sizes["number_overhead"] += 12 else: raise FreezeError(self, 'freezing of object %r is not implemented' % (obj,)) @@ -338,8 +369,10 @@ class RawCode: print('STATIC const mp_rom_obj_t const_table_data_%s[%u] = {' % (self.escaped_name, const_table_len)) for qst in self.qstrs: + sizes["const_table_overhead"] += 4 print(' MP_ROM_QSTR(%s),' % global_qstrs[qst].qstr_id) for i in range(len(self.objs)): + sizes["const_table_overhead"] += 4 if type(self.objs[i]) is float: print('#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B') print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) @@ -353,6 +386,7 @@ class RawCode: else: print(' MP_ROM_PTR(&const_obj_%s_%u),' % (self.escaped_name, i)) for rc in self.raw_codes: + sizes["const_table_overhead"] += 4 print(' MP_ROM_PTR(&raw_code_%s),' % rc.escaped_name) print('};') @@ -376,6 +410,9 @@ class RawCode: print(' #endif') print(' },') print('};') + sizes["raw_code_overhead"] += 16 + + return sizes def read_uint(f): i = 0 @@ -467,6 +504,7 @@ def freeze_mpy(base_qstrs, raw_codes): new[q.qstr_esc] = (len(new), q.qstr_esc, q.str) new = sorted(new.values(), key=lambda x: x[0]) + print('#include "py/bc0.h"') print('#include "py/mpconfig.h"') print('#include "py/objint.h"') print('#include "py/objstr.h"') @@ -523,27 +561,45 @@ def freeze_mpy(base_qstrs, raw_codes): print(' %u, // allocated entries' % len(new)) print(' %u, // used entries' % len(new)) print(' {') + qstr_size = {"metadata": 0, "data": 0} for _, _, qstr in new: + qstr_size["metadata"] += config.MICROPY_QSTR_BYTES_IN_LEN + config.MICROPY_QSTR_BYTES_IN_HASH + qstr_size["data"] += len(qstr) print(' %s,' % qstrutil.make_bytes(config.MICROPY_QSTR_BYTES_IN_LEN, config.MICROPY_QSTR_BYTES_IN_HASH, qstr)) print(' },') print('};') + sizes = {} for rc in raw_codes: - rc.freeze(rc.source_file.str.replace('/', '_')[:-3] + '_') + sizes[rc.source_file.str] = rc.freeze(rc.source_file.str.replace('/', '_')[:-3] + '_') print() print('const char mp_frozen_mpy_names[] = {') + qstr_size["filenames"] = 1 for rc in raw_codes: module_name = rc.source_file.str print('"%s\\0"' % module_name) + qstr_size["filenames"] += len(module_name) + 1 print('"\\0"};') print('const mp_raw_code_t *const mp_frozen_mpy_content[] = {') for rc in raw_codes: print(' &raw_code_%s,' % rc.escaped_name) + size = sizes[rc.source_file.str] + print(' // Total size:', sum(size.values())) + for k in size: + print(" // {} {}".format(k, size[k])) print('};') + print() + print('// Total size:', sum([sum(x.values()) for x in sizes.values()]) + sum(qstr_size.values())) + for k in size: + total = sum([x[k] for x in sizes.values()]) + print("// {} {}".format(k, total)) + for k in qstr_size: + print("// qstr {} {}".format(k, qstr_size[k])) + def main(): import argparse cmd_parser = argparse.ArgumentParser(description='A tool to work with MicroPython .mpy files.') From cb0126131a08a52aa5f66ae0f705079b2ae21080 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 18 Oct 2018 10:37:42 -0700 Subject: [PATCH 22/42] Use python3 for mpy-tool --- py/mkenv.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/mkenv.mk b/py/mkenv.mk index facb8a3c26..b76dd60f85 100644 --- a/py/mkenv.mk +++ b/py/mkenv.mk @@ -72,7 +72,7 @@ endif MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py MPY_CROSS = $(TOP)/mpy-cross/mpy-cross -MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py +MPY_TOOL = $(PYTHON3) $(TOP)/tools/mpy-tool.py PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py all: From b4dcbb79b2327137a615f37556dc6ffa415658da Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 18 Oct 2018 14:23:17 -0700 Subject: [PATCH 23/42] Add back printing out code info. Whoops! --- tools/mpy-tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 9e103ec607..5ce24061bc 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -289,10 +289,12 @@ class RawCode: print(' ', self.simple_name.qstr_id, '& 0xff,', self.simple_name.qstr_id, '>> 8,') print(" // source file") print(' ', self.source_file.qstr_id, '& 0xff,', self.source_file.qstr_id, '>> 8,') + print(" // code info") print(' ', end='') for i in range(self.ip2 + 4, self.ip): - opcode = self.bytecode[i] + print(' 0x%02x,' % self.bytecode[i], end='') print() + print(" // bytecode") ip = self.ip while ip < len(self.bytecode): f, sz = mp_opcode_format(self.bytecode, ip) From 3d7b96aeb1ae36deb905b7ab6091d4fc0f61482d Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Mon, 17 Sep 2018 02:45:04 -0700 Subject: [PATCH 24/42] Add board and pin defs for MakerDiary NRF52840 MDK --- ports/nrf/Makefile | 16 +- .../boards/makerdiary_nrf52840_mdk/README.md | 181 ++++++++++++++++++ .../boards/makerdiary_nrf52840_mdk/board.c | 40 ++++ .../makerdiary_nrf52840_mdk/mpconfigboard.h | 64 +++++++ .../makerdiary_nrf52840_mdk/mpconfigboard.mk | 16 ++ .../nrf/boards/makerdiary_nrf52840_mdk/pins.c | 63 ++++++ 6 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 ports/nrf/boards/makerdiary_nrf52840_mdk/README.md create mode 100644 ports/nrf/boards/makerdiary_nrf52840_mdk/board.c create mode 100644 ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h create mode 100644 ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.mk create mode 100644 ports/nrf/boards/makerdiary_nrf52840_mdk/pins.c diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 8b84f43df4..ce9e5e6647 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -300,16 +300,16 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex else ifeq ($(FLASHER), pyocd) flash: $(BUILD)/$(OUTPUT_FILENAME).hex - pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase - pyocd-tool -t $(MCU_SUB_VARIANT) erase $(BOOT_SETTING_ADDR) - pyocd-tool -t $(MCU_SUB_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001 - pyocd-tool -t $(MCU_SUB_VARIANT) reset + pyocd-flashtool -t nrf52 $< # --sector_erase + #pyocd-tool -t nrf52 erase $(BOOT_SETTING_ADDR) + #pyocd-tool -t nrf52 write32 $(BOOT_SETTING_ADDR) 0x00000001 + #pyocd-tool -t nrf52 reset sd: $(BUILD)/$(OUTPUT_FILENAME).hex - pyocd-flashtool -t $(MCU_SUB_VARIANT) --chip_erase - pyocd-flashtool -t $(MCU_SUB_VARIANT) $(SOFTDEV_HEX) - pyocd-flashtool -t $(MCU_SUB_VARIANT) $< --sector_erase - pyocd-tool -t $(MCU_SUB_VARIANT) reset $(BOOT_SETTING_ADDR) + pyocd-flashtool -t nrf52 --chip_erase + pyocd-flashtool -t nrf52 $(SOFTDEV_HEX) + pyocd-flashtool -t nrf52 $< --sector_erase + pyocd-tool -t nrf52 reset $(BOOT_SETTING_ADDR) endif diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md new file mode 100644 index 0000000000..dfa794349c --- /dev/null +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md @@ -0,0 +1,181 @@ +# Setup + +## Installing CircuitPython submodules + +Before you can build, you will need to run the following commands once, which +will install the submodules that are part of the CircuitPython ecosystem, and +build the `mpy-cross` tool: + +``` +$ cd circuitpython +$ git submodule update --init +$ make -C mpy-cross +``` + +You then need to download the SD and Nordic SDK files via: + +> This script relies on `wget`, which must be available from the command line. + +``` +$ cd ports/nrf +$ ./drivers/bluetooth/download_ble_stack.sh +``` + +## Note about bootloaders + +While most Adafruit devices come with (or can easily be flashed with) an +Adafruit-provided bootloader (supporting niceties like UF2 flashing) + +### Install `nrfjprog` + +Before you can install the bootloader, you will first need to install the +`nrfjprog` tool from Nordic Semiconductors for your operating system. The +binary files can be downloaded via the following links: + +- [nRF5x toolset tar for Linux 32-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux32/52619) +- [nRF5x toolset tar for Linux 64-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux64/51388) +- [nRF5x toolset tar for OSX v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-OSX/53406) +- [nRF5x toolset installer for Windows v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Win32/48768) + +You will then need to add the `nrfjprog` folder to your system `PATH` variable +so that it is available from the command line. The exact process for this is +OS specific, but on a POSIX type system like OS X or Linux, you can +temporarily add the location to your `PATH` environment variables as follows: + +``` +$ export PATH=$PATH:YOURPATHHERE/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog/ +``` + +You can test this by running the following command: + +``` +$ nrfjprog --version +nrfjprog version: 9.7.2 +JLinkARM.dll version: 6.20f +``` + +### Flash the USB CDC Bootloader with 'nrfjprog' + +> This operation only needs to be done once, and only on boards that don't + already have the serial bootloader installed. + +Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory + +``` +$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git +$ cd Adafruit_nRF52_Bootloader +``` + +Once `nrfjprog` is installed and available in `PATH` you can flash your +board with the serial bootloader via the following command: + +``` +make BOARD=feather_nrf52840_express VERSION=latest flash +``` + +This should give you the following (or very similar) output, and you will see +a DFU blinky pattern on one of the board LEDs: + +``` +$ make BOARD=pca10056 VERSION=latest flash +Flashing: bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex +nrfjprog --program bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex --chiperase -f nrf52 --reset +Parsing hex file. +Erasing user available code and UICR flash areas. +Applying system reset. +Checking that the area to write is not protected. +Programing device. +Applying system reset. +Run. +``` + +From this point onward, you can now use a simple serial port for firmware +updates. + +Note: You can specify other version that are available in the directory `Adafruit_nRF52_Bootloader/bin/feather_nrf52840_express/` . The `VERSION=latest` will use the latest bootloader available. + +### IMPORTANT: Disable Mass Storage on PCA10056 J-Link + +The J-Link firmware on the PCA10056 implement USB Mass Storage, but this +causes a known conflict with reliable USB CDC serial port communication. In +order to use the serial bootloader, **you must disable MSD support on the +Segger J-Link**! + +To disable mass storage support, run the `JLinkExe` (or equivalent) command, +and send `MSDDisable`. (You can re-enable MSD support via `MSDEnable`): + +``` +$ JLinkExe +SEGGER J-Link Commander V6.20f (Compiled Oct 13 2017 17:20:01) +DLL version V6.20f, compiled Oct 13 2017 17:19:52 + +Connecting to J-Link via USB...O.K. +Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 +Hardware version: V1.00 +S/N: 683947110 +VTref = 3.300V + + +Type "connect" to establish a target connection, '?' for help +J-Link>MSDDisable +Probe configured successfully. +J-Link>exit +``` + +## Building and Flashing CircuitPython + +### Installing `adafruit-nrfutil` + +run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi + +``` +$ pip3 install adafruit-nrfutil --user +``` + +### Flashing CircuitPython with USB CDC + +With the serial bootloader present on your board, you first need to force your +board into DFU mode by holding down BUTTON1 and RESETTING the board (with +BUTTON1 still pressed as you come out of reset). + +This will give you a **fast blinky DFU pattern** to indicate you are in DFU +mode. + +You can **build and flash** a CircuitPython binary via the following command: + +``` +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash +``` + +This should give you the following results: + +``` +$make V=1 BOARD=feather52840 SD=s140 SERIAL=/dev/tty.usbmodem1411 dfu-gen dfu-flash +nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip +Zip created at build-feather52840-s140/dfu-package.zip +nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/ttyACM1 -b 115200 --singlebank +Upgrading target on /dev/ttyACM1 with DFU package /home/hathach/Dropbox/adafruit/circuitpython/ada_cp/ports/nrf/build-feather52840-s140/dfu-package.zip. Flow control is disabled, Single bank mode +Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 199840 +Sending DFU start packet +Sending DFU init packet +Sending firmware file +######################################################################################################################################################################################################################################################################################################################################################################################################### +Activating new firmware + +DFU upgrade took 8.50606513023s +Device programmed. +``` + +### Flashing CircuitPython with MSC UF2 + +uf2 file is generated last by `all` target + +``` +$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all +Create firmware.uf2 +../../tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex" +Converting to uf2, output size: 392192, start address: 0x26000 +Wrote 392192 bytes to build-feather52840-s140/firmware.uf2. +``` + +Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done. diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c new file mode 100644 index 0000000000..a6d050fce2 --- /dev/null +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "boards/board.h" +#include "usb.h" + +void board_init(void) { + usb_init(); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h new file mode 100644 index 0000000000..0a0321fcf8 --- /dev/null +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h @@ -0,0 +1,64 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#define FEATHER52840 + +#define MICROPY_HW_BOARD_NAME "MakerDiary nRF52840 MDK" +#define MICROPY_HW_MCU_NAME "nRF52840" +#define MICROPY_PY_SYS_PLATFORM "MakerDiary52840MDK" + +#define MICROPY_QSPI_DATA0 (&pin_P1_05) +#define MICROPY_QSPI_DATA1 (&pin_P1_04) +#define MICROPY_QSPI_DATA2 (&pin_P1_02) +#define MICROPY_QSPI_DATA3 (&pin_P1_01) +#define MICROPY_QSPI_SCK (&pin_P1_03) +#define MICROPY_QSPI_CS (&pin_P1_06) + +#define CIRCUITPY_AUTORELOAD_DELAY_MS 500 + +// If you change this, then make sure to update the linker scripts as well to +// make sure you don't overwrite code +#define PORT_HEAP_SIZE (128 * 1024) +// TODO #define CIRCUITPY_INTERNAL_NVM_SIZE 8192 + +#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) + +// TODO #include "external_flash/devices.h" + +#define EXTERNAL_FLASH_DEVICE_COUNT 1 +// Datasheet for when this is implemented: +// http://www.mxic.com.tw/Lists/Datasheet/Attachments/7428/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.4.pdf +#define EXTERNAL_FLASH_DEVICES MX25R6435F + +#define EXTERNAL_FLASH_QSPI_DUAL + +// TODO include "external_flash/external_flash.h" + +#define BOARD_HAS_CRYSTAL 0 + +#define DEFAULT_UART_BUS_RX (&pin_P0_19) +#define DEFAULT_UART_BUS_TX (&pin_P0_20) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.mk b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.mk new file mode 100644 index 0000000000..caf580ec4d --- /dev/null +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.mk @@ -0,0 +1,16 @@ +MCU_SERIES = m4 +MCU_VARIANT = nrf52 +MCU_SUB_VARIANT = nrf52840 +MCU_CHIP = nrf52840 +SD ?= s140 +SOFTDEV_VERSION ?= 6.1.0 + +BOOT_SETTING_ADDR = 0xFF000 + +ifeq ($(SD),) + LD_FILE = boards/nrf52840_1M_256k.ld +else + LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld +endif + +NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/pins.c b/ports/nrf/boards/makerdiary_nrf52840_mdk/pins.c new file mode 100644 index 0000000000..27f0c67974 --- /dev/null +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/pins.c @@ -0,0 +1,63 @@ +#include "shared-bindings/board/__init__.h" + +#include "board_busses.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_AIN0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_AIN1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_AIN2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_AIN3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_AIN4), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_AIN5), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_AIN6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_AIN7), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_VDIV), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_P11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_P12), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_P13), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_P14), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_P15), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_P16), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_P17), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_P21), MP_ROM_PTR(&pin_P0_21) }, + { MP_ROM_QSTR(MP_QSTR_P25), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_P26), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_P27), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_P28), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_P29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_P30), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_P31), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_CSN), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_P1_01) }, + + { MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_P0_19) }, + + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_P0_22) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_P0_24) }, + + { MP_ROM_QSTR(MP_QSTR_USR_BTN), MP_ROM_PTR(&pin_P1_00) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); From 16ca9c8c7c7cb17eb9aa0a9728052d7ef957713b Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sat, 20 Oct 2018 02:39:09 -0700 Subject: [PATCH 25/42] Makefile fixes and some docs --- ports/nrf/Makefile | 16 +- ports/nrf/README.md | 2 + .../boards/makerdiary_nrf52840_mdk/README.md | 209 ++++++------------ 3 files changed, 74 insertions(+), 153 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index ce9e5e6647..a1a6a4d35c 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -300,16 +300,16 @@ sd: $(BUILD)/$(OUTPUT_FILENAME).hex else ifeq ($(FLASHER), pyocd) flash: $(BUILD)/$(OUTPUT_FILENAME).hex - pyocd-flashtool -t nrf52 $< # --sector_erase - #pyocd-tool -t nrf52 erase $(BOOT_SETTING_ADDR) - #pyocd-tool -t nrf52 write32 $(BOOT_SETTING_ADDR) 0x00000001 - #pyocd-tool -t nrf52 reset + pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase + #pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR) + pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001 + pyocd-tool -t $(MCU_VARIANT) reset sd: $(BUILD)/$(OUTPUT_FILENAME).hex - pyocd-flashtool -t nrf52 --chip_erase - pyocd-flashtool -t nrf52 $(SOFTDEV_HEX) - pyocd-flashtool -t nrf52 $< --sector_erase - pyocd-tool -t nrf52 reset $(BOOT_SETTING_ADDR) + pyocd-flashtool -t $(MCU_VARIANT) --chip_erase + pyocd-flashtool -t $(MCU_VARIANT) $(SOFTDEV_HEX) + pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase + pyocd-tool -t $(MCU_VARIANT) reset $(BOOT_SETTING_ADDR) endif diff --git a/ports/nrf/README.md b/ports/nrf/README.md index c21bd5d63b..4bd865400b 100644 --- a/ports/nrf/README.md +++ b/ports/nrf/README.md @@ -39,6 +39,7 @@ the following links: * Adafruit [Feather nRF52](boards/feather_nrf52832/README.md): 512KB Flash, 64KB SRAM * Adafruit [Feather nRF52840](boards/feather_nrf52840_express/README.md): 1MB Flash, 256KB SRAM * Nordic PCA10056 see [Feather nRF52840](boards/pca10056/README.md) +* MakerDiary NRF52840 MDK see [its README](boards/makerdiary_nrf52840_mdk/README.md) For all other board targets, see the generic notes below. @@ -80,6 +81,7 @@ pca10040 | s132 | Peripheral and Scanner | [S pca10056 | s140 | Peripheral and Scanner | [Segger](#segger-targets) feather_nrf52832 | s132 | Peripheral and Scanner | [UART DFU](#dfu-targets) feather_nrf52840_express | s140 | Peripheral and Scanner | UF2 bootloader +makerdiary_nrf52840_mdk | s140 | Peripheral and Scanner | pyocd or ARM mbed DAPLink ## Segger Targets diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md index dfa794349c..826b930512 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md @@ -1,4 +1,20 @@ -# Setup +# MakerDiary NRF52840 MDK + +Refer to https://github.com/makerdiary/nrf52840-mdk or +https://wiki.makerdiary.com/nrf52840-mdk/ for more details about the device. + +Notably, CircuitPython does not currently support QSPI external flash on NRF +devices, so neither does this port. Don't store anything you care to read in +Python on that giant 64MB flash device for now - the 64MB drive that shows up on +your computer is actually part of the MSC driver provided by the DAPLink +debugger. You'll still have access to 256KB of the onboard flash, however, for +storing your Python files, cat pictures, or whatever. + +It's also interesting to note that all three LEDs and the "user button" on this +device are wired through sinks, not sources, so flip your boolean expectations +when dealing with `digitalio.DigitalInOut` on this device - `my_led.value = +True` turns the LED off! Likewise, the user button will read `False` when +pressed. ## Installing CircuitPython submodules @@ -24,158 +40,61 @@ $ ./drivers/bluetooth/download_ble_stack.sh ## Note about bootloaders While most Adafruit devices come with (or can easily be flashed with) an -Adafruit-provided bootloader (supporting niceties like UF2 flashing) +Adafruit-provided bootloader (supporting niceties like UF2 flashing), this +board comes with DAPLink which (apparently?) handles everything from debugging +to programming the device, as well as the boot sequence. What's particularly +awesome about this board is that there is no physical interaction with the board +required to flash new code (read: CircuitPython builds) - the device is _always_ +listening for new firmware uploads (via `pyocd-flashtool`), even if userspace +code is running. -### Install `nrfjprog` +## Building and Flashing CircuitPython -Before you can install the bootloader, you will first need to install the -`nrfjprog` tool from Nordic Semiconductors for your operating system. The -binary files can be downloaded via the following links: +You'll need to have [pyocd](https://github.com/mbedmicro/pyOCD) installed as +appropriate for your system. -- [nRF5x toolset tar for Linux 32-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux32/52619) -- [nRF5x toolset tar for Linux 64-bit v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Linux64/51388) -- [nRF5x toolset tar for OSX v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-OSX/53406) -- [nRF5x toolset installer for Windows v9.7.2](http://www.nordicsemi.com/eng/nordic/Products/nRF52832/nRF5x-Command-Line-Tools-Win32/48768) - -You will then need to add the `nrfjprog` folder to your system `PATH` variable -so that it is available from the command line. The exact process for this is -OS specific, but on a POSIX type system like OS X or Linux, you can -temporarily add the location to your `PATH` environment variables as follows: - -``` -$ export PATH=$PATH:YOURPATHHERE/nRF5x-Command-Line-Tools_9_7_2_OSX/nrfjprog/ -``` - -You can test this by running the following command: - -``` -$ nrfjprog --version -nrfjprog version: 9.7.2 -JLinkARM.dll version: 6.20f -``` - -### Flash the USB CDC Bootloader with 'nrfjprog' - -> This operation only needs to be done once, and only on boards that don't - already have the serial bootloader installed. - -Firstly clone the [Adafruit_nRF52_Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader.git) and enter its directory - -``` -$ git clone https://github.com/adafruit/Adafruit_nRF52_Bootloader.git -$ cd Adafruit_nRF52_Bootloader -``` - -Once `nrfjprog` is installed and available in `PATH` you can flash your -board with the serial bootloader via the following command: - -``` -make BOARD=feather_nrf52840_express VERSION=latest flash +```sh +make BOARD=makerdiary_nrf52840_mdk FLASHER=pyocd SD=s140 flash ``` This should give you the following (or very similar) output, and you will see a DFU blinky pattern on one of the board LEDs: ``` -$ make BOARD=pca10056 VERSION=latest flash -Flashing: bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex -nrfjprog --program bin/pca10056/6.0.0r0/pca10056_bootloader_s140_6.0.0r0.hex --chiperase -f nrf52 --reset -Parsing hex file. -Erasing user available code and UICR flash areas. -Applying system reset. -Checking that the area to write is not protected. -Programing device. -Applying system reset. -Run. +$ make BOARD=makerdiary_nrf52840_mdk FLASHER=pyocd SD=s140 flash +Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity. +pyocd-flashtool -t nrf52 build-makerdiary_nrf52840_mdk-s140/firmware.hex --sector_erase +INFO:root:DAP SWD MODE initialised +INFO:root:ROM table #0 @ 0xe00ff000 cidr=b105100d pidr=2002c4008 +INFO:root:[0] +WARNING:root:Invalid coresight component, cidr=0x0 +INFO:root:[1] +INFO:root:[2] +WARNING:root:Invalid coresight component, cidr=0x1010101 +INFO:root:[3] +WARNING:root:Invalid coresight component, cidr=0x0 +INFO:root:[4] +INFO:root:[5] +INFO:root:CPU core is Cortex-M4 +INFO:root:FPU present +INFO:root:6 hardware breakpoints, 4 literal comparators +INFO:root:4 hardware watchpoints +[====================] 100% +INFO:root:Programmed 237568 bytes (58 pages) at 14.28 kB/s +#pyocd-tool -t nrf52 erase 0xFF000 +pyocd-tool -t nrf52 write32 0xFF000 0x00000001 +WARNING:root:Invalid coresight component, cidr=0x0 +WARNING:root:Invalid coresight component, cidr=0x1010101 +WARNING:root:Invalid coresight component, cidr=0x0 +pyocd-tool -t nrf52 reset +WARNING:root:Invalid coresight component, cidr=0x0 +WARNING:root:Invalid coresight component, cidr=0x1010101 +WARNING:root:Invalid coresight component, cidr=0x0 +Resetting target ``` -From this point onward, you can now use a simple serial port for firmware -updates. - -Note: You can specify other version that are available in the directory `Adafruit_nRF52_Bootloader/bin/feather_nrf52840_express/` . The `VERSION=latest` will use the latest bootloader available. - -### IMPORTANT: Disable Mass Storage on PCA10056 J-Link - -The J-Link firmware on the PCA10056 implement USB Mass Storage, but this -causes a known conflict with reliable USB CDC serial port communication. In -order to use the serial bootloader, **you must disable MSD support on the -Segger J-Link**! - -To disable mass storage support, run the `JLinkExe` (or equivalent) command, -and send `MSDDisable`. (You can re-enable MSD support via `MSDEnable`): - -``` -$ JLinkExe -SEGGER J-Link Commander V6.20f (Compiled Oct 13 2017 17:20:01) -DLL version V6.20f, compiled Oct 13 2017 17:19:52 - -Connecting to J-Link via USB...O.K. -Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 -Hardware version: V1.00 -S/N: 683947110 -VTref = 3.300V - - -Type "connect" to establish a target connection, '?' for help -J-Link>MSDDisable -Probe configured successfully. -J-Link>exit -``` - -## Building and Flashing CircuitPython - -### Installing `adafruit-nrfutil` - -run follow command to install [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil) from PyPi - -``` -$ pip3 install adafruit-nrfutil --user -``` - -### Flashing CircuitPython with USB CDC - -With the serial bootloader present on your board, you first need to force your -board into DFU mode by holding down BUTTON1 and RESETTING the board (with -BUTTON1 still pressed as you come out of reset). - -This will give you a **fast blinky DFU pattern** to indicate you are in DFU -mode. - -You can **build and flash** a CircuitPython binary via the following command: - -``` -$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all dfu-gen dfu-flash -``` - -This should give you the following results: - -``` -$make V=1 BOARD=feather52840 SD=s140 SERIAL=/dev/tty.usbmodem1411 dfu-gen dfu-flash -nrfutil dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application build-feather52840-s140/firmware.hex build-feather52840-s140/dfu-package.zip -Zip created at build-feather52840-s140/dfu-package.zip -nrfutil --verbose dfu serial --package build-feather52840-s140/dfu-package.zip -p /dev/ttyACM1 -b 115200 --singlebank -Upgrading target on /dev/ttyACM1 with DFU package /home/hathach/Dropbox/adafruit/circuitpython/ada_cp/ports/nrf/build-feather52840-s140/dfu-package.zip. Flow control is disabled, Single bank mode -Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 199840 -Sending DFU start packet -Sending DFU init packet -Sending firmware file -######################################################################################################################################################################################################################################################################################################################################################################################################### -Activating new firmware - -DFU upgrade took 8.50606513023s -Device programmed. -``` - -### Flashing CircuitPython with MSC UF2 - -uf2 file is generated last by `all` target - -``` -$ make V=1 SD=s140 SERIAL=/dev/tty.usbmodem1411 BOARD=feather52840 all -Create firmware.uf2 -../../tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "build-feather52840-s140/firmware.uf2" "build-feather52840-s140/firmware.hex" -Converting to uf2, output size: 392192, start address: 0x26000 -Wrote 392192 bytes to build-feather52840-s140/firmware.uf2. -``` - -Simply drag and drop firmware.uf2 to the MSC, the nrf52840 will blink fast and reset after done. +Alternatively (and untested by me), it's apparently possible to copy +`firmware.hex` to the MSC device provided by DAPLink and flash that way. Refer +to [the upstream +documentation](https://wiki.makerdiary.com/nrf52840-mdk/getting-started/#drag-n-drop-programming) +for details. From 99edeed2e7b11e105a7a4479537521daf201b745 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sat, 20 Oct 2018 02:42:18 -0700 Subject: [PATCH 26/42] Build this thing! --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d4f21a398d..c56664d16f 100755 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ git: # that SDK is shortest and add it there. In the case of major re-organizations, # just try to make the builds "about equal in run time" env: - - TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express" TRAVIS_SDK=arm:nrf:esp8266 + - TRAVIS_TESTS="unix docs translations" TRAVIS_BOARDS="feather_huzzah circuitplayground_express pca10056 pca10059 feather_nrf52832 feather_nrf52840_express makerdiary_nrf52840_mdk" TRAVIS_SDK=arm:nrf:esp8266 - TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express" TRAVIS_SDK=arm - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero" TRAVIS_SDK=arm From 4c75a60bd3a8f56b5ebb935ea5f5dbec5cb3fc7a Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sat, 20 Oct 2018 02:57:17 -0700 Subject: [PATCH 27/42] Declobber a DEFINE --- ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h index 0a0321fcf8..b33fb2dd62 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/mpconfigboard.h @@ -25,7 +25,7 @@ * THE SOFTWARE. */ -#define FEATHER52840 +#define MAKERDIARYNRF52840MDK #define MICROPY_HW_BOARD_NAME "MakerDiary nRF52840 MDK" #define MICROPY_HW_MCU_NAME "nRF52840" From aefabc5353cf8507b15f77a17ab38023324f3040 Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sat, 20 Oct 2018 03:29:20 -0700 Subject: [PATCH 28/42] Update docs to reflect proper size of device --- ports/nrf/boards/makerdiary_nrf52840_mdk/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md index 826b930512..f1ba8151ac 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk/README.md @@ -4,10 +4,12 @@ Refer to https://github.com/makerdiary/nrf52840-mdk or https://wiki.makerdiary.com/nrf52840-mdk/ for more details about the device. Notably, CircuitPython does not currently support QSPI external flash on NRF -devices, so neither does this port. Don't store anything you care to read in -Python on that giant 64MB flash device for now - the 64MB drive that shows up on -your computer is actually part of the MSC driver provided by the DAPLink -debugger. You'll still have access to 256KB of the onboard flash, however, for +devices, so neither does this port - the 64Mb flash device is not used for +anything. Also, don't confuse this with the 64MiB drive that shows up on your +computer - it's actually part of the MSC driver provided by the DAPLink +debugger, and is inaccessible at all from Python land (this drive is where you +can copy `firmware.hex` if you'd prefer to flash that way as opposed to with +`pyocd`. You'll still have access to 256KB of the onboard flash, however, for storing your Python files, cat pictures, or whatever. It's also interesting to note that all three LEDs and the "user button" on this From 4a409192286cddf7de33d3aa2b594db5e35bafef Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Sat, 20 Oct 2018 03:36:55 -0700 Subject: [PATCH 29/42] Make sure port is built as an NRF hex correctly --- tools/build_adafruit_bins.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/build_adafruit_bins.sh b/tools/build_adafruit_bins.sh index 595d5ba5d2..07581edbee 100755 --- a/tools/build_adafruit_bins.sh +++ b/tools/build_adafruit_bins.sh @@ -25,6 +25,7 @@ grandcentral_m4_express \ hallowing_m0_express \ itsybitsy_m0_express \ itsybitsy_m4_express \ +makerdiary_nrf52840_mdk \ metro_m0_express \ metro_m4_express \ pca10056 \ @@ -81,6 +82,11 @@ for board in $boards; do (( exit_status = exit_status || $? )) temp_filename=ports/nrf/build-$board-s140/firmware.uf2 extension=uf2 + elif [[ $board == "makerdiary_nrf52840_mdk" ]]; then + make $PARALLEL -C ports/nrf TRANSLATION=$language BOARD=$board SD=s140 + (( exit_status = exit_status || $? )) + temp_filename=ports/nrf/build-$board-s140/firmware.hex + extension=hex else time make $PARALLEL -C ports/atmel-samd TRANSLATION=$language BOARD=$board (( exit_status = exit_status || $? )) From aeb538521747552229c0b777e3a145592cdc6f5f Mon Sep 17 00:00:00 2001 From: Carlos Date: Sat, 20 Oct 2018 19:46:17 -0500 Subject: [PATCH 30/42] [locale\es] Keep already translated strings up to date --- locale/es.po | 200 ++++++++++++++++++++++----------------------------- 1 file changed, 84 insertions(+), 116 deletions(-) diff --git a/locale/es.po b/locale/es.po index 60452ae348..59b8d6353c 100644 --- a/locale/es.po +++ b/locale/es.po @@ -65,7 +65,7 @@ msgstr "string de longitud impar" #: extmod/modubinascii.c:101 msgid "non-hex digit found" -msgstr "se encontró un digito no hexadecimal" +msgstr "se encontró un digito non-hex" #: extmod/modubinascii.c:169 msgid "incorrect padding" @@ -81,7 +81,7 @@ msgstr "No se puede obtener inequívocamente sizeof escalar" #: extmod/moductypes.c:397 msgid "struct: no fields" -msgstr "struct: no fields" +msgstr "struct: sin campos" #: extmod/moductypes.c:530 msgid "struct: cannot index" @@ -121,7 +121,7 @@ msgstr "certificado inválido" #: extmod/modutimeq.c:131 msgid "queue overflow" -msgstr "desborde de queue" +msgstr "desbordamiento de queue" #: extmod/moduzlib.c:98 msgid "compression header" @@ -132,16 +132,14 @@ msgid "invalid dupterm index" msgstr "index dupterm inválido" #: extmod/vfs_fat.c:426 py/moduerrno.c:150 -#, fuzzy msgid "Read-only filesystem" -msgstr "sistema de archivos de Solo-Lectura" +msgstr "Sistema de archivos de solo-Lectura" #: extmod/vfs_posix_file.c:48 ports/unix/file.c:50 py/objstringio.c:43 msgid "I/O operation on closed file" msgstr "Operación I/O en archivo cerrado" #: lib/embed/abort_.c:8 -#, fuzzy msgid "abort() called" msgstr "se llamó abort()" @@ -158,21 +156,20 @@ msgid " output:\n" msgstr " salida:\n" #: main.c:157 main.c:230 -#, fuzzy msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" "Auto-reload habilitado. Simplemente guarda los archivos via USB para " -"ejecutarlos o entra REPL para desabilitarlos.\n" +"ejecutarlos o entra al REPL para desabilitarlos.\n" #: main.c:159 msgid "Running in safe mode! Auto-reload is off.\n" -msgstr "Ejecutando en modo seguro! Auto-recarga esta deshabilitado.\n" +msgstr "Ejecutando en modo seguro! La auto-recarga esta deshabilitada.\n" #: main.c:161 main.c:232 msgid "Auto-reload is off.\n" -msgstr "Auto-reload deshabilitado.\n" +msgstr "Auto-recarga deshabilitado.\n" #: main.c:175 msgid "Running in safe mode! Not running saved code.\n" @@ -184,7 +181,7 @@ msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" #: main.c:239 msgid "You requested starting safe mode by " -msgstr "Solicitaste iniciar en modo seguro con " +msgstr "Solicitaste iniciar en modo seguro por " #: main.c:242 msgid "To exit, please reset the board without " @@ -200,28 +197,27 @@ msgstr "" #: main.c:251 msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" msgstr "" -"Parece que nuestro código del núcleo CircuitPython dejó de funcionar. " -"Whoops!\n" +"Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n" #: main.c:252 #, fuzzy msgid "Please file an issue here with the contents of your CIRCUITPY drive:\n" msgstr "" -"Por favor registra un problema aquí con los contenidos de tu unidad de " +"Por favor registra un issue en el siguiente URL con los contenidos de tu unidad de " "almacenamiento CIRCUITPY:\n" #: main.c:255 msgid "" "The microcontroller's power dipped. Please make sure your power supply " "provides\n" -msgstr "" +msgstr "La alimentación del microcontrolador cayó. Por favor asegurate de que tu fuente de alimentación provee" #: main.c:256 msgid "" "enough power for the whole circuit and press reset (after ejecting " "CIRCUITPY).\n" msgstr "" -"suficiente poder para todo el circuito y pulsa reset (después de expulsar " +"suficiente poder para todo el circuito y presiona reset (después de expulsar " "CIRCUITPY).\n" #: main.c:260 @@ -261,7 +257,7 @@ msgstr "Sin bus UART por default" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c:63 #: ports/nrf/common-hal/analogio/AnalogIn.c:39 msgid "Pin does not have ADC capabilities" -msgstr "pin no tiene capacidades ADC" +msgstr "Pin no tiene capacidad ADC" #: ports/atmel-samd/common-hal/analogio/AnalogOut.c:49 msgid "No DAC on chip" @@ -278,7 +274,7 @@ msgstr "Pin bit clock inválido" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:153 msgid "Bit clock and word select must share a clock unit" -msgstr "Bit clock y Word select deben compartir la unidad de reloj" +msgstr "Bit clock y word select deben compartir una unidad de reloj" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:156 #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:130 @@ -299,11 +295,11 @@ msgstr "Clock unit está siendo utilizado" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:240 #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:172 msgid "Unable to find free GCLK" -msgstr "No se pudo encontrar un GCLK disponible" +msgstr "No se pudo encontrar un GCLK libre" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:254 msgid "Too many channels in sample." -msgstr "Demasiados canales en sample" +msgstr "Demasiados canales en sample." #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:305 #: ports/atmel-samd/common-hal/audioio/AudioOut.c:339 @@ -321,11 +317,11 @@ msgstr "Pin clock inválido" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:134 msgid "Only 8 or 16 bit mono with " -msgstr "Solo mono de 8 o 16 bit con" +msgstr "Solo mono de 8 o 16 bit con " #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:167 msgid "sampling rate out of range" -msgstr "velocidad de muestreo fuera de rango" +msgstr "frecuencia de muestreo fuera de rango" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:69 msgid "DAC already in use" @@ -333,13 +329,13 @@ msgstr "DAC ya está siendo utilizado" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:73 msgid "Right channel unsupported" -msgstr "El canal derecho no tiene soporte" +msgstr "Canal derecho no soportado" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:76 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:116 #: ports/atmel-samd/common-hal/touchio/TouchIn.c:65 msgid "Invalid pin" -msgstr "pin inválido" +msgstr "Pin inválido" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:84 msgid "Invalid pin for left channel" @@ -351,22 +347,22 @@ msgstr "Pin inválido para canal derecho" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:91 msgid "Cannot output both channels on the same pin" -msgstr "No es posible utilizar el mismo pin para ambos canales" +msgstr "No se puede tener ambos canales en el mismo pin" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:176 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:189 #: ports/atmel-samd/common-hal/pulseio/PulseOut.c:110 msgid "All timers in use" -msgstr "Todos los timers están siendo utilizados" +msgstr "Todos los timers en uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 msgid "All event channels in use" -msgstr "Todos los canales de eventos están siendo utilizados" +msgstr "Todos los event channels en uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 #, c-format msgid "Sample rate too high. It must be less than %d" -msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor que %d" +msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" #: ports/atmel-samd/common-hal/busio/I2C.c:71 msgid "Not enough pins available" @@ -386,21 +382,21 @@ msgstr "SDA o SCL necesitan una pull up" #: ports/atmel-samd/common-hal/busio/I2C.c:121 msgid "Unsupported baudrate" -msgstr "Baudrate sin soporte" +msgstr "Baudrate no soportado" #: ports/atmel-samd/common-hal/busio/UART.c:66 msgid "bytes > 8 bits not supported" -msgstr "bytes > 8 bits no son soportados" +msgstr "bytes > 8 bits no soportados" #: ports/atmel-samd/common-hal/busio/UART.c:72 #: ports/nrf/common-hal/busio/UART.c:82 msgid "tx and rx cannot both be None" -msgstr "tx y rx no pueden ser ambos None" +msgstr "Ambos tx y rx no pueden ser None" #: ports/atmel-samd/common-hal/busio/UART.c:145 #: ports/nrf/common-hal/busio/UART.c:115 msgid "Failed to allocate RX buffer" -msgstr "Fallo la asignación del buffer RX" +msgstr "Ha fallado la asignación del buffer RX" #: ports/atmel-samd/common-hal/busio/UART.c:153 msgid "Could not initialize UART" @@ -419,12 +415,12 @@ msgstr "Sin pin TX" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c:170 #: ports/nrf/common-hal/digitalio/DigitalInOut.c:142 msgid "Cannot get pull while in output mode" -msgstr "No se puede obtener pull mientras en modo de salida" +msgstr "No puede ser pull mientras este en modo de salida" #: ports/atmel-samd/common-hal/microcontroller/__init__.c:74 #: ports/esp8266/common-hal/microcontroller/__init__.c:64 msgid "Cannot reset into bootloader because no bootloader is present." -msgstr "No se puede reiniciar en bootloader porque no hay bootloader presente." +msgstr "No se puede reiniciar a bootloader porque no hay bootloader presente." #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:120 #: ports/atmel-samd/common-hal/pulseio/PWMOut.c:369 @@ -439,7 +435,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:110 msgid "No hardware support on pin" -msgstr "pin no tiene soporte en hardware" +msgstr "Sin soporte de hardware en pin" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:113 msgid "EXTINT channel already in use" @@ -449,12 +445,12 @@ msgstr "El canal EXTINT ya está siendo utilizado" #: ports/esp8266/common-hal/pulseio/PulseIn.c:86 #, c-format msgid "Failed to allocate RX buffer of %d bytes" -msgstr "Fallo la asignación del buffer RX de %d bytes" +msgstr "Falló la asignación del buffer RX de %d bytes" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:205 #: ports/esp8266/common-hal/pulseio/PulseIn.c:151 msgid "pop from an empty PulseIn" -msgstr "pop en un PulseIn vacío" +msgstr "pop de un PulseIn vacío" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c:237 #: ports/esp8266/common-hal/pulseio/PulseIn.c:182 py/obj.c:420 @@ -475,7 +471,7 @@ msgstr "El canal EXTINT ya está siendo utilizado" #: ports/atmel-samd/common-hal/rtc/RTC.c:101 msgid "calibration value out of range +/-127" -msgstr "Valor de calibración fuera de rango +/-127" +msgstr "Valor de calibración fuera del rango +/-127" #: ports/atmel-samd/common-hal/storage/__init__.c:48 msgid "Cannot remount '/' when USB is active." @@ -503,11 +499,11 @@ msgstr "Error USB" #: ports/esp8266/common-hal/analogio/AnalogIn.c:43 msgid "Pin %q does not have ADC capabilities" -msgstr "Pin %q no tiene capacidades ADC" +msgstr "Pin %q no tiene capacidades de ADC" #: ports/esp8266/common-hal/analogio/AnalogOut.c:39 msgid "No hardware support for analog out." -msgstr "Sin soporte de hardware para salida análoga" +msgstr "Sin soporte de hardware para analog out" #: ports/esp8266/common-hal/busio/SPI.c:72 msgid "Pins not valid for SPI" @@ -527,21 +523,21 @@ msgstr "stop bits inválidos" #: ports/esp8266/common-hal/digitalio/DigitalInOut.c:200 msgid "ESP8266 does not support pull down." -msgstr "ESP8266 no tiene soporte para pull down" +msgstr "ESP8266 no soporta pull down." #: ports/esp8266/common-hal/digitalio/DigitalInOut.c:210 msgid "GPIO16 does not support pull up." -msgstr "GPIO16 no tiene soporte para pull up." +msgstr "GPIO16 no soporta pull up." #: ports/esp8266/common-hal/microcontroller/__init__.c:66 msgid "ESP8226 does not support safe mode." -msgstr "ESP8226 no tiene soporte para modo seguro" +msgstr "ESP8226 no soporta modo seguro." #: ports/esp8266/common-hal/pulseio/PWMOut.c:54 #: ports/esp8266/common-hal/pulseio/PWMOut.c:113 #, c-format msgid "Maximum PWM frequency is %dhz." -msgstr "La frecuencia máxima del PWM es %dhz" +msgstr "La frecuencia máxima del PWM es %dhz." #: ports/esp8266/common-hal/pulseio/PWMOut.c:57 #: ports/esp8266/common-hal/pulseio/PWMOut.c:116 @@ -552,7 +548,7 @@ msgstr "La frecuencia mínima del PWM es 1hz" #, c-format msgid "Multiple PWM frequencies not supported. PWM already set to %dhz." msgstr "" -"PWM de múltiples frecuencias no tiene soporte. El PWM ya se estableció a %dhz" +"PWM de múltiples frecuencias no soportado. El PWM ya se estableció a %dhz" #: ports/esp8266/common-hal/pulseio/PWMOut.c:77 ports/esp8266/machine_pwm.c:70 #, c-format @@ -561,11 +557,11 @@ msgstr "El pin %d no soporta PWM" #: ports/esp8266/common-hal/pulseio/PulseIn.c:78 msgid "No PulseIn support for %q" -msgstr "%q no tiene soporte para PulseIn" +msgstr "Sin soporte PulseIn para %q" #: ports/esp8266/common-hal/storage/__init__.c:34 msgid "Unable to remount filesystem" -msgstr "No se pudo montar de nuevo el sistema de archivos" +msgstr "Incapaz de montar de nuevo el sistema de archivos" #: ports/esp8266/common-hal/storage/__init__.c:38 msgid "Use esptool to erase flash and re-upload Python instead" @@ -590,7 +586,7 @@ msgstr "esperando un pin" #: ports/esp8266/machine_pin.c:284 msgid "Pin(16) doesn't support pull" -msgstr "Pin(16) no tiene soporte para pull" +msgstr "Pin(16) no soporta para pull" #: ports/esp8266/machine_pin.c:323 msgid "invalid pin" @@ -598,7 +594,7 @@ msgstr "pin inválido" #: ports/esp8266/machine_pin.c:389 msgid "pin does not have IRQ capabilities" -msgstr "pin no tiene capacidades IRQ" +msgstr "pin sin capacidades IRQ" #: ports/esp8266/machine_rtc.c:185 msgid "buffer too long" @@ -626,7 +622,7 @@ msgstr "len debe de ser múltiple de 4" #, c-format msgid "memory allocation failed, allocating %u bytes for native code" msgstr "" -"la asignación de memoria ha fallado, asignando %u bytes para código nativo" +"falló la asignación de memoria, asignando %u bytes para código nativo" #: ports/esp8266/modesp.c:317 msgid "flash location must be below 1MByte" @@ -638,11 +634,11 @@ msgstr "la frecuencia solo puede ser 80MHz o 160MHz" #: ports/esp8266/modnetwork.c:61 msgid "AP required" -msgstr "AP necesario" +msgstr "AP requerido" #: ports/esp8266/modnetwork.c:61 msgid "STA required" -msgstr "STA necesario" +msgstr "STA requerido" #: ports/esp8266/modnetwork.c:87 msgid "Cannot update i/f status" @@ -714,11 +710,11 @@ msgstr "Funcionalidad AnalogOut no soportada" #: ports/nrf/common-hal/busio/I2C.c:95 msgid "All I2C peripherals are in use" -msgstr "Todos los timers están siendo utilizados" +msgstr "Todos los timers están siendo usados" #: ports/nrf/common-hal/busio/SPI.c:115 msgid "All SPI peripherals are in use" -msgstr "Todos los timers están siendo utilizados" +msgstr "Todos los timers están siendo usados" #: ports/nrf/common-hal/busio/UART.c:48 #, c-format @@ -747,9 +743,8 @@ msgid "Can not get temperature. status: 0x%02x" msgstr "No se puede obtener la temperatura. status: 0x%02x" #: ports/nrf/common-hal/pulseio/PWMOut.c:162 -#, fuzzy msgid "All PWM peripherals are in use" -msgstr "Todos los timers están siendo utilizados" +msgstr "Todos los periféricos PWM en uso" #: ports/nrf/drivers/bluetooth/ble_drv.c:199 msgid "Cannot apply GAP parameters." @@ -765,16 +760,16 @@ msgstr "No se puede consultar la dirección del dispositivo." #: ports/nrf/drivers/bluetooth/ble_drv.c:264 msgid "Can not add Vendor Specific 128-bit UUID." -msgstr "No se puede agregar el UUID de 128-bits Especifico del Vendedor." +msgstr "No se puede agregar el Vendor Specific 128-bit UUID." #: ports/nrf/drivers/bluetooth/ble_drv.c:284 #: ports/nrf/drivers/bluetooth/ble_drv.c:298 msgid "Can not add Service." -msgstr "No se puede agregar el Servicio" +msgstr "No se puede agregar el Servicio." #: ports/nrf/drivers/bluetooth/ble_drv.c:373 msgid "Can not add Characteristic." -msgstr "No se puede agregar la Característica" +msgstr "No se puede agregar la Característica." #: ports/nrf/drivers/bluetooth/ble_drv.c:400 msgid "Can not apply device name in the stack." @@ -1134,7 +1129,7 @@ msgid "'%s' expects a register" msgstr "" #: py/emitinlinethumb.c:211 -#, fuzzy, c-format +#, c-format msgid "'%s' expects a special register" msgstr "ord espera un carácter" @@ -1178,7 +1173,6 @@ msgid "unsupported Thumb instruction '%s' with %d arguments" msgstr "" #: py/emitinlinethumb.c:810 -#, fuzzy msgid "branch not in range" msgstr "El argumento de chr() no esta en el rango(256)" @@ -1345,14 +1339,12 @@ msgid "File exists" msgstr "" #: py/moduerrno.c:148 -#, fuzzy msgid "Unsupported operation" -msgstr "El pin %d no soporta PWM" +msgstr "Operacion no soportada" #: py/moduerrno.c:149 -#, fuzzy msgid "Invalid argument" -msgstr "argumentos inválidos" +msgstr "argumento inválido" #: py/obj.c:90 msgid "Traceback (most recent call last):\n" @@ -1424,9 +1416,8 @@ msgid "%q indices must be integers, not %s" msgstr "" #: py/obj.c:423 -#, fuzzy msgid "%q index out of range" -msgstr "struct: index fuera de rango" +msgstr "%w index fuera de rango" #: py/obj.c:455 msgid "object has no len" @@ -1438,9 +1429,8 @@ msgid "object of type '%s' has no len()" msgstr "" #: py/obj.c:496 -#, fuzzy msgid "object does not support item deletion" -msgstr "ESP8226 no soporta modo seguro" +msgstr "object no soporta supresión de item" #: py/obj.c:499 #, c-format @@ -1499,9 +1489,8 @@ msgid "full" msgstr "" #: py/objdeque.c:127 -#, fuzzy msgid "empty" -msgstr "heap vacío" +msgstr "vacío" #: py/objdict.c:314 msgid "popitem(): dictionary is empty" @@ -1512,9 +1501,8 @@ msgid "dict update sequence has wrong length" msgstr "" #: py/objfloat.c:308 py/parsenum.c:331 -#, fuzzy msgid "complex values not supported" -msgstr "script de compilación no soportado" +msgstr "valores complejos no soportados" #: py/objgenerator.c:108 msgid "can't send non-None value to a just-started generator" @@ -1545,9 +1533,8 @@ msgid "float too big" msgstr "" #: py/objint.c:328 -#, fuzzy msgid "long int not supported in this build" -msgstr "AnalogOut no es soportado por el pin dado" +msgstr "long int no soportado en esta compilación" #: py/objint.c:334 py/objint.c:340 py/objint.c:350 py/objint.c:358 msgid "small int overflow" @@ -1586,9 +1573,8 @@ msgid "can't set attribute" msgstr "" #: py/objobject.c:55 -#, fuzzy msgid "__new__ arg must be a user-type" -msgstr "heap debe ser una lista" +msgstr "__new__ arg debe ser un user-type" #: py/objrange.c:110 msgid "zero step" @@ -1599,9 +1585,8 @@ msgid "pop from an empty set" msgstr "" #: py/objslice.c:66 -#, fuzzy msgid "Length must be an int" -msgstr "heap debe ser una lista" +msgstr "Length debe ser un int" #: py/objslice.c:71 msgid "Length must be non-negative" @@ -1616,9 +1601,8 @@ msgid "Cannot subclass slice" msgstr "" #: py/objstr.c:261 -#, fuzzy msgid "bytes value out of range" -msgstr "Valor de calibración fuera de rango +/-127" +msgstr "valor de bytes fuera de rango" #: py/objstr.c:270 msgid "wrong number of arguments" @@ -1629,18 +1613,16 @@ msgid "join expects a list of str/bytes objects consistent with self object" msgstr "" #: py/objstr.c:542 py/objstr.c:647 py/objstr.c:1744 -#, fuzzy msgid "empty separator" -msgstr "heap vacío" +msgstr "separator vacío" #: py/objstr.c:641 msgid "rsplit(None,n)" msgstr "" #: py/objstr.c:713 -#, fuzzy msgid "substring not found" -msgstr "módulo no encontrado" +msgstr "substring no encontrado" #: py/objstr.c:770 msgid "start/end indices" @@ -1681,14 +1663,12 @@ msgid "" msgstr "" #: py/objstr.c:1055 py/objstr.c:1083 -#, fuzzy msgid "tuple index out of range" -msgstr "struct: index fuera de rango" +msgstr "tuple index fuera de rango" #: py/objstr.c:1071 -#, fuzzy msgid "attributes not supported yet" -msgstr "bytes > 8 bits no soportados" +msgstr "atributos aún no soportados" #: py/objstr.c:1079 msgid "" @@ -1696,9 +1676,8 @@ msgid "" msgstr "" #: py/objstr.c:1171 -#, fuzzy msgid "invalid format specifier" -msgstr "formato inválido" +msgstr "especificador de formato inválido" #: py/objstr.c:1192 msgid "sign not allowed in string format specifier" @@ -1736,9 +1715,8 @@ msgid "incomplete format key" msgstr "" #: py/objstr.c:1482 -#, fuzzy msgid "incomplete format" -msgstr "formato inválido" +msgstr "formato incompleto" #: py/objstr.c:1490 msgid "not enough arguments for format string" @@ -1776,9 +1754,8 @@ msgid "string indices must be integers, not %s" msgstr "" #: py/objstrunicode.c:145 py/objstrunicode.c:164 -#, fuzzy msgid "string index out of range" -msgstr "struct: index fuera de rango" +msgstr "string index fuera de rango" #: py/objtype.c:358 msgid "__init__() should return None" @@ -1827,9 +1804,8 @@ msgid "type '%q' is not an acceptable base type" msgstr "" #: py/objtype.c:1137 -#, fuzzy msgid "multiple inheritance not supported" -msgstr "operación I2C no soportada" +msgstr "herencia multiple no soportada" #: py/objtype.c:1164 msgid "multiple bases have instance lay-out conflict" @@ -1848,14 +1824,12 @@ msgid "issubclass() arg 1 must be a class" msgstr "" #: py/parse.c:726 -#, fuzzy msgid "constant must be an integer" -msgstr "heap debe ser una lista" +msgstr "constant debe ser un entero" #: py/parse.c:868 -#, fuzzy msgid "Unable to init parser" -msgstr "No se pudo encontrar un GCLK disponible" +msgstr "Incapaz de inicializar el parser" #: py/parse.c:1170 msgid "unexpected indent" @@ -1871,7 +1845,7 @@ msgstr "" #: py/parsenum.c:151 msgid "invalid syntax for integer" -msgstr "formato inválido" +msgstr "sintaxis inválido para entero" #: py/parsenum.c:155 #, c-format @@ -1880,11 +1854,11 @@ msgstr "" #: py/parsenum.c:339 msgid "invalid syntax for number" -msgstr "argumentos inválidos" +msgstr "sintaxis inválido para número" #: py/parsenum.c:342 msgid "decimal numbers not supported" -msgstr "bytes > 8 bits no son soportados" +msgstr "números decimales no soportados" #: py/persistentcode.c:223 msgid "" @@ -1898,7 +1872,7 @@ msgstr "" #: py/runtime.c:206 msgid "name not defined" -msgstr "módulo no encontrado" +msgstr "name no definido" #: py/runtime.c:209 msgid "name '%q' is not defined" @@ -1973,9 +1947,8 @@ msgid "exceptions must derive from BaseException" msgstr "" #: py/runtime.c:1430 -#, fuzzy msgid "cannot import name %q" -msgstr "ningún módulo se llama '%q'" +msgstr "no se puede importar name '%q'" #: py/runtime.c:1535 msgid "memory allocation failed, heap is locked" @@ -1995,9 +1968,8 @@ msgid "object not in sequence" msgstr "" #: py/stream.c:96 -#, fuzzy msgid "stream operation not supported" -msgstr "operación I2C no soportada" +msgstr "operación stream no soportada" #: py/vm.c:255 msgid "local variable referenced before assignment" @@ -2144,7 +2116,6 @@ msgid "stop must be 1 or 2" msgstr "" #: shared-bindings/digitalio/DigitalInOut.c:211 -#, fuzzy msgid "Invalid direction." msgstr "Dirección inválida." @@ -2305,9 +2276,8 @@ msgid "index must be int" msgstr "" #: shared-bindings/pulseio/PulseIn.c:293 -#, fuzzy msgid "Read-only" -msgstr "Solo lectura" +msgstr "Solo-lectura" #: shared-bindings/pulseio/PulseOut.c:134 msgid "Array must contain halfwords (type 'H')" @@ -2472,14 +2442,12 @@ msgid "Group full" msgstr "" #: shared-module/displayio/Group.c:48 -#, fuzzy msgid "Group empty" -msgstr "heap vacío" +msgstr "Group vacío" #: shared-module/displayio/OnDiskBitmap.c:49 -#, fuzzy msgid "Invalid BMP file" -msgstr "pin inválido" +msgstr "Archivo BMP inválido" #: shared-module/displayio/OnDiskBitmap.c:59 #, c-format From ec1aec1921c55b7570403b2958dc0a8170fe78ab Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sun, 21 Oct 2018 10:22:00 -0500 Subject: [PATCH 31/42] shared-bindings/time: introduce time.monotonic_ns This is intended to be compatible with Python 3.7's time.monotonic_ns. The "actual resolution" is 1ms due to this being the unit at which common_hal_time_monotonic ticks. Closes #519 --- shared-bindings/time/__init__.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 4d95545690..8a5e16c5e4 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -206,6 +206,20 @@ STATIC mp_obj_t time_time(void) { } MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); +//| .. method:: monotonic_ns(clk_id) +//| +//| Return the time of the specified clock clk_id in nanoseconds. Refer to +//| Clock ID Constants for a list of accepted values for clk_id. +//| +//| :return: the current time +//| :rtype: int +//| +STATIC mp_obj_t time_monotonic_ns(void) { + uint64_t time64 = common_hal_time_monotonic() * 1000000llu; + return mp_obj_new_int_from_ll((long long) time64); +} +MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns); + //| .. method:: localtime([secs]) //| //| Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in @@ -280,6 +294,7 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = { #endif // MICROPY_PY_COLLECTIONS #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&time_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_monotonic_ns), MP_ROM_PTR(&time_monotonic_ns_obj) }, #endif }; From c16ef428ab31fbaeb6534e7ca56abb9591a2a6b7 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 21 Oct 2018 11:38:16 -0500 Subject: [PATCH 32/42] [locale\es.po] Address @sabas1080 recommendations --- locale/es.po | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/locale/es.po b/locale/es.po index 59b8d6353c..a7f7e6738e 100644 --- a/locale/es.po +++ b/locale/es.po @@ -169,7 +169,7 @@ msgstr "Ejecutando en modo seguro! La auto-recarga esta deshabilitada.\n" #: main.c:161 main.c:232 msgid "Auto-reload is off.\n" -msgstr "Auto-recarga deshabilitado.\n" +msgstr "Auto-recarga deshabilitada.\n" #: main.c:175 msgid "Running in safe mode! Not running saved code.\n" @@ -400,7 +400,7 @@ msgstr "Ha fallado la asignación del buffer RX" #: ports/atmel-samd/common-hal/busio/UART.c:153 msgid "Could not initialize UART" -msgstr "No se pudo inicializar la UART" +msgstr "No se puede inicializar la UART" #: ports/atmel-samd/common-hal/busio/UART.c:240 #: ports/nrf/common-hal/busio/UART.c:149 @@ -1344,7 +1344,7 @@ msgstr "Operacion no soportada" #: py/moduerrno.c:149 msgid "Invalid argument" -msgstr "argumento inválido" +msgstr "Argumento inválido" #: py/obj.c:90 msgid "Traceback (most recent call last):\n" From 71ac9d16a7b2cb9d5ec758b4cd6fdcf3ec22184b Mon Sep 17 00:00:00 2001 From: Carlos Date: Sun, 21 Oct 2018 11:56:05 -0500 Subject: [PATCH 33/42] [locale\es.po] Add missing \n --- locale/es.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/es.po b/locale/es.po index a7f7e6738e..d4570cb09f 100644 --- a/locale/es.po +++ b/locale/es.po @@ -210,7 +210,7 @@ msgstr "" msgid "" "The microcontroller's power dipped. Please make sure your power supply " "provides\n" -msgstr "La alimentación del microcontrolador cayó. Por favor asegurate de que tu fuente de alimentación provee" +msgstr "La alimentación del microcontrolador cayó. Por favor asegurate de que tu fuente de alimentación provee\n" #: main.c:256 msgid "" From 59e43a2be4e740b65ae19b708c8e9670fa04fc05 Mon Sep 17 00:00:00 2001 From: Joshua Lowe Date: Tue, 23 Oct 2018 16:05:07 +0100 Subject: [PATCH 34/42] Update README to include Hallowing --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index ac74f10d6c..1364ba6b2d 100644 --- a/README.rst +++ b/README.rst @@ -37,6 +37,7 @@ Designed for CircuitPython - `Adafruit ItsyBitsy M0 Express `_ (`CircuitPython Guide `__) - `Adafruit Trinket M0 `__ (`CircuitPython Guide `__) - `Adafruit Metro M4 `__ (`CircuitPython Guide `__) +- `Adafruit Hallowing M0 Express `__ (`CircuitPython Guide `__) Other ~~~~~ From 41f62d84cb157bdaf612ec2da80afabd60d7a98f Mon Sep 17 00:00:00 2001 From: Joshua Lowe Date: Tue, 23 Oct 2018 17:27:54 +0100 Subject: [PATCH 35/42] Update README.rst --- README.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 1364ba6b2d..a9b82bbe6f 100644 --- a/README.rst +++ b/README.rst @@ -30,14 +30,19 @@ Supported Boards Designed for CircuitPython ~~~~~~~~~~~~~~~~~~~~~~~~~~ +**M0 Boards** - `Adafruit CircuitPlayground Express `__ (`CircuitPython Guide `__) - `Adafruit Feather M0 Express `__ (`CircuitPython Guide `__) -- `Adafruit Metro M0 Express `_ (`CircuitPython Guide `__) - `Adafruit Gemma M0 `__ (`CircuitPython Guide `__) -- `Adafruit ItsyBitsy M0 Express `_ (`CircuitPython Guide `__) -- `Adafruit Trinket M0 `__ (`CircuitPython Guide `__) -- `Adafruit Metro M4 `__ (`CircuitPython Guide `__) - `Adafruit Hallowing M0 Express `__ (`CircuitPython Guide `__) +- `Adafruit ItsyBitsy M0 Express `_ (`CircuitPython Guide `__) +- `Adafruit Metro M0 Express `_ (`CircuitPython Guide `__) +- `Adafruit Trinket M0 `__ (`CircuitPython Guide `__) + +**M4 Boards** +- `Adafruit Feather M4 Express `__ (`CircuitPython Guide `__) +- `Adafruit ItsyBitsy M4 Express `__ (`CircuitPython Guide `__) +- `Adafruit Metro M4 `__ (`CircuitPython Guide `__) Other ~~~~~ From cb47d9edee687aa67195ddc949ff8c52cfb87881 Mon Sep 17 00:00:00 2001 From: Joshua Lowe Date: Tue, 23 Oct 2018 17:28:30 +0100 Subject: [PATCH 36/42] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index a9b82bbe6f..410f6cf8af 100644 --- a/README.rst +++ b/README.rst @@ -31,6 +31,7 @@ Designed for CircuitPython ~~~~~~~~~~~~~~~~~~~~~~~~~~ **M0 Boards** + - `Adafruit CircuitPlayground Express `__ (`CircuitPython Guide `__) - `Adafruit Feather M0 Express `__ (`CircuitPython Guide `__) - `Adafruit Gemma M0 `__ (`CircuitPython Guide `__) @@ -40,6 +41,7 @@ Designed for CircuitPython - `Adafruit Trinket M0 `__ (`CircuitPython Guide `__) **M4 Boards** + - `Adafruit Feather M4 Express `__ (`CircuitPython Guide `__) - `Adafruit ItsyBitsy M4 Express `__ (`CircuitPython Guide `__) - `Adafruit Metro M4 `__ (`CircuitPython Guide `__) From 1936cd3f386e78cdd0d566fb3d5e7aa047ca7d48 Mon Sep 17 00:00:00 2001 From: Joshua Lowe Date: Tue, 23 Oct 2018 17:30:53 +0100 Subject: [PATCH 37/42] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 410f6cf8af..f3ee34f349 100644 --- a/README.rst +++ b/README.rst @@ -44,7 +44,7 @@ Designed for CircuitPython - `Adafruit Feather M4 Express `__ (`CircuitPython Guide `__) - `Adafruit ItsyBitsy M4 Express `__ (`CircuitPython Guide `__) -- `Adafruit Metro M4 `__ (`CircuitPython Guide `__) +- `Adafruit Metro M4 `__ (`CircuitPython Guide `__) Other ~~~~~ From e02811054e726cae590938b111ffcf640c0b3704 Mon Sep 17 00:00:00 2001 From: Joshua Lowe Date: Tue, 23 Oct 2018 18:17:50 +0100 Subject: [PATCH 38/42] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index f3ee34f349..e89543fe56 100644 --- a/README.rst +++ b/README.rst @@ -44,7 +44,7 @@ Designed for CircuitPython - `Adafruit Feather M4 Express `__ (`CircuitPython Guide `__) - `Adafruit ItsyBitsy M4 Express `__ (`CircuitPython Guide `__) -- `Adafruit Metro M4 `__ (`CircuitPython Guide `__) +- `Adafruit Metro M4 Express `__ (`CircuitPython Guide `__) Other ~~~~~ From fbadfd599810cb1ebc93e4915f5b6d63cecbc75a Mon Sep 17 00:00:00 2001 From: Senuros Date: Wed, 24 Oct 2018 11:39:16 +0200 Subject: [PATCH 39/42] added more german translation strings, fixed some existing translation strings --- locale/de_DE.po | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/locale/de_DE.po b/locale/de_DE.po index de9a21e960..0f8aee8462 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -93,7 +93,7 @@ msgstr "struct: index außerhalb gültigen Bereichs" #: extmod/moduheapq.c:38 msgid "heap must be a list" -msgstr "heap muss eine list sein" +msgstr "heap muss eine Liste sein" #: extmod/moduheapq.c:86 extmod/modutimeq.c:147 extmod/modutimeq.c:172 msgid "empty heap" @@ -185,12 +185,12 @@ msgstr "Du hast das Starten im Sicherheitsmodus ausgelöst durch " #: main.c:242 msgid "To exit, please reset the board without " -msgstr "Zum beenden bitte resete das board ohne " +msgstr "Zum beenden bitte resette das board ohne " #: main.c:249 msgid "" "You are running in safe mode which means something really bad happened.\n" -msgstr "Sicherheitsmodus aktive, etwas wirklich schlechtes ist passiert.\n" +msgstr "Sicherheitsmodus aktiv, etwas wirklich schlechtes ist passiert.\n" #: main.c:251 msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n" @@ -215,7 +215,7 @@ msgid "" "CIRCUITPY).\n" msgstr "" "genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach " -"demsicheren Auswerfen von CIRCUITPY.)\n" +"dem sicheren Auswerfen von CIRCUITPY.)\n" #: main.c:260 msgid "Press any key to enter the REPL. Use CTRL-D to reload." @@ -225,7 +225,7 @@ msgstr "" #: main.c:416 msgid "soft reboot\n" -msgstr "weicher reboot\n" +msgstr "soft reboot\n" #: ports/atmel-samd/audio_dma.c:209 #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:361 @@ -268,7 +268,7 @@ msgstr "AnalogOut ist an diesem Pin nicht unterstützt" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:147 #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:150 msgid "Invalid bit clock pin" -msgstr "Ungülgites bit clock pin" +msgstr "Ungültiges bit clock pin" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:153 msgid "Bit clock and word select must share a clock unit" @@ -284,7 +284,7 @@ msgstr "Ungültiger data pin" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:145 #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c:150 msgid "Serializer in use" -msgstr "Serilaizer wird benutzt" +msgstr "Serializer wird benutzt" #: ports/atmel-samd/common-hal/audiobusio/I2SOut.c:230 msgid "Clock unit in use" @@ -355,7 +355,7 @@ msgstr "Alle timer werden benutzt" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:218 msgid "All event channels in use" -msgstr "Alle event Kanälre werden benutzt" +msgstr "Alle event Kanäle werden benutzt" #: ports/atmel-samd/common-hal/audioio/AudioOut.c:297 #, c-format @@ -380,7 +380,7 @@ msgstr "SDA oder SCL brauchen pull up" #: ports/atmel-samd/common-hal/busio/I2C.c:121 msgid "Unsupported baudrate" -msgstr "Baudrate wird nicht unterstütz" +msgstr "Baudrate wird nicht unterstützt" #: ports/atmel-samd/common-hal/busio/UART.c:66 msgid "bytes > 8 bits not supported" @@ -545,24 +545,24 @@ msgstr "Minimale PWM Frequenz ist %dHz" #: ports/esp8266/common-hal/pulseio/PWMOut.c:68 #, c-format msgid "Multiple PWM frequencies not supported. PWM already set to %dhz." -msgstr "" +msgstr "Mehrere PWM Frequenzen nicht unterstützt. PWM bereits auf %dHz gesetzt." #: ports/esp8266/common-hal/pulseio/PWMOut.c:77 ports/esp8266/machine_pwm.c:70 #, c-format msgid "PWM not supported on pin %d" -msgstr "" +msgstr "PWM nicht unterstützt an Pin %d" #: ports/esp8266/common-hal/pulseio/PulseIn.c:78 msgid "No PulseIn support for %q" -msgstr "" +msgstr "Keine PulseIn Unterstützung für %q" #: ports/esp8266/common-hal/storage/__init__.c:34 msgid "Unable to remount filesystem" -msgstr "" +msgstr "Dateisystem kann nicht wieder gemounted werden." #: ports/esp8266/common-hal/storage/__init__.c:38 msgid "Use esptool to erase flash and re-upload Python instead" -msgstr "" +msgstr "Benutze esptool um den flash zu löschen und stattdessen Python hochzuladen" #: ports/esp8266/esp_mphal.c:154 msgid "C-level assert" @@ -571,102 +571,102 @@ msgstr "" #: ports/esp8266/machine_adc.c:57 #, c-format msgid "not a valid ADC Channel: %d" -msgstr "" +msgstr "Kein gültiger ADC Kanal: %d" #: ports/esp8266/machine_hspi.c:131 ports/esp8266/machine_hspi.c:137 msgid "impossible baudrate" -msgstr "" +msgstr "Unmögliche Baudrate" #: ports/esp8266/machine_pin.c:129 msgid "expecting a pin" -msgstr "" +msgstr "Ein Pin wird erwartet" #: ports/esp8266/machine_pin.c:284 msgid "Pin(16) doesn't support pull" -msgstr "" +msgstr "Pin(16) unterstützt kein pull" #: ports/esp8266/machine_pin.c:323 msgid "invalid pin" -msgstr "" +msgstr "Ungültiger Pin" #: ports/esp8266/machine_pin.c:389 msgid "pin does not have IRQ capabilities" -msgstr "" +msgstr "Pin hat keine IRQ Fähigkeiten" #: ports/esp8266/machine_rtc.c:185 msgid "buffer too long" -msgstr "" +msgstr "Buffer zu lang" #: ports/esp8266/machine_rtc.c:209 ports/esp8266/machine_rtc.c:223 #: ports/esp8266/machine_rtc.c:246 msgid "invalid alarm" -msgstr "" +msgstr "Ungültiger Alarm" #: ports/esp8266/machine_uart.c:169 #, c-format msgid "UART(%d) does not exist" -msgstr "" +msgstr "UART(%d) existiert nicht" #: ports/esp8266/machine_uart.c:219 msgid "UART(1) can't read" -msgstr "" +msgstr "UART(1) kann nicht lesen" #: ports/esp8266/modesp.c:119 msgid "len must be multiple of 4" -msgstr "" +msgstr "len muss ein vielfaches von 4 sein" #: ports/esp8266/modesp.c:274 #, c-format msgid "memory allocation failed, allocating %u bytes for native code" -msgstr "" +msgstr "Speicherallozierung fehlgeschlagen, alloziere %u Bytes für nativen Code" #: ports/esp8266/modesp.c:317 msgid "flash location must be below 1MByte" -msgstr "" +msgstr "flash location muss unter 1MByte sein" #: ports/esp8266/modmachine.c:63 msgid "frequency can only be either 80Mhz or 160MHz" -msgstr "" +msgstr "Die Frequenz kann nur 80Mhz oder 160Mhz sein" #: ports/esp8266/modnetwork.c:61 msgid "AP required" -msgstr "" +msgstr "AP erforderlich" #: ports/esp8266/modnetwork.c:61 msgid "STA required" -msgstr "" +msgstr "STA erforderlich" #: ports/esp8266/modnetwork.c:87 msgid "Cannot update i/f status" -msgstr "" +msgstr "Kann i/f Status nicht updaten" #: ports/esp8266/modnetwork.c:142 msgid "Cannot set STA config" -msgstr "" +msgstr "Kann STA Konfiguration nicht setzen" #: ports/esp8266/modnetwork.c:144 msgid "Cannot connect to AP" -msgstr "" +msgstr "Kann nicht zu AP verbinden" #: ports/esp8266/modnetwork.c:152 msgid "Cannot disconnect from AP" -msgstr "" +msgstr "Kann nicht trennen von AP" #: ports/esp8266/modnetwork.c:173 msgid "unknown status param" -msgstr "" +msgstr "Unbekannter Statusparameter" #: ports/esp8266/modnetwork.c:222 msgid "STA must be active" -msgstr "" +msgstr "STA muss aktiv sein" #: ports/esp8266/modnetwork.c:239 msgid "scan failed" -msgstr "" +msgstr "Scan fehlgeschlagen" #: ports/esp8266/modnetwork.c:306 msgid "wifi_set_ip_info() failed" -msgstr "" +msgstr "wifi_set_ip_info() fehlgeschlagen" #: ports/esp8266/modnetwork.c:319 msgid "either pos or kw args are allowed" From cec9a69a15a16a42bea528032d00684ddee0df22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sun, 7 Oct 2018 19:51:24 +0200 Subject: [PATCH 40/42] samd51: Make errno, os, and time module aliases Add alias for uerrno so the user doesn't have to know about the CircuitPython special names for the module. Make os and time weak modules (aliases) making it possible to add functionality to those modules written in python. Example: 'import os' will now look in the path for an os module and if not found it will import the builtin module. An os module written in python will import the builtin module through its name prefixed with an underscore (_os) following the C module naming practice in CPython. Also right align the macro values to increase readability making it easier to compare the values for samd21 and samd51. Even the longest macro from py/mpconfig.h will fit with this alignment. --- ports/atmel-samd/mpconfigport.h | 38 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 14f72ccfb0..afdbf0cd82 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -84,7 +84,6 @@ #define MICROPY_VFS (1) #define MICROPY_VFS_FAT (1) #define MICROPY_PY_MACHINE (1) -#define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_HW_ENABLE_DAC (1) #define MICROPY_ENABLE_FINALISER (1) @@ -140,15 +139,17 @@ typedef long mp_off_t; #include "include/sam.h" #ifdef SAMD21 -#define CIRCUITPY_MCU_FAMILY samd21 +#define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" -#define PORT_HEAP_SIZE (16384 + 4096) +#define PORT_HEAP_SIZE (16384 + 4096) +#define MICROPY_MODULE_WEAK_LINKS (0) #endif #ifdef SAMD51 -#define CIRCUITPY_MCU_FAMILY samd51 +#define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" -#define PORT_HEAP_SIZE (0x20000) // 128KiB +#define PORT_HEAP_SIZE (0x20000) // 128KiB +#define MICROPY_MODULE_WEAK_LINKS (1) #endif #ifdef LONGINT_IMPL_NONE @@ -290,6 +291,33 @@ extern const struct _mp_obj_module_t usb_hid_module; { MP_OBJ_NEW_QSTR(MP_QSTR_supervisor), (mp_obj_t)&supervisor_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, +#elif MICROPY_MODULE_WEAK_LINKS +#define MICROPY_PORT_BUILTIN_MODULES \ + { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_neopixel_write),(mp_obj_t)&neopixel_write_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&os_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_rtc), (mp_obj_t)&rtc_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_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 }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \ + TOUCHIO_MODULE \ + EXTRA_BUILTIN_MODULES + +#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ + { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \ + { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&os_module) }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ + #else #define MICROPY_PORT_BUILTIN_MODULES \ { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ From 1b86e5fc8362a913a0ef7de01cce68c980238fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sun, 7 Oct 2018 20:43:39 +0200 Subject: [PATCH 41/42] samd51: Enable functionality to support CPython stdlib This enables various things in order to support the CPython standard library. MICROPY_PY_BUILTINS_NOTIMPLEMENTED: Support NotImplemented for easy conversion of stdlib. It doesn't do fallbacks though, only raises TypeError. MICROPY_PY_COLLECTIONS_ORDEREDDICT: collections.OrderedDict MICROPY_PY_FUNCTION_ATTRS: Support function.__name__ for use as key in the function attribute workaround. MICROPY_PY_IO: uio module: BytesIO, FileIO, StringIO, TextIOWrapper Also add 'io' alias. MICROPY_PY_REVERSE_SPECIAL_METHODS: Support the __r*__ special methods. MICROPY_PY_SYS_EXC_INFO: sys.exc_info() used by unittest when collecting exceptions. MICROPY_CPYTHON_COMPAT: Some of the things it adds: >>> object.__init__ >>> object.__new__ >>> object.__class__ >>> object().__class__ >>> object.__name__ 'object' >>> 'Hello'.encode() b'Hello' >>> b'Hello'.decode() 'Hello' Named tuple field names from string: namedtuple('Point', 'x y') --- ports/atmel-samd/mpconfigport.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index afdbf0cd82..38eabf7480 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -20,8 +20,6 @@ #define MICROPY_COMP_CONST (1) #define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) -// Turn off for consistency -#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_MEM_STATS (0) #define MICROPY_DEBUG_PRINTERS (0) #define MICROPY_ENABLE_GC (1) @@ -57,7 +55,6 @@ #define MICROPY_PY_DESCRIPTORS (1) #define MICROPY_PY_MATH (0) #define MICROPY_PY_CMATH (0) -#define MICROPY_PY_IO (0) #define MICROPY_PY_URANDOM (0) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) #define MICROPY_PY_STRUCT (0) @@ -142,14 +139,28 @@ typedef long mp_off_t; #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define PORT_HEAP_SIZE (16384 + 4096) +#define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_MODULE_WEAK_LINKS (0) +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#define MICROPY_PY_FUNCTION_ATTRS (0) +#define MICROPY_PY_IO (0) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) +#define MICROPY_PY_SYS_EXC_INFO (0) #endif #ifdef SAMD51 #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #define PORT_HEAP_SIZE (0x20000) // 128KiB +#define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_MODULE_WEAK_LINKS (1) +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1) +#define MICROPY_PY_FUNCTION_ATTRS (1) +#define MICROPY_PY_IO (1) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) +#define MICROPY_PY_SYS_EXC_INFO (1) #endif #ifdef LONGINT_IMPL_NONE @@ -315,6 +326,7 @@ extern const struct _mp_obj_module_t usb_hid_module; #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, \ + { MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) }, \ { MP_ROM_QSTR(MP_QSTR_os), MP_ROM_PTR(&os_module) }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ From d882ff6328f0c0afee75f202ca7a87ffad252b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Date: Sun, 7 Oct 2018 21:54:53 +0200 Subject: [PATCH 42/42] samd51: Set stack size to 8k This is necessary in order to run unittest. Heavy tests like those in the stdlib need 12-14k. --- ports/atmel-samd/mpconfigport.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index 38eabf7480..7b54a418df 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -139,6 +139,7 @@ typedef long mp_off_t; #define CIRCUITPY_MCU_FAMILY samd21 #define MICROPY_PY_SYS_PLATFORM "Atmel SAMD21" #define PORT_HEAP_SIZE (16384 + 4096) +#define CIRCUITPY_DEFAULT_STACK_SIZE 4096 #define MICROPY_CPYTHON_COMPAT (0) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) @@ -153,6 +154,7 @@ typedef long mp_off_t; #define CIRCUITPY_MCU_FAMILY samd51 #define MICROPY_PY_SYS_PLATFORM "MicroChip SAMD51" #define PORT_HEAP_SIZE (0x20000) // 128KiB +#define CIRCUITPY_DEFAULT_STACK_SIZE 8192 #define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_MODULE_WEAK_LINKS (1) #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) @@ -400,8 +402,4 @@ void run_background_tasks(void); #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 #define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt" -// TODO(tannewt): Make this 6k+ for any non-express M4 boards because they cache sectors on the -// stack. -#define CIRCUITPY_DEFAULT_STACK_SIZE 4096 - #endif // __INCLUDED_MPCONFIGPORT_H