Merge branch 'master' into non-standard-nvm

This commit is contained in:
Dan Halbert 2020-05-04 16:08:45 -04:00 committed by GitHub
commit c377d4bea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
239 changed files with 11952 additions and 7394 deletions

View File

@ -10,7 +10,7 @@ on:
jobs:
test:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
steps:
- name: Dump GitHub context
env:
@ -127,7 +127,7 @@ jobs:
path: mpy-cross/mpy-cross
build-arm:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
needs: test
strategy:
fail-fast: false
@ -206,11 +206,13 @@ jobs:
- "nucleo_h743zi_2"
- "ohs2020_badge"
- "openbook_m4"
- "openmv_h7"
- "particle_argon"
- "particle_boron"
- "particle_xenon"
- "pca10056"
- "pca10059"
- "pca10100"
- "pewpew10"
- "pewpew_m4"
- "pirkey_m0"
@ -230,6 +232,7 @@ jobs:
- "seeeduino_xiao"
- "serpente"
- "shirtty"
- "simmel"
- "snekboard"
- "sparkfun_lumidrive"
- "sparkfun_nrf52840_mini"
@ -244,7 +247,7 @@ jobs:
- "stm32f411ve_discovery"
- "stm32f412zg_discovery"
- "stm32f4_discovery"
- "stm32f746g_disco"
- "stm32f746g_discovery"
- "stringcar_m0_express"
- "teensy40"
- "teknikio_bluebird"
@ -303,7 +306,7 @@ jobs:
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
build-riscv:
runs-on: ubuntu-16.04
runs-on: ubuntu-18.04
needs: test
strategy:
fail-fast: false

18
.gitmodules vendored
View File

@ -122,3 +122,21 @@
[submodule "lib/protomatter"]
path = lib/protomatter
url = https://github.com/adafruit/Adafruit_Protomatter
[submodule "frozen/Adafruit_CircuitPython_LSM6DS"]
path = frozen/Adafruit_CircuitPython_LSM6DS
url = https://github.com/adafruit/Adafruit_CircuitPython_LSM6DS
[submodule "frozen/Adafruit_CircuitPython_FocalTouch"]
path = frozen/Adafruit_CircuitPython_FocalTouch
url = https://github.com/adafruit/Adafruit_CircuitPython_FocalTouch
[submodule "frozen/Adafruit_CircuitPython_DS3231"]
path = frozen/Adafruit_CircuitPython_DS3231
url = https://github.com/adafruit/Adafruit_CircuitPython_DS3231
[submodule "frozen/Adafruit_CircuitPython_DRV2605"]
path = frozen/Adafruit_CircuitPython_DRV2605
url = https://github.com/adafruit/Adafruit_CircuitPython_DRV2605
[submodule "frozen/Adafruit_CircuitPython_BLE"]
path = frozen/Adafruit_CircuitPython_BLE
url = https://github.com/adafruit/Adafruit_CircuitPython_BLE
[submodule "frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center"]
path = frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center
url = https://github.com/adafruit/Adafruit_CircuitPython_BLE_Apple_Notification_Center

View File

@ -1,14 +1,19 @@
Supported Ports
==============================
Adafruit's CircuitPython currently has limited support with a focus on supporting the Atmel SAMD
and ESP8266.
CircuitPython supports a number of microcontroller families. Support quality for each varies
depending on the active contributors for each port.
Adafruit sponsored developers are actively contributing to atmel-samd, mimxrt10xx, nrf and stm
ports. They also maintain the other ports in order to ensure the boards build. Additional testing
is limited.
.. toctree::
:maxdepth: 2
../ports/atmel-samd/README
../ports/cxd56/README
../ports/litex/README
../ports/mimxrt10xx/README
../ports/nrf/README
../ports/stm/README
../ports/cxd56/README

@ -1 +1 @@
Subproject commit a746bd8e0953853056ee405e2fa02c8ebca4fb79
Subproject commit cf61d728e70b9ec57e5711b40540793a89296f5d

@ -0,0 +1 @@
Subproject commit 96774b15da61da54662bcfbbf15b5bdc27315a9f

@ -0,0 +1 @@
Subproject commit 3ffb3f02d2046910e09d1f5a74721bd1a4cdf8cf

@ -0,0 +1 @@
Subproject commit 7914a6390318687bb8e2e9c4119aa932fea01531

@ -0,0 +1 @@
Subproject commit 0d49a1fcd96c13a94e8bdf26f92abe79b8517906

@ -0,0 +1 @@
Subproject commit 72968d3546f9d6c5af138d4c179343007cb9662c

@ -0,0 +1 @@
Subproject commit 24224cc905fad4646506caeb2451b4a495804ffc

@ -1 +1 @@
Subproject commit c59fa774274b13790a3ae0fc19d9651eeba560ab
Subproject commit a74a823b0a140667a4e4e80fa2678870faba2bd0

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -285,11 +285,12 @@ msgstr "Semua timer untuk pin ini sedang digunakan"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Semua timer sedang digunakan"
@ -1242,6 +1243,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2215,6 +2220,10 @@ msgstr "fungsi diharapkan setidaknya %d argumen, hanya mendapatkan %d"
msgid "function got multiple values for argument '%q'"
msgstr "fungsi mendapatkan nilai ganda untuk argumen '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2704,7 +2713,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -283,11 +283,12 @@ msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr ""
@ -1228,6 +1229,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2191,6 +2196,10 @@ msgstr ""
msgid "function got multiple values for argument '%q'"
msgstr ""
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2679,7 +2688,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -285,11 +285,12 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Alle timer werden benutzt"
@ -1245,6 +1246,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull wird nicht verwendet, wenn die Richtung output ist."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2220,6 +2225,10 @@ msgstr "Funktion erwartet maximal %d Argumente, aber hat %d erhalten"
msgid "function got multiple values for argument '%q'"
msgstr "Funktion hat mehrere Werte für Argument '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2715,7 +2724,8 @@ msgstr "nur eine sample_rate=16000 wird unterstützt"
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -283,11 +283,12 @@ msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr ""
@ -1228,6 +1229,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2191,6 +2196,10 @@ msgstr ""
msgid "function got multiple values for argument '%q'"
msgstr ""
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2679,7 +2688,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -285,11 +285,12 @@ msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr ""
@ -1232,6 +1233,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2195,6 +2200,10 @@ msgstr ""
msgid "function got multiple values for argument '%q'"
msgstr ""
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2683,7 +2692,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -287,11 +287,12 @@ msgstr "Todos los timers para este pin están siendo utilizados"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Todos los timers en uso"
@ -1244,6 +1245,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull no se usa cuando la dirección es output."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2222,6 +2227,10 @@ msgstr "la función esperaba minimo %d argumentos, tiene %d"
msgid "function got multiple values for argument '%q'"
msgstr "la función tiene múltiples valores para el argumento '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2717,7 +2726,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr "solo se admiten segmentos con step=1 (alias None)"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -287,11 +287,12 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Lahat ng timer ginagamit"
@ -1250,6 +1251,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull hindi ginagamit kapag ang direksyon ay output."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2236,6 +2241,10 @@ msgstr "function na inaasahang %d ang argumento, ngunit %d ang nakuha"
msgid "function got multiple values for argument '%q'"
msgstr "ang function ay nakakuha ng maraming values para sa argument '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2730,7 +2739,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -290,11 +290,12 @@ msgstr "Tous les timers pour cette broche sont utilisés"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Tous les timers sont utilisés"
@ -1263,6 +1264,10 @@ msgstr "Appuyez sur une touche pour entrer sur REPL ou CTRL-D pour recharger."
msgid "Pull not used when direction is output."
msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2261,6 +2266,10 @@ msgstr "la fonction attendait au plus %d arguments, reçu %d"
msgid "function got multiple values for argument '%q'"
msgstr "la fonction a reçu plusieurs valeurs pour l'argument '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2757,7 +2766,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr "seules les tranches avec 'step=1' (cad None) sont supportées"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -286,11 +286,12 @@ msgstr "Tutti i timer per questo pin sono in uso"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Tutti i timer utilizzati"
@ -1259,6 +1260,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2237,6 +2242,10 @@ msgstr "la funzione prevede al massimo %d argmoneti, ma ne ha ricevuti %d"
msgid "function got multiple values for argument '%q'"
msgstr "la funzione ha ricevuto valori multipli per l'argomento '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2735,7 +2744,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr "solo slice con step=1 (aka None) sono supportate"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -285,11 +285,12 @@ msgstr "핀의 모든 타이머가 사용 중입니다"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "모든 타이머가 사용 중입니다"
@ -1232,6 +1233,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2196,6 +2201,10 @@ msgstr ""
msgid "function got multiple values for argument '%q'"
msgstr ""
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2684,7 +2693,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -284,11 +284,12 @@ msgstr "Wszystkie timery tej nóżki w użyciu"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Wszystkie timery w użyciu"
@ -1233,6 +1234,10 @@ msgstr "Dowolny klawisz aby uruchomić konsolę. CTRL-D aby przeładować."
msgid "Pull not used when direction is output."
msgstr "Podciągnięcie nieużywane w trybie wyjścia."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2200,6 +2205,10 @@ msgstr "funkcja bierze najwyżej %d argumentów, jest %d"
msgid "function got multiple values for argument '%q'"
msgstr "funkcja dostała wiele wartości dla argumentu '%q'"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2688,7 +2697,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr "tylko fragmenty ze step=1 (lub None) są wspierane"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -286,11 +286,12 @@ msgstr "Todos os temporizadores para este pino estão em uso"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Todos os temporizadores em uso"
@ -1244,6 +1245,10 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2213,6 +2218,10 @@ msgstr "função esperada na maioria dos %d argumentos, obteve %d"
msgid "function got multiple values for argument '%q'"
msgstr ""
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2701,7 +2710,8 @@ msgstr ""
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-17 18:44-0500\n"
"POT-Creation-Date: 2020-04-27 18:34-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -290,11 +290,12 @@ msgstr "Cǐ yǐn jiǎo de suǒyǒu jìshí qì zhèngzài shǐyòng"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/peripherals/nrf/timers.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
#: shared-bindings/pulseio/PWMOut.c shared-module/_pew/PewPew.c
msgid "All timers in use"
msgstr "Suǒyǒu jìshí qì shǐyòng"
@ -1247,6 +1248,10 @@ msgstr "Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzà
msgid "Pull not used when direction is output."
msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@ -2228,6 +2233,10 @@ msgstr "hánshù yùjì zuìduō %d cānshù, huòdé %d"
msgid "function got multiple values for argument '%q'"
msgstr "hánshù huòdé cānshù '%q' de duōchóng zhí"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
msgstr ""
#: py/argcheck.c
#, c-format
msgid "function missing %d required positional arguments"
@ -2718,7 +2727,8 @@ msgstr "Jǐn zhīchí cǎiyàng lǜ = 16000"
msgid "only slices with step=1 (aka None) are supported"
msgstr "jǐn zhīchí bù zhǎng = 1(jí wú) de qiēpiàn"
#: extmod/ulab/code/ndarray.c extmod/ulab/code/vectorise.c
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
msgstr ""

2
main.c
View File

@ -428,7 +428,7 @@ int __attribute__((used)) main(void) {
filesystem_init(safe_mode == NO_SAFE_MODE, false);
// displays init after filesystem, since they could share the flash SPI
board_init();
board_init();
// Reset everything and prep MicroPython to run boot.py.
reset_port();

View File

@ -194,7 +194,6 @@ SRC_ASF := \
hpl/gclk/hpl_gclk.c \
hpl/nvmctrl/hpl_nvmctrl.c \
hpl/pm/hpl_pm.c \
hpl/rtc/hpl_rtc.c \
hpl/sercom/hpl_sercom.c \
hpl/systick/hpl_systick.c \
hal/utils/src/utils_list.c \
@ -258,7 +257,6 @@ SRC_C = \
peripherals/samd/timers.c \
reset.c \
supervisor/shared/memory.c \
tick.c \
timer_handler.c \
@ -306,7 +304,6 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
# Doing a $(sort ...) removes duplicates as part of sorting.
SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
SRC_S = supervisor/$(CHIP_FAMILY)_cpu.s
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))

View File

@ -1,243 +1,21 @@
SAMD21x18
=========
SAMD21 and SAMD51
==================
This port brings MicroPython to SAMD21x18 based development boards under the name
CircuitPython. Supported boards include:
This port supports many development boards that utilize SAMD21 and SAMD51 chips. See
https://circuitpython.org/downloads for all supported boards.
- Adafruit CircuitPlayground Express
- Adafruit Feather M0 Basic
- Adafruit Feather M0 Express
- Adafruit Metro M0 Express
- Adafruit M0 Bluefruit LE
- Arduino Zero
- Arduino MKR Zero
- Arduino Nano 33 IoT
Pinout
------
All of the boards share the same core pin functionality but call pins by
different names. The table below matches the pin order in
`the datasheet <http://ww1.microchip.com/downloads/en/DeviceDoc/40001882A.pdf>`_
and omits the pins only available on the largest package because all supported
boards use smaller version.
===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================
`microcontroller.pin` `board`
--------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Datasheet arduino_mkrzero arduino_nano_33_iot arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express sparkfun_samd21_mini sparkfun_samd21_dev trinket_m0
===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================
PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI``
PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK``
PA02 ``A0`` ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``A0`` ``A0`` ``D1`` / ``A0``
PA03
PB08 ``L`` ``A4`` / ``SDA`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1``
PB09 ``BATTERY`` ``A5`` / ``SCL`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2``
PA04 ``A3`` ``D6`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` ``A3`` ``A3``
PA05 ``A4`` ``D5`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4`` ``A4``
PA06 ``A5`` ``D7`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D8`` ``D8`` ``D4`` / ``TX``
PA07 ``A6`` ``D4`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX``
PA08 ``D11`` / ``SDA`` ``ESP_RESET`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D4`` ``D0`` / ``SDA``
PA09 ``D12`` / ``SCL`` ``A6`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D3`` ``D3`` ``D2`` / ``SCL``
PA10 ``D2`` ``A3`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13``
PA11 ``D3`` ``A2`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX``
PB10 ``D4`` ``D2`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI``
PB11 ``D5`` ``D3`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK``
PA12 ``SD_MOSI`` ``ESP_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO`` ``MISO``
PA13 ``SD_SCK`` ``ESP_MISO`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS`` ``D38``
PA14 ``SD_CS`` ``ESP_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2`` ``D2``
PA15 ``SD_MISO`` ``ESP_SCK`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5``
PA16 ``D8`` / ``MOSI`` ``D11`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` ``D11`` / ``MOSI`` ``D11``
PA17 ``D9`` / ``SCK`` ``D13`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` ``D13`` / ``SCK`` / ``BLUE_LED`` ``D13`` / ``BLUE_LED``
PA18 ``D8`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10``
PA19 ``D10`` / ``MISO`` ``D12`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` / ``MISO`` ``D12``
PA20 ``D6`` ``D9`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6``
PA21 ``D7`` ``D10`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` ``D7`` ``D7``
PA22 ``D0`` ``ESP_TX`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA``
PA23 ``D1`` ``ESP_RX`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL`` ``SCL``
PA24
PA25
PB22 ``D14`` / ``TX`` ``D1`` / ``TX`` ``FLASH_CS`` ``D30`` / ``TX1``
PB23 ``D13`` / ``RX`` ``D0`` / ``RX`` ``NEOPIXEL`` / ``D8`` ``D31`` / ``RX1``
PA27 ``SD_CD`` ``ESP_GPIO0`` ``GREEN_LED`` ``GREEN_LED``
PA28 ``ESP_BUSY`` ``BUTTON_A`` / ``D4``
PA29
PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL``
PA31
PB02 ``A1`` ``A1`` ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5`` ``A5``
PB03 ``A2`` ``A7`` ``A4`` / ``SCL`` ``YELLOW_LED`` ``YELLOW_LED``
===================== =================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ====================== ================
Here is a table about which pins can do what in CircuitPython terms. However,
just because something is listed, doesn't mean it will always work. Existing use
of other pins and functionality will impact your ability to use a pin for your
desired purpose. For example, only certain combinations of SPI pins will work
because they use shared hardware internally.
===================== ======== ========= ========= ======= ======= ======= ========= ========= ======= ========== ========== ========= ========= ========= ============ ======= ======= =========
`microcontroller.pin` `analogio` `audioio` `bitbangio` `busio` `digitalio` `pulseio` `touchio`
--------------------- ------------------- --------- ------------------------- -------------------------------------------------------------------------------------- ------------ ---------------- ---------
Datasheet AnalogIn AnalogOut AudioOut I2C OneWire SPI I2C - SDA I2C - SCL OneWire SPI - MISO SPI - MOSI SPI - SCK UART - RX UART - TX DigitalInOut PulseIn PWMOut TouchIn
===================== ======== ========= ========= ======= ======= ======= ========= ========= ======= ========== ========== ========= ========= ========= ============ ======= ======= =========
PA00 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA01 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA02 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA03 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB08 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB09 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA04 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA05 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA06 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA07 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA08 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA09 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA10 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA11 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB10 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB11 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA12 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA13 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA14 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA15 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA16 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA17 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA18 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA19 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA20 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA21 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA22 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA23 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA24
PA25
PB22 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB23 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA27 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA28 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA29 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA30 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PA31 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB02 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
PB03 **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes** **Yes**
===================== ======== ========= ========= ======= ======= ======= ========= ========= ======= ========== ========== ========= ========= ========= ============ ======= ======= =========
Setup
-----
An ARM compiler is required for the build, along with the associated binary
utilities. They can be installed as follows:
- Ubuntu
.. code-block:: shell
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get install gcc-arm-embedded
- Arch Linux
.. code-block:: shell
sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib
For other systems, the `GNU Arm Embedded Toolchain <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`_
may be available in binary form.
The latest available package from team-gcc-arm-embedded is used to produce the
binaries shipped by AdaFruit. Other compiler versions, particularly older
ones, may not work properly. In particular, the ``gcc-arm-none-eabi`` package
in Debian Stretch is too old.
The compiler can be changed using the ``CROSS_COMPILE`` variable when invoking
``make``.
Building
--------
Before building the firmware for a given board, there are two additional steps.
These commands should be executed from the root directory of the repository
(``circuitpython/``).
1. There are various submodules that reside in different repositories. In order
to have these submodules locally, you must pull them into your clone, using:
.. code-block:: shell
git submodule update --init --recursive
2. The MicroPython cross-compiler must be built; it will be used to pre-compile
some of the built-in scripts to bytecode. The cross-compiler is built and
run on the host machine, using:
.. code-block:: shell
make -C mpy-cross
For build instructions see this guide: https://learn.adafruit.com/building-circuitpython/
Build commands are run from the ``circuitpython/ports/atmel-samd`` directory.
To build for a given board you must specify it by setting ``BOARD``. For example:
.. code-block:: shell
make BOARD=feather_m0_basic
Board names are the directory names in the `boards <https://github.com/adafruit/circuitpython/tree/master/ports/atmel-samd/boards>`_ folder.
Deploying
Debugging
---------
Arduino Bootloader
^^^^^^^^^^^^^^^^^^
For debugging instructions see this guide: https://learn.adafruit.com/debugging-the-samd21-with-gdb
If your board has an existing Arduino bootloader on it then you can use bossac
to flash MicroPython. First, activate the bootloader. On Adafruit Feathers you
can double click the reset button and the #13 will fade in and out. Finally,
run bossac:
tools/bossac_osx -e -w -v -b -R build-feather_m0_basic/firmware.bin
No Bootloader via GDB
^^^^^^^^^^^^^^^^^^^^^
This method works for loading MicroPython onto the Arduino Zero via the
programming port rather than the native USB port.
Note: These instructions are tested on Mac OSX and will vary for different
platforms.
openocd -f ~/Library/Arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg
In another terminal from ``micropython/atmel-samd``:
arm-none-eabi-gdb build-arduino_zero/firmware.elf
(gdb) tar ext :3333
...
(gdb) load
...
(gdb) monitor reset init
...
(gdb) continue
Connecting
----------
Serial
^^^^^^
All boards are currently configured to work over USB rather than UART. To
connect to it from OSX do something like this:
screen /dev/tty.usbmodem142422 115200
You may not see a prompt immediately because it doesn't know you connected. To
get one either hit enter to get `>>>` or do CTRL-B to get the full header.
Mass storage
^^^^^^^^^^^^
All boards will also show up as a mass storage device. Make sure to eject it
before resetting or disconnecting the board.
Port Specific modules
---------------------

View File

@ -26,7 +26,6 @@
#include "background.h"
#include "audio_dma.h"
#include "tick.h"
#include "supervisor/filesystem.h"
#include "supervisor/shared/tick.h"
#include "supervisor/usb.h"
@ -34,6 +33,7 @@
#include "py/runtime.h"
#include "shared-module/network/__init__.h"
#include "supervisor/shared/stack.h"
#include "supervisor/port.h"
#ifdef CIRCUITPY_DISPLAYIO
#include "shared-module/displayio/__init__.h"
@ -92,10 +92,10 @@ void run_background_tasks(void) {
running_background_tasks = false;
assert_heap_ok();
last_finished_tick = supervisor_ticks_ms64();
last_finished_tick = port_get_raw_ticks(NULL);
finish_background_task();
}
bool background_tasks_ok(void) {
return supervisor_ticks_ms64() - last_finished_tick < 1000;
return port_get_raw_ticks(NULL) - last_finished_tick < 1024;
}

View File

@ -12,10 +12,11 @@ EXTERNAL_FLASH_DEVICES = "S25FL216K, GD25Q16C"
# Turn off features and optimizations for Crickit build to make room for additional frozen libs.
LONGINT_IMPL = NONE
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_PIXELBUF = 1
CIRCUITPY_RTC = 0
SUPEROPT_GC = 0

View File

@ -32,8 +32,6 @@
#include "shared-module/displayio/mipi_constants.h"
#include "shared-bindings/busio/SPI.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
#define DELAY 0x80

View File

@ -31,7 +31,6 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -31,7 +31,6 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-bindings/time/__init__.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -32,7 +32,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "supervisor/shared/board.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -31,8 +31,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
#define DELAY 0x80
uint8_t display_init_sequence[] = {

View File

@ -34,8 +34,6 @@
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
#define DELAY 0x80
uint8_t display_init_sequence[] = {

View File

@ -33,8 +33,6 @@
#include "shared-module/displayio/mipi_constants.h"
#include "shared-bindings/busio/SPI.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;
#define DELAY 0x80

View File

@ -49,7 +49,6 @@
#include "samd/dma.h"
#include "audio_dma.h"
#include "tick.h"
#define OVERSAMPLING 64
#define SAMPLES_PER_BUFFER 32

View File

@ -33,8 +33,6 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "tick.h"
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {

View File

@ -24,11 +24,12 @@
* THE SOFTWARE.
*/
#include "shared-bindings/frequencyio/FrequencyIn.h"
#include <stdint.h>
#include "hal/include/hal_gpio.h"
#include "atmel_start_pins.h"
#include "supervisor/shared/translate.h"
#include "mpconfigport.h"
#include "py/runtime.h"
@ -41,11 +42,11 @@
#include "samd/pins.h"
#include "samd/external_interrupts.h"
#include "shared-bindings/frequencyio/FrequencyIn.h"
#include "peripheral_clk_config.h"
#include "hpl_gclk_config.h"
#include "tick.h"
#include "shared-bindings/time/__init__.h"
#include "supervisor/shared/translate.h"
#ifdef SAMD21
#include "hpl/gclk/hpl_gclk_base.h"
@ -88,9 +89,7 @@ void frequencyin_interrupt_handler(uint8_t index) {
if (!ref_tc->COUNT16.INTFLAG.bit.OVF) return; // false trigger
uint32_t current_us;
uint64_t current_ms;
current_tick(&current_ms, &current_us);
uint64_t current_ns = common_hal_time_monotonic_ns();
for (uint8_t i = 0; i <= (TC_INST_NUM - 1); i++) {
if (active_frequencyins[i] != NULL) {
@ -101,14 +100,12 @@ void frequencyin_interrupt_handler(uint8_t index) {
if ((EIC->INTFLAG.reg & mask) == mask) {
// Make sure capture_period has elapsed before we
// record a new event count.
if (current_ms - self->last_ms >= self->capture_period) {
float new_factor = self->last_us + (1000 - current_us);
if ((current_ns - self->last_ns) / 1000000 >= self->capture_period) {
// ms difference will not need 64 bits. If we use 64 bits,
// double-precision float routines are required, and we don't
// want to include them because they're very large.
self->factor = (uint32_t) (current_ms - self->last_ms) + (new_factor / 1000);
self->last_ms = current_ms;
self->last_us = current_us;
self->factor = (uint32_t) (current_ns - self->last_ns) / 1000000.0;
self->last_ns = current_ns;
#ifdef SAMD51
tc->COUNT16.CTRLBSET.bit.CMD = TC_CTRLBSET_CMD_READSYNC_Val;
@ -278,8 +275,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t*
self->pin = pin->number;
self->channel = pin->extint_channel;
self->errored_too_fast = false;
self->last_ms = 0;
self->last_us = 1000;
self->last_ns = 0;
self->capture_period = capture_period;
#ifdef SAMD21
self->TC_IRQ = TC3_IRQn + timer_index;

View File

@ -38,8 +38,7 @@ typedef struct {
uint8_t channel;
uint8_t event_channel;
uint32_t frequency;
volatile uint64_t last_ms;
volatile uint32_t last_us;
volatile uint64_t last_ns;
float factor;
uint32_t capture_period;
uint8_t TC_IRQ;

View File

@ -29,7 +29,7 @@
#include "shared-bindings/neopixel_write/__init__.h"
#include "tick.h"
#include "supervisor/port.h"
#ifdef SAMD51
#include "hri/hri_cmcc_d51.h"
@ -91,8 +91,7 @@ static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMa
"");
}
uint64_t next_start_tick_ms = 0;
uint32_t next_start_tick_us = 1000;
uint64_t next_start_raw_ticks = 0;
void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) {
// This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code:
@ -101,9 +100,9 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
uint32_t pinMask;
PortGroup* port;
// This must be called while interrupts are on in case we're waiting for a
// future ms tick.
wait_until(next_start_tick_ms, next_start_tick_us);
// Wait to make sure we don't append onto the last transmission. This should only be a tick or
// two.
while (port_get_raw_ticks(NULL) < next_start_raw_ticks) {}
// Turn off interrupts of any kind during timing-sensitive code.
mp_hal_disable_all_interrupts();
@ -144,15 +143,8 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout,
#endif
// ticks_ms may be out of date at this point because we stopped the
// interrupt. We'll risk it anyway.
current_tick(&next_start_tick_ms, &next_start_tick_us);
if (next_start_tick_us < 100) {
next_start_tick_ms += 1;
next_start_tick_us = 100 - next_start_tick_us;
} else {
next_start_tick_us -= 100;
}
// Update the next start.
next_start_raw_ticks = port_get_raw_ticks(NULL) + 4;
// Turn on interrupts after timing-sensitive code.
mp_hal_enable_all_interrupts();

View File

@ -41,10 +41,9 @@
#include "samd/pins.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/ps2io/Ps2.h"
#include "supervisor/port.h"
#include "supervisor/shared/translate.h"
#include "tick.h"
#define STATE_IDLE 0
#define STATE_RECV 1
#define STATE_RECV_PARITY 2
@ -168,24 +167,21 @@ static void delay_us(uint32_t t) {
void ps2_interrupt_handler(uint8_t channel) {
// Grab the current time first.
uint32_t current_us;
uint64_t current_ms;
current_tick(&current_ms, &current_us);
uint64_t current_tick = port_get_raw_ticks(NULL);
ps2io_ps2_obj_t* self = get_eic_channel_data(channel);
int data_bit = gpio_get_pin_level(self->data_pin) ? 1 : 0;
// test for timeout
if (self->state != STATE_IDLE) {
int64_t diff_ms = current_ms - self->last_int_ms;
if (diff_ms >= 2) { // a.k.a. > 1.001ms
int64_t diff_ms = current_tick - self->last_raw_ticks;
if (diff_ms > 1) { // a.k.a. > 1.001ms
self->last_errors |= ERROR_TIMEOUT;
self->state = STATE_IDLE;
}
}
self->last_int_us = current_us;
self->last_int_ms = current_ms;
self->last_raw_ticks = current_tick;
if (self->state == STATE_IDLE) {
self->bits = 0;

View File

@ -39,8 +39,7 @@ typedef struct {
uint8_t data_pin;
uint8_t state;
uint64_t last_int_ms;
uint32_t last_int_us;
uint64_t last_raw_ticks;
uint16_t bits;
bool parity;

View File

@ -34,15 +34,31 @@
#include "background.h"
#include "eic_handler.h"
#include "mpconfigport.h"
#include "timer_handler.h"
#include "py/gc.h"
#include "py/runtime.h"
#include "samd/external_interrupts.h"
#include "samd/pins.h"
#include "samd/timers.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/pulseio/PulseIn.h"
#include "supervisor/shared/translate.h"
#include "tick.h"
// This timer is shared amongst all PulseIn objects as a higher resolution clock.
static uint8_t refcount = 0;
static uint8_t pulsein_tc_index = 0xff;
volatile static uint32_t overflow_count = 0;
void pulsein_timer_interrupt_handler(uint8_t index) {
if (index != pulsein_tc_index) return;
overflow_count++;
Tc* tc = tc_insts[index];
if (!tc->COUNT16.INTFLAG.bit.OVF) return;
// Clear the interrupt bit.
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_OVF;
}
static void pulsein_set_config(pulseio_pulsein_obj_t* self, bool first_edge) {
uint32_t sense_setting;
@ -61,13 +77,15 @@ static void pulsein_set_config(pulseio_pulsein_obj_t* self, bool first_edge) {
void pulsein_interrupt_handler(uint8_t channel) {
// Grab the current time first.
uint32_t current_us;
uint64_t current_ms;
current_tick(&current_ms, &current_us);
uint32_t current_overflow = overflow_count;
Tc* tc = tc_insts[pulsein_tc_index];
#ifdef SAMD51
tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_READSYNC;
while (tc->COUNT16.SYNCBUSY.bit.COUNT == 1 ||
tc->COUNT16.CTRLBSET.bit.CMD == TC_CTRLBSET_CMD_READSYNC_Val) {}
#endif
uint32_t current_count = tc->COUNT16.COUNT.reg;
// current_tick gives us the remaining us until the next tick but we want the number since the
// last ms.
current_us = 1000 - current_us;
pulseio_pulsein_obj_t* self = get_eic_channel_data(channel);
if (!background_tasks_ok() || self->errored_too_fast) {
self->errored_too_fast = true;
@ -78,17 +96,17 @@ void pulsein_interrupt_handler(uint8_t channel) {
self->first_edge = false;
pulsein_set_config(self, false);
} else {
uint32_t ms_diff = current_ms - self->last_ms;
uint16_t us_diff = current_us - self->last_us;
uint32_t total_diff = us_diff;
if (self->last_us > current_us) {
total_diff = 1000 + current_us - self->last_us;
if (ms_diff > 1) {
total_diff += (ms_diff - 1) * 1000;
}
} else {
total_diff += ms_diff * 1000;
// Sometimes we beat the overflow interrupt so just fudge overflow in
// that case.
if (current_count < self->last_count && current_overflow == self->last_overflow) {
current_overflow += 1;
}
uint32_t total_diff = current_count + 0xffff * (current_overflow - self->last_overflow) - self->last_count;
// The SAMD21 clock is 48MHz. We prescale it to 3MHz so // 3 here.
#ifdef SAMD21
total_diff /= 3;
#endif
// Cap duration at 16 bits.
uint16_t duration = 0xffff;
if (total_diff < duration) {
duration = total_diff;
@ -102,8 +120,14 @@ void pulsein_interrupt_handler(uint8_t channel) {
self->start++;
}
}
self->last_ms = current_ms;
self->last_us = current_us;
self->last_overflow = current_overflow;
self->last_count = current_count;
}
void pulsein_reset() {
refcount = 0;
pulsein_tc_index = 0xff;
overflow_count = 0;
}
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
@ -126,10 +150,62 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
self->start = 0;
self->len = 0;
self->first_edge = true;
self->last_us = 0;
self->last_ms = 0;
self->errored_too_fast = false;
if (refcount == 0) {
// Find a spare timer.
Tc *tc = NULL;
int8_t index = TC_INST_NUM - 1;
for (; index >= 0; index--) {
if (tc_insts[index]->COUNT16.CTRLA.bit.ENABLE == 0) {
tc = tc_insts[index];
break;
}
}
if (tc == NULL) {
mp_raise_RuntimeError(translate("All timers in use"));
}
pulsein_tc_index = index;
set_timer_handler(true, index, TC_HANDLER_PULSEIN);
#ifdef SAMD21
// We use GCLK0 for SAMD21 which is 48MHz. We prescale it to 3MHz.
turn_on_clocks(true, index, 0);
#endif
#ifdef SAMD51
// We use GCLK5 for SAMD51 because it runs at 2MHz and we can use it for a 1MHz clock,
// 1us per tick.
turn_on_clocks(true, index, 5);
#endif
#ifdef SAMD21
tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 |
TC_CTRLA_PRESCALER_DIV16 |
TC_CTRLA_WAVEGEN_NFRQ;
#endif
#ifdef SAMD51
tc_reset(tc);
tc_set_enable(tc, false);
tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV2;
tc->COUNT16.WAVE.reg = TC_WAVE_WAVEGEN_NFRQ;
#endif
tc_set_enable(tc, true);
// Clear our interrupt in case it was set earlier
tc->COUNT16.INTFLAG.reg = TC_INTFLAG_OVF;
tc->COUNT16.INTENSET.reg = TC_INTENSET_OVF;
tc_enable_interrupts(pulsein_tc_index);
tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_RETRIGGER;
overflow_count = 0;
}
refcount++;
self->last_overflow = overflow_count;
self->last_count = 0;
set_eic_channel_data(pin->extint_channel, (void*) self);
// Check to see if the EIC is enabled and start it up if its not.'
@ -158,6 +234,12 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
turn_off_eic_channel(self->channel);
reset_pin_number(self->pin);
refcount--;
if (refcount == 0) {
tc_reset(tc_insts[pulsein_tc_index]);
pulsein_tc_index = 0xff;
}
self->pin = NO_PIN;
}
@ -185,8 +267,8 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self,
// Reconfigure the pin and make sure its set to detect the first edge.
self->first_edge = true;
self->last_ms = 0;
self->last_us = 0;
self->last_overflow = 0;
self->last_count = 0;
gpio_set_pin_function(self->pin, GPIO_PIN_FUNCTION_A);
uint32_t mask = 1 << self->channel;
// Clear previous interrupt state and re-enable it.

View File

@ -41,13 +41,14 @@ typedef struct {
volatile uint16_t start;
volatile uint16_t len;
volatile bool first_edge;
volatile uint64_t last_ms;
volatile uint16_t last_us;
volatile uint32_t last_overflow;
volatile uint16_t last_count;
volatile bool errored_too_fast;
} pulseio_pulsein_obj_t;
void pulsein_reset(void);
void pulsein_interrupt_handler(uint8_t channel);
void pulsein_timer_interrupt_handler(uint8_t index);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H

View File

@ -30,76 +30,47 @@
#include <hal_init.h>
#include <hpl_gclk_base.h>
#include <hpl_pm_base.h>
#include <hal_calendar.h>
#include "py/obj.h"
#include "py/runtime.h"
#include "lib/timeutils/timeutils.h"
#include "shared-bindings/rtc/__init__.h"
#include "supervisor/port.h"
#include "supervisor/shared/translate.h"
static struct calendar_descriptor calendar;
void rtc_init(void) {
#ifdef SAMD21
_gclk_enable_channel(RTC_GCLK_ID, CONF_GCLK_RTC_SRC);
#endif
#ifdef SAMD51
hri_mclk_set_APBAMASK_RTC_bit(MCLK);
#endif
calendar_init(&calendar, RTC);
calendar_set_baseyear(&calendar, 2000);
calendar_enable(&calendar);
}
// This is the time in seconds since 2000 that the RTC was started.
// TODO: Change the offset to ticks so that it can be a subsecond adjustment.
static uint32_t rtc_offset = 0;
void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
struct calendar_date_time datetime;
calendar_get_date_time(&calendar, &datetime);
tm->tm_year = datetime.date.year;
tm->tm_mon = datetime.date.month;
tm->tm_mday = datetime.date.day;
tm->tm_hour = datetime.time.hour;
tm->tm_min = datetime.time.min;
tm->tm_sec = datetime.time.sec;
uint64_t ticks_s = port_get_raw_ticks(NULL) / 1024;
timeutils_seconds_since_2000_to_struct_time(rtc_offset + ticks_s, tm);
}
void common_hal_rtc_set_time(timeutils_struct_time_t *tm) {
// Reset prescaler to increase initial precision. Otherwise we can be up to 1 second off already.
uint32_t freqcorr = hri_rtcmode0_read_FREQCORR_reg(calendar.device.hw);
calendar_deinit(&calendar);
rtc_init();
hri_rtcmode0_write_FREQCORR_reg(calendar.device.hw, freqcorr);
struct calendar_date date = {
.year = tm->tm_year,
.month = tm->tm_mon,
.day = tm->tm_mday,
};
calendar_set_date(&calendar, &date);
struct calendar_time time = {
.hour = tm->tm_hour,
.min = tm->tm_min,
.sec = tm->tm_sec,
};
calendar_set_time(&calendar, &time);
uint64_t ticks_s = port_get_raw_ticks(NULL) / 1024;
uint32_t epoch_s = timeutils_seconds_since_2000(
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec
);
rtc_offset = epoch_s - ticks_s;
}
// A positive value speeds up the clock by removing clock cycles.
int common_hal_rtc_get_calibration(void) {
int calibration = hri_rtcmode0_read_FREQCORR_VALUE_bf(calendar.device.hw);
int calibration = hri_rtcmode0_read_FREQCORR_VALUE_bf(RTC);
if (!hri_rtcmode0_get_FREQCORR_SIGN_bit(calendar.device.hw))
if (!hri_rtcmode0_get_FREQCORR_SIGN_bit(RTC)) {
calibration = -calibration;
}
return calibration;
}
void common_hal_rtc_set_calibration(int calibration) {
if (calibration > 127 || calibration < -127)
if (calibration > 127 || calibration < -127) {
mp_raise_ValueError(translate("calibration value out of range +/-127"));
}
hri_rtcmode0_write_FREQCORR_SIGN_bit(calendar.device.hw, calibration < 0 ? 0 : 1);
hri_rtcmode0_write_FREQCORR_VALUE_bf(calendar.device.hw, abs(calibration));
hri_rtcmode0_write_FREQCORR_SIGN_bit(RTC, calibration < 0 ? 0 : 1);
hri_rtcmode0_write_FREQCORR_VALUE_bf(RTC, abs(calibration));
}

View File

@ -27,6 +27,4 @@
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H
extern void rtc_init(void);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_RTC_RTC_H

View File

@ -42,7 +42,6 @@
#include "samd/clocks.h"
#include "samd/pins.h"
#include "tick.h"
#include "adafruit_ptc.h"
bool touch_enabled = false;

View File

@ -49,21 +49,6 @@
extern uint32_t common_hal_mcu_processor_get_frequency(void);
void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0;
while (duration < delay) {
RUN_BACKGROUND_TASKS;
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break;
}
duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait.
}
}
// Use mp_hal_delay_us() for timing of less than 1ms.
// Do a simple timing loop to wait for a certain number of microseconds.
// Can be used when interrupts are disabled, which makes tick_delay() unreliable.

View File

@ -34,9 +34,8 @@
#include "supervisor/shared/tick.h"
// Global millisecond tick count (driven by SysTick interrupt).
static inline mp_uint_t mp_hal_ticks_ms(void) {
return supervisor_ticks_ms32();
}
#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32())
// Number of bytes in receive buffer
volatile uint8_t usb_rx_count;
volatile bool mp_cdc_enabled;

@ -1 +1 @@
Subproject commit f528240c2a4c2d7a39de786f1aa56895c12227b4
Subproject commit 6b531fc923d9f02b14bd731a5f584ddf716e8773

View File

@ -41,6 +41,7 @@
#endif
#include "hal/include/hal_flash.h"
#include "supervisor/flash.h"
#include "supervisor/shared/rgb_led_status.h"
static struct flash_descriptor supervisor_flash_desc;
@ -73,7 +74,7 @@ uint32_t supervisor_flash_get_block_count(void) {
return INTERNAL_FLASH_PART1_NUM_BLOCKS;
}
void supervisor_flash_flush(void) {
void port_internal_flash_flush(void) {
}
void supervisor_flash_release_cache(void) {

View File

@ -32,6 +32,7 @@
// ASF 4
#include "atmel_start_pins.h"
#include "peripheral_clk_config.h"
#include "hal/include/hal_delay.h"
#include "hal/include/hal_flash.h"
#include "hal/include/hal_gpio.h"
@ -70,10 +71,10 @@
#include "samd/dma.h"
#include "shared-bindings/rtc/__init__.h"
#include "reset.h"
#include "tick.h"
#include "supervisor/shared/safe_mode.h"
#include "supervisor/shared/stack.h"
#include "supervisor/shared/tick.h"
#include "tusb.h"
@ -132,6 +133,49 @@ static void save_usb_clock_calibration(void) {
}
#endif
static void rtc_init(void) {
#ifdef SAMD21
_gclk_enable_channel(RTC_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK2_Val);
RTC->MODE0.CTRL.bit.SWRST = true;
while (RTC->MODE0.CTRL.bit.SWRST != 0) {}
RTC->MODE0.CTRL.reg = RTC_MODE0_CTRL_ENABLE |
RTC_MODE0_CTRL_MODE_COUNT32 |
RTC_MODE0_CTRL_PRESCALER_DIV2;
#endif
#ifdef SAMD51
hri_mclk_set_APBAMASK_RTC_bit(MCLK);
RTC->MODE0.CTRLA.bit.SWRST = true;
while (RTC->MODE0.SYNCBUSY.bit.SWRST != 0) {}
RTC->MODE0.CTRLA.reg = RTC_MODE0_CTRLA_ENABLE |
RTC_MODE0_CTRLA_MODE_COUNT32 |
RTC_MODE0_CTRLA_PRESCALER_DIV2 |
RTC_MODE0_CTRLA_COUNTSYNC;
#endif
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_OVF;
// Set all peripheral interrupt priorities to the lowest priority by default.
for (uint16_t i = 0; i < PERIPH_COUNT_IRQn; i++) {
NVIC_SetPriority(i, (1UL << __NVIC_PRIO_BITS) - 1UL);
}
// Bump up the rtc interrupt so nothing else interferes with timekeeping.
NVIC_SetPriority(RTC_IRQn, 0);
#ifdef SAMD21
NVIC_SetPriority(USB_IRQn, 1);
#endif
#ifdef SAMD51
NVIC_SetPriority(USB_0_IRQn, 1);
NVIC_SetPriority(USB_1_IRQn, 1);
NVIC_SetPriority(USB_2_IRQn, 1);
NVIC_SetPriority(USB_3_IRQn, 1);
#endif
NVIC_ClearPendingIRQ(RTC_IRQn);
NVIC_EnableIRQ(RTC_IRQn);
}
safe_mode_t port_init(void) {
#if defined(SAMD21)
@ -220,12 +264,7 @@ safe_mode_t port_init(void) {
clock_init(BOARD_HAS_CRYSTAL, DEFAULT_DFLL48M_FINE_CALIBRATION);
#endif
// Configure millisecond timer initialization.
tick_init();
#if CIRCUITPY_RTC
rtc_init();
#endif
init_shared_dma();
@ -267,6 +306,7 @@ void reset_port(void) {
#endif
eic_reset();
#if CIRCUITPY_PULSEIO
pulsein_reset();
pulseout_reset();
pwmout_reset();
#endif
@ -275,9 +315,6 @@ void reset_port(void) {
analogin_reset();
analogout_reset();
#endif
#if CIRCUITPY_RTC
rtc_reset();
#endif
reset_gclks();
@ -352,6 +389,108 @@ uint32_t port_get_saved_word(void) {
return *safe_word;
}
// TODO: Move this to an RTC backup register so we can preserve it when only the BACKUP power domain
// is enabled.
static volatile uint64_t overflowed_ticks = 0;
static volatile bool _ticks_enabled = false;
void RTC_Handler(void) {
uint32_t intflag = RTC->MODE0.INTFLAG.reg;
if (intflag & RTC_MODE0_INTFLAG_OVF) {
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_OVF;
// Our RTC is 32 bits and we're clocking it at 16.384khz which is 16 (2 ** 4) subticks per
// tick.
overflowed_ticks += (1L<< (32 - 4));
#ifdef SAMD51
} else if (intflag & RTC_MODE0_INTFLAG_PER2) {
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_PER2;
// Do things common to all ports when the tick occurs
supervisor_tick();
#endif
} else if (intflag & RTC_MODE0_INTFLAG_CMP0) {
// Clear the interrupt because we may have hit a sleep and _ticks_enabled
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
#ifdef SAMD21
if (_ticks_enabled) {
// Do things common to all ports when the tick occurs.
supervisor_tick();
// Check _ticks_enabled again because a tick handler may have turned it off.
if (_ticks_enabled) {
port_interrupt_after_ticks(1);
}
}
#endif
#ifdef SAMD51
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
#endif
}
}
static uint32_t _get_count(void) {
#ifdef SAMD51
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {}
#endif
#ifdef SAMD21
while (RTC->MODE0.STATUS.bit.SYNCBUSY != 0) {}
#endif
return RTC->MODE0.COUNT.reg;
}
uint64_t port_get_raw_ticks(uint8_t* subticks) {
uint32_t current_ticks = _get_count();
if (subticks != NULL) {
*subticks = (current_ticks % 16) * 2;
}
return overflowed_ticks + current_ticks / 16;
}
// Enable 1/1024 second tick.
void port_enable_tick(void) {
#ifdef SAMD51
// PER2 will generate an interrupt every 32 ticks of the source 32.768 clock.
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_PER2;
#endif
#ifdef SAMD21
_ticks_enabled = true;
port_interrupt_after_ticks(1);
#endif
}
// Disable 1/1024 second tick.
void port_disable_tick(void) {
#ifdef SAMD51
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_PER2;
#endif
#ifdef SAMD21
_ticks_enabled = false;
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
#endif
}
void port_interrupt_after_ticks(uint32_t ticks) {
uint32_t current_ticks = _get_count();
if (ticks > 1 << 28) {
// We'll interrupt sooner with an overflow.
return;
}
RTC->MODE0.COMP[0].reg = current_ticks + (ticks << 4);
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0;
}
void port_sleep_until_interrupt(void) {
#ifdef SAMD51
// Clear the FPU interrupt because it can prevent us from sleeping.
if (__get_FPSCR() & ~(0x9f)) {
__set_FPSCR(__get_FPSCR() & ~(0x9f));
(void) __get_FPSCR();
}
#endif
__WFI();
}
/**
* \brief Default interrupt handler for unused IRQs.
*/

View File

@ -1,107 +0,0 @@
/*
* 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 "tick.h"
#include "peripheral_clk_config.h"
#include "supervisor/shared/tick.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h"
void SysTick_Handler(void) {
// SysTick interrupt handler called when the SysTick timer reaches zero
// (every millisecond).
common_hal_mcu_disable_interrupts();
// Read the control register to reset the COUNTFLAG.
(void) SysTick->CTRL;
common_hal_mcu_enable_interrupts();
// Do things common to all ports when the tick occurs
supervisor_tick();
}
void tick_init() {
uint32_t ticks_per_ms = common_hal_mcu_processor_get_frequency() / 1000;
SysTick_Config(ticks_per_ms-1);
NVIC_EnableIRQ(SysTick_IRQn);
// Set all peripheral interrupt priorities to the lowest priority by default.
for (uint16_t i = 0; i < PERIPH_COUNT_IRQn; i++) {
NVIC_SetPriority(i, (1UL << __NVIC_PRIO_BITS) - 1UL);
}
// Bump up the systick interrupt so nothing else interferes with timekeeping.
NVIC_SetPriority(SysTick_IRQn, 0);
#ifdef SAMD21
NVIC_SetPriority(USB_IRQn, 1);
#endif
#ifdef SAMD51
NVIC_SetPriority(USB_0_IRQn, 1);
NVIC_SetPriority(USB_1_IRQn, 1);
NVIC_SetPriority(USB_2_IRQn, 1);
NVIC_SetPriority(USB_3_IRQn, 1);
#endif
}
void tick_delay(uint32_t us) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
uint32_t us_until_next_tick = SysTick->VAL / ticks_per_us;
uint32_t start_tick;
while (us >= us_until_next_tick) {
start_tick = SysTick->VAL; // wait for SysTick->VAL to RESET
while (SysTick->VAL < start_tick) {}
us -= us_until_next_tick;
us_until_next_tick = 1000;
}
while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
}
// us counts down!
void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
// We disable interrupts to prevent ticks_ms from changing while we grab it.
common_hal_mcu_disable_interrupts();
uint32_t tick_status = SysTick->CTRL;
uint32_t current_us = SysTick->VAL;
uint32_t tick_status2 = SysTick->CTRL;
uint64_t current_ms = supervisor_ticks_ms64();
// The second clause ensures our value actually rolled over. Its possible it hit zero between
// the VAL read and CTRL read.
if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 ||
((tick_status2 & SysTick_CTRL_COUNTFLAG_Msk) != 0 && current_us > ticks_per_us)) {
current_ms++;
}
common_hal_mcu_enable_interrupts();
*ms = current_ms;
*us_until_ms = current_us / ticks_per_us;
}
void wait_until(uint64_t ms, uint32_t us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
}

View File

@ -29,6 +29,7 @@
#include "timer_handler.h"
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/pulseio/PulseOut.h"
#include "shared-module/_pew/PewPew.h"
#include "common-hal/frequencyio/FrequencyIn.h"
@ -49,6 +50,11 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
if (is_tc) {
uint8_t handler = tc_handler[index];
switch(handler) {
case TC_HANDLER_PULSEIN:
#if CIRCUITPY_PULSEIO
pulsein_timer_interrupt_handler(index);
#endif
break;
case TC_HANDLER_PULSEOUT:
#if CIRCUITPY_PULSEIO
pulseout_interrupt_handler(index);

View File

@ -31,6 +31,7 @@
#define TC_HANDLER_PEW 0x2
#define TC_HANDLER_FREQUENCYIN 0x3
#define TC_HANDLER_RGBMATRIX 0x4
#define TC_HANDLER_PULSEIN 0x5
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
void shared_timer_handler(bool is_tc, uint8_t index);

View File

@ -152,7 +152,6 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
SRC_S = supervisor/cpu.s
SRC_C = \
tick.c \
background.c \
fatfs_port.c \
mphalport.c \
@ -184,7 +183,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
# Sources that only hold QSTRs after pre-processing.
SRC_QSTR_PREPROCESSOR +=
SRC_QSTR_PREPROCESSOR +=
all: $(BUILD)/firmware.spk
@ -197,7 +196,7 @@ $(FIRMWARE):
$(ECHO) "run make flash-bootloader again to flash bootloader."
exit 1
$(BUILD)/libmpy.a: $(SPRESENSE_SDK) $(OBJ)
$(BUILD)/libmpy.a: $(SPRESENSE_SDK) $(OBJ)
$(ECHO) "AR $@"
$(Q)$(AR) rcs $(BUILD)/libmpy.a $(OBJ)

View File

@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
#include <stdbool.h> // for cxd56_clock.h
#include <cxd56_clock.h>
#include <sys/boardctl.h>
// For NAN: remove when not needed.
@ -31,7 +33,7 @@
#include "py/mphal.h"
uint32_t common_hal_mcu_processor_get_frequency(void) {
return mp_hal_ticks_cpu();
return cxd56_get_cpu_baseclk();
}
float common_hal_mcu_processor_get_temperature(void) {

View File

@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
#include <stdbool.h> // for cxd56_clock.h
#include <cxd56_clock.h>
#include <sys/boardctl.h>
#include "py/mphal.h"
@ -42,8 +44,20 @@ const mcu_processor_obj_t common_hal_mcu_processor_obj = {
},
};
#define DELAY_CORRECTION (700)
void common_hal_mcu_delay_us(uint32_t delay) {
mp_hal_delay_us(delay);
if (delay) {
unsigned long long ticks = cxd56_get_cpu_baseclk() / 1000000L * delay;
if (ticks < DELAY_CORRECTION) return; // delay time already used in calculation
ticks -= DELAY_CORRECTION;
ticks /= 6;
// following loop takes 6 cycles
do {
__asm__ __volatile__("nop");
} while(--ticks);
}
}
void common_hal_mcu_disable_interrupts(void) {

View File

@ -25,6 +25,7 @@
*/
#include <arch/board/board.h>
#include <sys/time.h>
#include "py/runtime.h"
#include "py/mphal.h"
@ -51,7 +52,9 @@ static int pulsein_set_config(pulseio_pulsein_obj_t *self, bool first_edge) {
static int pulsein_interrupt_handler(int irq, FAR void *context, FAR void *arg) {
// Grab the current time first.
uint32_t current_us = mp_hal_ticks_us();
struct timeval tv;
gettimeofday(&tv, NULL);
uint64_t current_us = ((uint64_t) tv.tv_sec) * 1000000 + tv.tv_usec;
pulseio_pulsein_obj_t *self = pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0];

View File

@ -38,7 +38,7 @@ typedef struct {
uint16_t maxlen;
uint16_t start;
uint16_t len;
uint32_t last_us;
uint64_t last_us;
bool idle_state;
bool first_edge;
bool paused;

View File

@ -1,45 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright 2019 Sony Semiconductor Solutions Corporation
*
* 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 <sys/time.h>
#include "py/mphal.h"
#include "supervisor/shared/tick.h"
uint64_t common_hal_time_monotonic(void) {
return supervisor_ticks_ms64();
}
uint64_t common_hal_time_monotonic_ns(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return 1000 * ((uint64_t) tv.tv_sec * 1000000 + (uint64_t) tv.tv_usec);
}
void common_hal_time_delay_ms(uint32_t delay) {
mp_hal_delay_ms(delay);
}

View File

@ -23,66 +23,3 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdbool.h>
#include <sys/time.h>
#include <cxd56_clock.h>
#include <sys/boardctl.h>
#include "py/mpstate.h"
#include "supervisor/shared/tick.h"
#define DELAY_CORRECTION (700)
#define DELAY_INTERVAL (50)
void mp_hal_init(void) {
boardctl(BOARDIOC_INIT, 0);
}
mp_uint_t mp_hal_ticks_ms(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
mp_uint_t mp_hal_ticks_us(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000 + tv.tv_usec;
}
mp_uint_t mp_hal_ticks_cpu(void) {
return cxd56_get_cpu_baseclk();
}
void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0;
while (duration < delay) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break;
}
duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait.
}
}
void mp_hal_delay_us(uint32_t us) {
if (us) {
unsigned long long ticks = mp_hal_ticks_cpu() / 1000000L * us;
if (ticks < DELAY_CORRECTION) return; // delay time already used in calculation
ticks -= DELAY_CORRECTION;
ticks /= 6;
// following loop takes 6 cycles
do {
__asm__ __volatile__("nop");
} while(--ticks);
}
}

View File

@ -30,5 +30,8 @@
#include <sys/types.h>
#include "lib/utils/interrupt_char.h"
#include "supervisor/shared/tick.h"
#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32())
#endif // MICROPY_INCLUDED_CXD56_MPHALPORT_H

View File

@ -59,7 +59,7 @@ uint32_t supervisor_flash_get_block_count(void) {
return CXD56_SPIFLASHSIZE >> PAGE_SHIFT;
}
void supervisor_flash_flush(void) {
void port_internal_flash_flush(void) {
if (flash_sector == NO_SECTOR) {
return;
}

View File

@ -25,13 +25,16 @@
*/
#include <stdint.h>
#include <sys/boardctl.h>
#include <sys/time.h>
#include "sched/sched.h"
#include "boards/board.h"
#include "supervisor/port.h"
#include "supervisor/shared/tick.h"
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/analogio/AnalogIn.h"
@ -103,3 +106,41 @@ void port_set_saved_word(uint32_t value) {
uint32_t port_get_saved_word(void) {
return _ebss;
}
volatile bool _tick_enabled;
void board_timerhook(void)
{
// Do things common to all ports when the tick occurs
if (_tick_enabled) {
supervisor_tick();
}
}
uint64_t port_get_raw_ticks(uint8_t* subticks) {
struct timeval tv;
gettimeofday(&tv, NULL);
long computed_subticks = tv.tv_usec * 1024 * 32 / 1000000;
if (subticks != NULL) {
*subticks = computed_subticks % 32;
}
return tv.tv_sec * 1024 + computed_subticks / 32;
}
// Enable 1/1024 second tick.
void port_enable_tick(void) {
_tick_enabled = true;
}
// Disable 1/1024 second tick.
void port_disable_tick(void) {
_tick_enabled = false;
}
void port_interrupt_after_ticks(uint32_t ticks) {
}
void port_sleep_until_interrupt(void) {
// TODO: Implement sleep.
}

1
ports/litex/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build-*/

View File

@ -116,7 +116,6 @@ SRC_C += \
background.c \
fatfs_port.c \
mphalport.c \
tick.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
lib/libc/string0.c \

25
ports/litex/README.rst Normal file
View File

@ -0,0 +1,25 @@
LiteX (FPGA)
============
`LiteX <https://github.com/enjoy-digital/litex>`_ is a Python-based System on a Chip (SoC) designer
for open source supported Field Programmable Gate Array (FPGA) chips. This means that the CPU
core(s) and peripherals are not defined by the physical chip. Instead, they are loaded as separate
"gateware". Once this gateware is loaded, CircuitPython can be loaded on top of it to work as
expected.
Installation
-------------
You'll need ``dfu-util`` to install CircuitPython on the Fomu.
Make sure the foboot bootloader is updated. Instructions are here: https://github.com/im-tomu/fomu-workshop/blob/master/docs/bootloader.rst
Once you've updated the bootloader, you should know how to use ``dfu-util``. It's pretty easy!
To install CircuitPython do:
.. code-block:: shell
dfu-util -D adafruit-circuitpython-fomu-en_US-<version>.dfu
It will install and then restart. CIRCUITPY should appear as it usually does and work the same.

View File

@ -7,8 +7,9 @@ ENTRY(_start)
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x20040000, LENGTH = 0x100000 /* entire flash, 1 MiB */
RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0x00020000 /* 128 KiB */
FLASH (rx) : ORIGIN = 0x20040000, LENGTH = 0x100000 /* entire flash, 1 MiB */
FLASH_FIRMWARE (rx) : ORIGIN = 0x20040000, LENGTH = 0x100000 /* entire flash, 1 MiB */
RAM (xrw) : ORIGIN = 0x10000000, LENGTH = 0x00020000 /* 128 KiB */
}
/* top end of the stack */
@ -19,7 +20,7 @@ SECTIONS
{
/* This is the initialized data section
The program executes knowing that the data is in the RAM
but the loader puts the initial values in the FLASH (inidata).
but the loader puts the initial values in the FLASH_FIRMWARE (inidata).
It is one task of the startup to copy the initial values from FLASH to RAM. */
.data : AT ( _sidata )
{
@ -73,7 +74,7 @@ SECTIONS
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} >RAM
/* The program code and other data goes into FLASH */
/* The program code and other data goes into FLASH_FIRMWARE */
.text :
{
. = ALIGN(4);
@ -88,7 +89,7 @@ SECTIONS
. = ALIGN(4);
_etext = .; /* define a global symbol at end of code */
_sidata = _etext; /* This is used by the startup in order to initialize the .data secion */
} >FLASH
} >FLASH_FIRMWARE
/* Uninitialized data section */
.bss :

View File

@ -37,26 +37,6 @@
#include "irq.h"
/*------------------------------------------------------------------*/
/* delay
*------------------------------------------------------------------*/
void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0;
while (duration < delay) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break;
}
duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait.
}
}
void mp_hal_delay_us(mp_uint_t delay) {
mp_hal_delay_ms(delay / 1000);
}

View File

@ -37,6 +37,7 @@
#include "py/runtime.h"
#include "lib/oofatfs/ff.h"
#include "supervisor/flash.h"
#include "supervisor/usb.h"
#include "csr.h"
@ -270,7 +271,7 @@ uint32_t supervisor_flash_get_block_count(void) {
}
__attribute__((section(".ramtext")))
void supervisor_flash_flush(void) {
void port_internal_flash_flush(void) {
// Skip if data is the same, or if there is no data in the cache
if (_flash_page_addr == NO_CACHE)
return;

View File

@ -27,11 +27,43 @@
#include <stdint.h>
#include "supervisor/port.h"
#include "supervisor/shared/tick.h"
#include "boards/board.h"
#include "tick.h"
#include "irq.h"
#include "csr.h"
// Global millisecond tick count. 1024 per second because most RTCs are clocked with 32.768khz
// crystals.
volatile uint64_t raw_ticks = 0;
volatile int subsecond = 0;
__attribute__((section(".ramtext")))
void SysTick_Handler(void) {
timer0_ev_pending_write(1);
raw_ticks += 1;
subsecond += 1;
// We track subsecond ticks so that we can increment raw_ticks one extra every 40 ms. We do this
// every 40 except 0 to make it 24 increments and not 25.
if (subsecond == 1000) {
subsecond = 0;
} else if (subsecond % 40 == 0) {
raw_ticks += 1;
}
supervisor_tick();
}
static void tick_init(void) {
int t;
timer0_en_write(0);
t = CONFIG_CLOCK_FREQUENCY / 1000; // 1000 kHz tick
timer0_reload_write(t);
timer0_load_write(t);
timer0_en_write(1);
timer0_ev_enable_write(1);
timer0_ev_pending_write(1);
irq_setmask(irq_getmask() | (1 << TIMER0_INTERRUPT));
}
safe_mode_t port_init(void) {
irq_setmask(0);
irq_setie(1);
@ -83,3 +115,22 @@ void port_set_saved_word(uint32_t value) {
uint32_t port_get_saved_word(void) {
return _ebss;
}
uint64_t port_get_raw_ticks(uint8_t* subticks) {
return raw_ticks;
}
// Enable 1/1024 second tick.
void port_enable_tick(void) {
}
// Disable 1/1024 second tick.
void port_disable_tick(void) {
}
void port_interrupt_after_ticks(uint32_t ticks) {
}
// TODO: Add sleep support if the SoC supports sleep.
void port_sleep_until_interrupt(void) {
}

View File

@ -25,8 +25,6 @@
* THE SOFTWARE.
*/
#include "tick.h"
#include "supervisor/usb.h"
#include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h"

View File

@ -1,82 +0,0 @@
/*
* 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 "csr.h"
#include "tick.h"
#include "irq.h"
#include "supervisor/shared/autoreload.h"
#include "supervisor/filesystem.h"
#include "supervisor/shared/tick.h"
#include "shared-module/gamepad/__init__.h"
#include "shared-bindings/microcontroller/Processor.h"
// Global millisecond tick count
// volatile uint64_t ticks_ms = 0;
__attribute__((section(".ramtext")))
void SysTick_Handler(void) {
timer0_ev_pending_write(1);
supervisor_tick();
}
void tick_init() {
int t;
timer0_en_write(0);
t = CONFIG_CLOCK_FREQUENCY / 1000; // 1000 kHz tick
timer0_reload_write(t);
timer0_load_write(t);
timer0_en_write(1);
timer0_ev_enable_write(1);
timer0_ev_pending_write(1);
irq_setmask(irq_getmask() | (1 << TIMER0_INTERRUPT));
}
void tick_delay(uint32_t us) {
// uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
// uint32_t us_between_ticks = SysTick->VAL / ticks_per_us;
// uint64_t start_ms = ticks_ms;
// while (us > 1000) {
// while (ticks_ms == start_ms) {}
// us -= us_between_ticks;
// start_ms = ticks_ms;
// us_between_ticks = 1000;
// }
// while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {}
}
// us counts down!
void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
// uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
// *ms = ticks_ms;
// *us_until_ms = SysTick->VAL / ticks_per_us;
}
void wait_until(uint64_t ms, uint32_t us_until_ms) {
// uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
// while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
}

View File

@ -1,46 +0,0 @@
/*
* 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.
*/
#ifndef MICROPY_INCLUDED_LITEX_TICK_H
#define MICROPY_INCLUDED_LITEX_TICK_H
#include "py/mpconfig.h"
#include <stdint.h>
extern volatile uint64_t ticks_ms;
extern struct timer_descriptor ms_timer;
void tick_init(void);
void tick_delay(uint32_t us);
void current_tick(uint64_t* ms, uint32_t* us_until_ms);
// Do not call this with interrupts disabled because it may be waiting for
// ticks_ms to increment.
void wait_until(uint64_t ms, uint32_t us_until_ms);
#endif // MICROPY_INCLUDED_LITEX_TICK_H

View File

@ -162,8 +162,8 @@ SRC_C = \
peripherals/mimxrt10xx/$(CHIP_FAMILY)/pins.c \
reset.c \
supervisor/flexspi_nor_flash_ops.c \
supervisor/shared/memory.c \
tick.c
supervisor/shared/memory.c
ifeq ($(CIRCUITPY_NETWORK),1)
CFLAGS += -DMICROPY_PY_NETWORK=1

View File

@ -27,7 +27,6 @@
#include "background.h"
//#include "audio_dma.h"
#include "tick.h"
#include "supervisor/filesystem.h"
#include "supervisor/shared/tick.h"
#include "supervisor/usb.h"

View File

@ -33,8 +33,6 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "tick.h"
void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {

View File

@ -25,16 +25,13 @@
* THE SOFTWARE.
*/
#include "py/mphal.h"
#include "shared-bindings/neopixel_write/__init__.h"
#include "tick.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "common-hal/microcontroller/Pin.h"
#include "supervisor/linker.h"
#include "supervisor/port.h"
uint64_t next_start_tick_ms = 0;
uint32_t next_start_tick_us = 1000;
uint64_t next_start_raw_ticks = 0;
//sysclock divisors
#define MAGIC_800_INT 900000 // ~1.11 us -> 1.2 field
@ -58,9 +55,9 @@ void PLACE_IN_ITCM(common_hal_neopixel_write)(const digitalio_digitalinout_obj_t
const uint32_t t0 = (sys_freq / MAGIC_800_T0H);
const uint32_t t1 = (sys_freq / MAGIC_800_T1H);
// This must be called while interrupts are on in case we're waiting for a
// future ms tick.
wait_until(next_start_tick_ms, next_start_tick_us);
// Wait to make sure we don't append onto the last transmission. This should only be a tick or
// two.
while (port_get_raw_ticks(NULL) < next_start_raw_ticks) {}
GPIO_Type *gpio = digitalinout->pin->gpio;
const uint32_t pin = digitalinout->pin->number;
@ -85,17 +82,11 @@ void PLACE_IN_ITCM(common_hal_neopixel_write)(const digitalio_digitalinout_obj_t
}
}
// Update the next start.
next_start_raw_ticks = port_get_raw_ticks(NULL) + 4;
// Enable interrupts again
__enable_irq();
// Update the next start.
current_tick(&next_start_tick_ms, &next_start_tick_us);
if (next_start_tick_us < 100) {
next_start_tick_ms += 1;
next_start_tick_us = 100 - next_start_tick_us;
} else {
next_start_tick_us -= 100;
}
}
#pragma GCC pop_options

View File

@ -38,8 +38,6 @@
#include "shared-bindings/pulseio/PulseIn.h"
#include "supervisor/shared/translate.h"
#include "tick.h"
// TODO
//static void pulsein_set_config(pulseio_pulsein_obj_t* self, bool first_edge) {
// uint32_t sense_setting;

View File

@ -72,5 +72,6 @@ int common_hal_rtc_get_calibration(void) {
}
void common_hal_rtc_set_calibration(int calibration) {
// SNVS has HPCALB_VAL bits for calibration.
mp_raise_NotImplementedError(translate("RTC calibration is not supported on this board"));
}

View File

@ -21,7 +21,7 @@ MEMORY
/* This can't move because the bootrom looks at this address. */
FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K
/* Place the ISRs 48k in to leave room for the bootloader when it is available. */
FLASH_TEXT (rx) : ORIGIN = 0x6000C000, LENGTH = code_size - 48K
FLASH_FIRMWARE (rx) : ORIGIN = 0x6000C000, LENGTH = code_size - 48K
FLASH_FATFS (r) : ORIGIN = 0x60100000, LENGTH = _ld_flash_size - code_size - _ld_reserved_flash_size
/* Teensy uses the last bit of flash for recovery. */
RESERVED_FLASH : ORIGIN = 0x60100000 + _ld_flash_size - _ld_reserved_flash_size, LENGTH = _ld_reserved_flash_size
@ -67,7 +67,7 @@ SECTIONS
) .text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} > FLASH_TEXT
} > FLASH_FIRMWARE
.ARM.exidx :
{
@ -75,7 +75,7 @@ SECTIONS
*(.gnu.linkonce.armexidx.*)
_etext = .; /* define a global symbol at end of code */
__etext = .; /* define a global symbol at end of code */
} > FLASH_TEXT
} > FLASH_FIRMWARE
_ld_filesystem_start = ORIGIN(FLASH_FATFS);
_ld_filesystem_end = _ld_filesystem_start + LENGTH(FLASH_FATFS);
@ -87,7 +87,7 @@ SECTIONS
*flexspi_nor_flash_ops.o(.text*)
*fsl_flexspi.o(.text*)
. = ALIGN(4);
} > OCRAM AT> FLASH_TEXT
} > OCRAM AT> FLASH_FIRMWARE
_ld_ocram_data_destination = ADDR(.data);
_ld_ocram_data_flash_copy = LOADADDR(.data);
_ld_ocram_data_size = SIZEOF(.data);
@ -114,7 +114,7 @@ SECTIONS
*(.itcm.*)
. = ALIGN(4);
} > ITCM AT> FLASH_TEXT
} > ITCM AT> FLASH_FIRMWARE
_ld_itcm_destination = ADDR(.itcm);
_ld_itcm_flash_copy = LOADADDR(.itcm);
_ld_itcm_size = SIZEOF(.itcm);
@ -126,7 +126,7 @@ SECTIONS
*(.dtcm_data.*)
. = ALIGN(4);
} > DTCM AT> FLASH_TEXT
} > DTCM AT> FLASH_FIRMWARE
_ld_dtcm_data_destination = ADDR(.dtcm_data);
_ld_dtcm_data_flash_copy = LOADADDR(.dtcm_data);
_ld_dtcm_data_size = SIZEOF(.dtcm_data);

View File

@ -33,21 +33,6 @@
#include "fsl_common.h"
void mp_hal_delay_ms(mp_uint_t delay) {
uint64_t start_tick = supervisor_ticks_ms64();
uint64_t duration = 0;
while (duration < delay) {
RUN_BACKGROUND_TASKS;
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
break;
}
duration = (supervisor_ticks_ms64() - start_tick);
// TODO(tannewt): Go to sleep for a little while while we wait.
}
}
void mp_hal_delay_us(mp_uint_t delay) {
#if defined(MIMXRT1011_SERIES) || defined(MIMXRT1021_SERIES)
SDK_DelayAtLeastUs(delay, SystemCoreClock);

@ -1 +1 @@
Subproject commit 4e7438e654f4a6b4f386b4bb9e817d74a0fbffc7
Subproject commit 8363ff7bed7533b9e7e6a6239aace3d6da14f349

View File

@ -183,7 +183,7 @@ uint32_t supervisor_flash_get_block_count(void) {
return CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE;
}
void supervisor_flash_flush(void) {
void port_internal_flash_flush(void) {
if (_flash_page_addr == NO_CACHE) return;
status_t status;

View File

@ -43,7 +43,6 @@
#include "common-hal/rtc/RTC.h"
#include "reset.h"
#include "tick.h"
#include "tusb.h"
@ -54,6 +53,7 @@
#include "shared-module/gamepadshift/__init__.h"
#endif
#include "shared-module/_pew/PewPew.h"
#include "supervisor/shared/tick.h"
#include "clocks.h"
@ -244,15 +244,18 @@ __attribute__((used, naked)) void Reset_Handler(void) {
}
safe_mode_t port_init(void) {
clocks_init();
CLOCK_SetMode(kCLOCK_ModeRun);
// Configure millisecond timer initialization.
tick_init();
clocks_init();
#if CIRCUITPY_RTC
rtc_init();
#endif
// Always enable the SNVS interrupt. The GPC won't wake us up unless at least one interrupt is
// enabled. It won't occur very often so it'll be low overhead.
NVIC_EnableIRQ(SNVS_HP_WRAPPER_IRQn);
// Reset everything into a known state before board_init.
reset_port();
@ -332,7 +335,7 @@ uint32_t *port_heap_get_top(void) {
return &_ld_heap_end;
}
// Place the word to save just after our BSS section that gets blanked.
// Place the word into the low power section of the SNVS.
void port_set_saved_word(uint32_t value) {
SNVS->LPGPR[1] = value;
}
@ -341,6 +344,67 @@ uint32_t port_get_saved_word(void) {
return SNVS->LPGPR[1];
}
uint64_t port_get_raw_ticks(uint8_t* subticks) {
uint64_t ticks = 0;
uint64_t next_ticks = 1;
while (ticks != next_ticks) {
ticks = next_ticks;
next_ticks = ((uint64_t) SNVS->HPRTCMR) << 32 | SNVS->HPRTCLR;
}
if (subticks != NULL) {
*subticks = ticks % 32;
}
return ticks / 32;
}
void SNVS_HP_WRAPPER_IRQHandler(void) {
if ((SNVS->HPSR & SNVS_HPSR_PI_MASK) != 0) {
supervisor_tick();
SNVS->HPSR = SNVS_HPSR_PI_MASK;
}
if ((SNVS->HPSR & SNVS_HPSR_HPTA_MASK) != 0) {
SNVS->HPSR = SNVS_HPSR_HPTA_MASK;
}
}
// Enable 1/1024 second tick.
void port_enable_tick(void) {
uint32_t hpcr = SNVS->HPCR;
hpcr &= ~SNVS_HPCR_PI_FREQ_MASK;
SNVS->HPCR = hpcr | SNVS_HPCR_PI_FREQ(5) | SNVS_HPCR_PI_EN_MASK;
}
// Disable 1/1024 second tick.
void port_disable_tick(void) {
SNVS->HPCR &= ~SNVS_HPCR_PI_EN_MASK;
}
void port_interrupt_after_ticks(uint32_t ticks) {
uint8_t subticks;
uint64_t current_ticks = port_get_raw_ticks(&subticks);
current_ticks += ticks;
SNVS->HPCR &= ~SNVS_HPCR_HPTA_EN_MASK;
// Wait for the alarm to be disabled.
while ((SNVS->HPCR & SNVS_HPCR_HPTA_EN_MASK) != 0) {}
SNVS->HPTAMR = current_ticks >> (32 - 5);
SNVS->HPTALR = current_ticks << 5 | subticks;
SNVS->HPCR |= SNVS_HPCR_HPTA_EN_MASK;
}
void port_sleep_until_interrupt(void) {
// App note here: https://www.nxp.com/docs/en/application-note/AN12085.pdf
// Clear the FPU interrupt because it can prevent us from sleeping.
if (__get_FPSCR() & ~(0x9f)) {
__set_FPSCR(__get_FPSCR() & ~(0x9f));
(void) __get_FPSCR();
}
NVIC_ClearPendingIRQ(SNVS_HP_WRAPPER_IRQn);
CLOCK_SetMode(kCLOCK_ModeWait);
__WFI();
CLOCK_SetMode(kCLOCK_ModeRun);
}
/**
* \brief Default interrupt handler for unused IRQs.
*/
@ -384,4 +448,3 @@ __attribute__((used)) void HardFault_Handler(void)
asm("nop;");
}
}

View File

@ -1,92 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Artur Pacholec
*
* 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 "tick.h"
#include "fsl_common.h"
#include "supervisor/shared/tick.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Processor.h"
void SysTick_Handler(void) {
// SysTick interrupt handler called when the SysTick timer reaches zero
// (every millisecond).
common_hal_mcu_disable_interrupts();
// Read the control register to reset the COUNTFLAG.
(void) SysTick->CTRL;
common_hal_mcu_enable_interrupts();
// Do things common to all ports when the tick occurs
supervisor_tick();
}
void tick_init() {
uint32_t ticks_per_ms = common_hal_mcu_processor_get_frequency() / 1000;
SysTick_Config(ticks_per_ms-1);
}
void tick_delay(uint32_t us) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
uint32_t us_until_next_tick = SysTick->VAL / ticks_per_us;
uint32_t start_tick;
while (us >= us_until_next_tick) {
start_tick = SysTick->VAL; // wait for SysTick->VAL to RESET
while (SysTick->VAL < start_tick) {}
us -= us_until_next_tick;
us_until_next_tick = 1000;
}
while (SysTick->VAL > ((us_until_next_tick - us) * ticks_per_us)) {}
}
// us counts down!
void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
// We disable interrupts to prevent ticks_ms from changing while we grab it.
common_hal_mcu_disable_interrupts();
uint32_t tick_status = SysTick->CTRL;
uint32_t current_us = SysTick->VAL;
uint32_t tick_status2 = SysTick->CTRL;
uint64_t current_ms = supervisor_ticks_ms64();
// The second clause ensures our value actually rolled over. Its possible it hit zero between
// the VAL read and CTRL read.
if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 ||
((tick_status2 & SysTick_CTRL_COUNTFLAG_Msk) != 0 && current_us > ticks_per_us)) {
current_ms++;
}
common_hal_mcu_enable_interrupts();
*ms = current_ms;
*us_until_ms = current_us / ticks_per_us;
}
void wait_until(uint64_t ms, uint32_t us_until_ms) {
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
}

View File

@ -1,43 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Artur Pacholec
*
* 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.
*/
#ifndef MICROPY_INCLUDED_MIMXRT10XX_TICK_H
#define MICROPY_INCLUDED_MIMXRT10XX_TICK_H
#include "py/mpconfig.h"
extern struct timer_descriptor ms_timer;
void tick_init(void);
void tick_delay(uint32_t us);
void current_tick(uint64_t* ms, uint32_t* us_until_ms);
// Do not call this with interrupts disabled because it may be waiting for
// ticks_ms to increment.
void wait_until(uint64_t ms, uint32_t us_until_ms);
#endif // MICROPY_INCLUDED_MIMXRT10XX_TICK_H

View File

@ -88,7 +88,7 @@ INC += -I../../supervisor/shared/usb
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb3 -Og
else
CFLAGS += -Os -DNDEBUG
CFLAGS += -Os -DNDEBUG -ggdb3
CFLAGS += -flto -flto-partition=none
endif
@ -148,8 +148,6 @@ endif
SRC_C += \
background.c \
fatfs_port.c \
mphalport.c \
tick.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,5 @@
USB_VID = 0x239A
USB_PID = 0x802A
USB_PRODUCT = "TG-Watch02A"
USB_MANUFACTURER = "TG-Tech"
@ -9,3 +8,12 @@ MCU_CHIP = nrf52840
QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 2
EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q128JV_SQ"
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LSM6DS
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FocalTouch
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DS3231
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DRV2605
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center

View File

@ -31,7 +31,6 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -31,7 +31,6 @@
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
displayio_fourwire_obj_t board_display_obj;

View File

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright 2019 Sony Semiconductor Solutions Corporation
* Copyright (c) 2018 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
@ -24,9 +24,15 @@
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_CXD56_TICK_H
#define MICROPY_INCLUDED_CXD56_TICK_H
#include "boards/board.h"
#include "py/mpconfig.h"
void board_init(void) {
}
#endif // MICROPY_INCLUDED_CXD56_TICK_H
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}

Some files were not shown because too many files have changed in this diff Show More