Merge pull request #2931 from tannewt/esp32s2_digitalio

Finish digitalio and pin use tracking for ESP32S2
This commit is contained in:
Dan Halbert 2020-05-26 19:18:45 -04:00 committed by GitHub
commit 3574670226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1012 additions and 832 deletions

View File

@ -210,6 +210,12 @@ locale/circuitpython.pot: all-source
translate: locale/circuitpython.pot
for po in $(shell ls locale/*.po); do msgmerge -U $$po -s --no-fuzzy-matching --add-location=file locale/circuitpython.pot; done
merge-translate:
git merge HEAD 1>&2 2> /dev/null; test $$? -eq 128
rm locale/*~ || true
git checkout --ours -- locale/*
make translate
check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
$(PYTHON) tools/check_translations.py $^

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-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"
@ -1082,10 +1082,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1249,6 +1245,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-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"
@ -1071,10 +1071,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1237,6 +1233,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -3,28 +3,25 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"PO-Revision-Date: 2020-05-24 03:22+0000\n"
"Last-Translator: dronecz <mzuzelka@gmail.com>\n"
"POT-Creation-Date: 2020-05-26 13:09-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"
"Language: cs\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 4.1-dev\n"
#: main.c
msgid ""
"\n"
"Code done running. Waiting for reload.\n"
msgstr ""
"\n"
"Kód byl dokončen. Čekám na opětovné načtení.\n"
#: supervisor/shared/safe_mode.c
msgid ""
@ -32,70 +29,65 @@ msgid ""
"Please file an issue with the contents of your CIRCUITPY drive at \n"
"https://github.com/adafruit/circuitpython/issues\n"
msgstr ""
"\n"
"Založte prosím problém s obsahem vaší jednotky CIRCUITPY na adrese\n"
"https://github.com/adafruit/circuitpython/issues\n"
#: supervisor/shared/safe_mode.c
msgid ""
"\n"
"To exit, please reset the board without "
msgstr ""
"\n"
"Pro ukončení, prosím resetujte desku bez "
#: py/obj.c
msgid " File \"%q\""
msgstr "  Soubor \"% q\""
msgstr ""
#: py/obj.c
msgid " File \"%q\", line %d"
msgstr "  Soubor \"% q\", řádek% d"
msgstr ""
#: main.c
msgid " output:\n"
msgstr " výstup:\n"
msgstr ""
#: py/objstr.c
#, c-format
msgid "%%c requires int or char"
msgstr "%% c vyžaduje int nebo char"
msgstr ""
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr "%d adresní piny a %d rgb piny označují výšku %d, nikoli %d"
msgstr ""
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q se nyní používá"
msgstr ""
#: py/obj.c
msgid "%q index out of range"
msgstr "%q index je mimo rozsah"
msgstr ""
#: py/obj.c
msgid "%q indices must be integers, not %s"
msgstr "Indexy% q musí být celá čísla, nikoli% s"
msgstr ""
#: shared-bindings/vectorio/Polygon.c
msgid "%q list must be a list"
msgstr "Seznam% q musí být seznam"
msgstr ""
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
#: shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "% q musí být > = 1"
msgstr ""
#: shared-module/vectorio/Polygon.c
msgid "%q must be a tuple of length 2"
msgstr "% q musí být n-tice délky 2"
msgstr ""
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "% q by měl být int"
msgstr ""
#: py/bc.c py/objnamedtuple.c
msgid "%q() takes %d positional arguments but %d were given"
@ -1079,10 +1071,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1245,6 +1233,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -1071,10 +1071,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1237,6 +1233,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2020-03-30 22:11+0000\n"
"Last-Translator: Tannewt <devnull@unpythonic.net>\n"
"Language-Team: English <https://later.unpythonic.net/projects/circuitpython/"
@ -1080,10 +1080,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1246,6 +1242,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Belay that! Th' Pin be not ADC capable"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2020-05-17 20:56+0000\n"
"Last-Translator: Jeff Epler <jepler@gmail.com>\n"
"Language-Team: \n"
@ -1080,10 +1080,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1252,6 +1248,10 @@ msgstr "Permiso denegado"
msgid "Pin does not have ADC capabilities"
msgstr "Pin no tiene capacidad ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -1087,10 +1087,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1257,6 +1253,10 @@ msgstr "Walang pahintulot"
msgid "Pin does not have ADC capabilities"
msgstr "Ang pin ay walang kakayahan sa ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2020-05-17 20:56+0000\n"
"Last-Translator: Anonymous <noreply@weblate.org>\n"
"Language-Team: French <https://later.unpythonic.net/projects/circuitpython/"
@ -1102,10 +1102,6 @@ msgstr "Doit utiliser un multiple de 6 broches RVB, pas %d"
msgid "Name too long"
msgstr "Nom trop long"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr "Étape négative non prise en charge"
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr "Pas de CCCD pour cette caractéristique"
@ -1278,6 +1274,10 @@ msgstr "Permission refusée"
msgid "Pin does not have ADC capabilities"
msgstr "La broche ne peut être utilisée pour l'ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr "La broche doit prendre en charge les interruptions matérielles"
@ -3545,6 +3545,9 @@ msgstr "'step' nul"
#~ msgid "Must be a Group subclass."
#~ msgstr "Doit être une sous-classe de 'Group'"
#~ msgid "Negative step not supported"
#~ msgstr "Étape négative non prise en charge"
#~ msgid "No PulseIn support for %q"
#~ msgstr "Pas de support de PulseIn pour %q"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -1091,10 +1091,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1266,6 +1262,10 @@ msgstr "Permesso negato"
msgid "Pin does not have ADC capabilities"
msgstr "Il pin non ha capacità di ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1075,10 +1075,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1241,6 +1237,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-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"
@ -1076,10 +1076,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1242,6 +1238,10 @@ msgstr "Odmowa dostępu"
msgid "Pin does not have ADC capabilities"
msgstr "Nóżka nie obsługuje ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -1083,10 +1083,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr ""
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr ""
@ -1252,6 +1248,10 @@ msgstr "Permissão negada"
msgid "Pin does not have ADC capabilities"
msgstr "O pino não tem recursos de ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2020-05-20 18:32+0000\n"
"Last-Translator: Jonny Bergdahl <jonny@bergdahl.it>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1091,10 +1091,6 @@ msgstr "Måste använda ett multipel av 6 rgb-pinnar, inte %d"
msgid "Name too long"
msgstr "Name är för långt"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr "Negativt step stöds inte"
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr "Ingen CCCD för denna karaktäristik"
@ -1264,6 +1260,10 @@ msgstr "Åtkomst nekad"
msgid "Pin does not have ADC capabilities"
msgstr "Pinnen har inte ADC-funktionalitet"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr "Pinnen måste stödja hårdvaruavbrott"
@ -3275,5 +3275,8 @@ msgstr "y-värde utanför intervall"
msgid "zero step"
msgstr "noll steg"
#~ msgid "Negative step not supported"
#~ msgstr "Negativt step stöds inte"
#~ msgid "empty %q list"
#~ msgstr "tom %q-lista"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-19 15:01+0800\n"
"POT-Creation-Date: 2020-05-26 13:09-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -1084,10 +1084,6 @@ msgstr ""
msgid "Name too long"
msgstr ""
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Negative step not supported"
msgstr "Bù zhīchí fù bù"
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
msgstr "Zhège tèzhēng méiyǒu CCCD"
@ -1256,6 +1252,10 @@ msgstr "Quánxiàn bèi jùjué"
msgid "Pin does not have ADC capabilities"
msgstr "Pin méiyǒu ADC nénglì"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
@ -3443,6 +3443,9 @@ msgstr "líng bù"
#~ msgid "Must be a Group subclass."
#~ msgstr "Bìxū shì fēnzǔ zi lèi."
#~ msgid "Negative step not supported"
#~ msgstr "Bù zhīchí fù bù"
#~ msgid "No default I2C bus"
#~ msgstr "Méiyǒu mòrèn I2C gōnggòng qìchē"

View File

@ -73,7 +73,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
common_hal_digitalio_digitalinout_set_pull(self, pull);
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t* self, bool value,
digitalio_drive_mode_t drive_mode) {
const uint8_t pin = self->pin->number;
@ -86,6 +86,7 @@ void common_hal_digitalio_digitalinout_switch_to_output(
// Direction is set in set_value. We don't need to do it here.
common_hal_digitalio_digitalinout_set_value(self, value);
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
@ -128,7 +129,7 @@ bool common_hal_digitalio_digitalinout_get_value(
}
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t* self,
digitalio_drive_mode_t drive_mode) {
bool value = common_hal_digitalio_digitalinout_get_value(self);
@ -138,6 +139,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
if (value) {
common_hal_digitalio_digitalinout_set_value(self, value);
}
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(

View File

@ -70,7 +70,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_ob
board_gpio_config(self->pin->number, 0, true, true, pull);
}
void common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t *self, bool value, digitalio_drive_mode_t drive_mode) {
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t *self, bool value, digitalio_drive_mode_t drive_mode) {
self->input = false;
self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN;
board_gpio_write(self->pin->number, -1);
@ -80,6 +80,7 @@ void common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_o
board_gpio_write(self->pin->number, 0);
}
common_hal_digitalio_digitalinout_set_value(self, value);
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(digitalio_digitalinout_obj_t *self) {
@ -104,7 +105,7 @@ bool common_hal_digitalio_digitalinout_get_value(digitalio_digitalinout_obj_t *s
return board_gpio_read(self->pin->number);
}
void common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode) {
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode) {
if (drive_mode == DRIVE_MODE_PUSH_PULL) {
board_gpio_write(self->pin->number, -1);
board_gpio_config(self->pin->number, 0, false, true, PIN_FLOAT);
@ -115,6 +116,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj
board_gpio_write(self->pin->number, 0);
self->open_drain = true;
}
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(digitalio_digitalinout_obj_t *self) {

View File

@ -152,6 +152,7 @@ SRC_C += \
mphalport.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
modules/$(CIRCUITPY_MODULE).c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
lib/oofatfs/ff.c \

View File

@ -26,8 +26,16 @@
#include "boards/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// USB
never_reset_pin(&pin_GPIO19);
never_reset_pin(&pin_GPIO20);
// Debug UART
never_reset_pin(&pin_GPIO43);
never_reset_pin(&pin_GPIO44);
}
bool board_requests_safe_mode(void) {

View File

@ -18,3 +18,5 @@ CIRCUITPY_MICROCONTROLLER = 0
CIRCUITPY_ESP_FLASH_MODE=dio
CIRCUITPY_ESP_FLASH_FREQ=40m
CIRCUITPY_ESP_FLASH_SIZE=4MB
CIRCUITPY_MODULE=wroom

View File

@ -26,8 +26,16 @@
#include "boards/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/microcontroller/Pin.h"
void board_init(void) {
// USB
never_reset_pin(&pin_GPIO19);
never_reset_pin(&pin_GPIO20);
// Debug UART
never_reset_pin(&pin_GPIO43);
never_reset_pin(&pin_GPIO44);
}
bool board_requests_safe_mode(void) {

View File

@ -18,3 +18,5 @@ CIRCUITPY_MICROCONTROLLER = 0
CIRCUITPY_ESP_FLASH_MODE=dio
CIRCUITPY_ESP_FLASH_FREQ=40m
CIRCUITPY_ESP_FLASH_SIZE=4MB
CIRCUITPY_MODULE=wrover

View File

@ -30,24 +30,18 @@
#include "driver/gpio.h"
#include "esp_log.h"
static const char* TAG = "CircuitPython digitalio";
#include "esp-idf/components/soc/include/hal/gpio_hal.h"
void common_hal_digitalio_digitalinout_never_reset(
digitalio_digitalinout_obj_t *self) {
(void)self;
never_reset_pin_number(self->pin->number);
}
digitalinout_result_t common_hal_digitalio_digitalinout_construct(
digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) {
// claim_pin(pin);
claim_pin(pin);
self->pin = pin;
ESP_EARLY_LOGW(TAG, "construct %d", pin->number);
return DIGITALINOUT_OK;
}
@ -60,78 +54,86 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
return;
}
// reset_pin_number(0, self->pin->number);
reset_pin_number(self->pin->number);
self->pin = mp_const_none;
}
void common_hal_digitalio_digitalinout_switch_to_input(
digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
gpio_config_t config = {
.pin_bit_mask = 1 << self->pin->number,
.mode = GPIO_MODE_INPUT
};
if (pull == PULL_UP) {
config.pull_up_en = GPIO_PULLUP_ENABLE;
} else if (pull == PULL_DOWN) {
config.pull_down_en = GPIO_PULLDOWN_ENABLE;
common_hal_digitalio_digitalinout_set_pull(self, pull);
gpio_set_direction(self->pin->number, GPIO_MODE_DEF_INPUT);
}
gpio_config(&config);
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t *self, bool value,
digitalio_drive_mode_t drive_mode) {
gpio_config_t config = {
.pin_bit_mask = 1ULL << self->pin->number,
.mode = GPIO_MODE_OUTPUT
};
if (drive_mode == DRIVE_MODE_OPEN_DRAIN) {
config.mode = GPIO_MODE_OUTPUT_OD;
}
gpio_set_level(self->pin->number, value);
gpio_config(&config);
return common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
digitalio_digitalinout_obj_t *self) {
uint32_t iomux = READ_PERI_REG(GPIO_PIN_MUX_REG[self->pin->number]);
if ((iomux & FUN_IE) != 0) {
return DIRECTION_INPUT;
}
return DIRECTION_OUTPUT;
}
void common_hal_digitalio_digitalinout_set_value(
digitalio_digitalinout_obj_t *self, bool value) {
ESP_EARLY_LOGW(TAG, "set %d %d", self->pin->number, value);
gpio_set_level(self->pin->number, value);
}
bool common_hal_digitalio_digitalinout_get_value(
digitalio_digitalinout_obj_t *self) {
return true;
return gpio_get_level(self->pin->number) == 1;
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t *self,
digitalio_drive_mode_t drive_mode) {
(void)self;
(void)drive_mode;
gpio_num_t number = self->pin->number;
gpio_mode_t mode;
if (drive_mode == DRIVE_MODE_OPEN_DRAIN) {
mode = GPIO_MODE_DEF_OD;
} else {
mode = GPIO_MODE_DEF_OUTPUT;
}
esp_err_t result = gpio_set_direction(number, mode);
if (result != ESP_OK) {
return DIGITALINOUT_INPUT_ONLY;
}
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
digitalio_digitalinout_obj_t *self) {
// if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT)
// return DRIVE_MODE_PUSH_PULL;
// else
if (GPIO_HAL_GET_HW(GPIO_PORT_0)->pin[self->pin->number].pad_driver == 1) {
return DRIVE_MODE_OPEN_DRAIN;
}
return DRIVE_MODE_PUSH_PULL;
}
void common_hal_digitalio_digitalinout_set_pull(
digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
(void)self;
(void)pull;
gpio_num_t number = self->pin->number;
gpio_pullup_dis(number);
gpio_pulldown_dis(number);
if (pull == PULL_UP) {
gpio_pullup_en(number);
} else if (pull == PULL_DOWN) {
gpio_pulldown_en(number);
}
}
digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
digitalio_digitalinout_obj_t *self) {
gpio_num_t gpio_num = self->pin->number;
if (REG_GET_BIT(GPIO_PIN_MUX_REG[gpio_num], FUN_PU) == 1) {
return PULL_UP;
} else if (REG_GET_BIT(GPIO_PIN_MUX_REG[gpio_num], FUN_PD) == 1) {
return PULL_DOWN;
}
return PULL_NONE;
}

View File

@ -29,18 +29,51 @@
#include "py/mphal.h"
// Mark pin as free and return it to a quiescent state.
void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
#include "esp-idf/components/driver/include/driver/gpio.h"
#include "esp-idf/components/soc/include/hal/gpio_hal.h"
STATIC uint32_t never_reset_pins[2];
STATIC uint32_t in_use[2];
void never_reset_pin_number(gpio_num_t pin_number) {
never_reset_pins[pin_number / 32] |= 1 << pin_number % 32;
}
void never_reset_pin(const mcu_pin_obj_t* pin) {
never_reset_pin_number(pin->number);
}
// Mark pin as free and return it to a quiescent state.
void reset_pin_number(gpio_num_t pin_number) {
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
}
void reset_all_pins(void) {
for (uint8_t i = 0; i < GPIO_PIN_COUNT; i++) {
uint32_t iomux_address = GPIO_PIN_MUX_REG[i];
if (iomux_address == 0 ||
(never_reset_pins[i / 32] & (1 << i % 32)) != 0) {
continue;
}
gpio_set_direction(i, GPIO_MODE_DEF_INPUT);
gpio_pullup_dis(i);
gpio_pulldown_dis(i);
}
in_use[0] = 0;
in_use[1] = 0;
}
void claim_pin(const mcu_pin_obj_t* pin) {
in_use[pin->number / 32] |= (1 << pin->number % 32);
}
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
return true;
bool pin_number_is_free(gpio_num_t pin_number) {
uint8_t offset = pin_number / 32;
uint8_t mask = 1 << pin_number % 32;
return (never_reset_pins[offset] & mask) == 0 && (in_use[offset] & mask) == 0;
}
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
return pin_number_is_free(0, pin->number);
return pin_number_is_free(pin->number);
}

View File

@ -34,11 +34,10 @@
void reset_all_pins(void);
// reset_pin_number takes the pin number instead of the pointer so that objects don't
// need to store a full pointer.
void reset_pin_number(uint8_t pin_port, uint8_t pin_number);
void reset_pin_number(gpio_num_t pin_number);
void claim_pin(const mcu_pin_obj_t* pin);
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number);
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number);
// GPIO_TypeDef * pin_port(uint8_t pin_port);
uint16_t pin_mask(uint8_t pin_number);
bool pin_number_is_free(gpio_num_t pin_number);
void never_reset_pin_number(gpio_num_t pin_number);
void never_reset_pin(const mcu_pin_obj_t* pin);
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_PIN_H

View File

@ -39,24 +39,31 @@
#include "supervisor/filesystem.h"
#include "supervisor/shared/safe_mode.h"
#include "freertos/FreeRTOS.h"
void common_hal_mcu_delay_us(uint32_t delay) {
}
volatile uint32_t nesting_count = 0;
static portMUX_TYPE cp_mutex = portMUX_INITIALIZER_UNLOCKED;
void common_hal_mcu_disable_interrupts(void) {
if (nesting_count == 0) {
portENTER_CRITICAL(&cp_mutex);
}
nesting_count++;
}
void common_hal_mcu_enable_interrupts(void) {
if (nesting_count == 0) {
// Maybe log here because it's very bad.
}
nesting_count--;
if (nesting_count > 0) {
return;
}
portEXIT_CRITICAL(&cp_mutex);
}
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {

View File

@ -0,0 +1,35 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 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_ESP32S2_MODULES_MODULE_H
#define MICROPY_INCLUDED_ESP32S2_MODULES_MODULE_H
#include "shared-bindings/microcontroller/Pin.h"
void never_reset_module_internal_pins(void);
#endif // MICROPY_INCLUDED_ESP32S2_MODULES_MODULE_H

View File

@ -0,0 +1,28 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 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.
*/
void never_reset_module_internal_pins(void) {
}

View File

@ -0,0 +1,37 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 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 "modules/module.h"
void never_reset_module_internal_pins(void) {
// SPI Flash
never_reset_pin(&pin_GPIO27);
never_reset_pin(&pin_GPIO28);
never_reset_pin(&pin_GPIO29);
never_reset_pin(&pin_GPIO30);
never_reset_pin(&pin_GPIO31);
never_reset_pin(&pin_GPIO32);
}

View File

@ -0,0 +1,38 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2020 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 "modules/module.h"
void never_reset_module_internal_pins(void) {
// SPI Flash and RAM
never_reset_pin(&pin_GPIO26);
never_reset_pin(&pin_GPIO27);
never_reset_pin(&pin_GPIO28);
never_reset_pin(&pin_GPIO29);
never_reset_pin(&pin_GPIO30);
never_reset_pin(&pin_GPIO31);
never_reset_pin(&pin_GPIO32);
}

View File

@ -33,3 +33,5 @@ CIRCUITPY_TOUCHIO = 0
# Enable USB support
CIRCUITPY_USB_HID = 1
CIRCUITPY_USB_MIDI = 1
CIRCUITPY_MODULE ?= none

View File

@ -33,10 +33,12 @@
#include <stdint.h>
#include "esp32s2_peripherals_config.h"
#include "esp-idf/config/sdkconfig.h"
#include "esp-idf/components/soc/include/hal/gpio_types.h"
typedef struct {
PIN_PREFIX_FIELDS
uint8_t number;
gpio_num_t number;
} mcu_pin_obj_t;
extern const mcu_pin_obj_t pin_GPIO0;

View File

@ -29,10 +29,12 @@
#include <sys/time.h>
#include "supervisor/port.h"
#include "boards/board.h"
#include "modules/module.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "common-hal/microcontroller/Pin.h"
#include "supervisor/memory.h"
#include "supervisor/shared/tick.h"
@ -56,12 +58,14 @@ safe_mode_t port_init(void) {
if (result != ESP_OK) {
ESP_EARLY_LOGE(TAG, "Unable to create tick timer.");
}
never_reset_module_internal_pins();
ESP_EARLY_LOGW(TAG, "port init done");
return NO_SAFE_MODE;
}
void reset_port(void) {
reset_all_pins();
}
void reset_to_bootloader(void) {

View File

@ -64,12 +64,13 @@ void common_hal_digitalio_digitalinout_switch_to_input(
touch_oe_write(touch_oe_read() & ~(1 << self->pin->number));
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t *self, bool value,
digitalio_drive_mode_t drive_mode) {
(void)drive_mode;
common_hal_digitalio_digitalinout_set_value(self, value);
touch_oe_write(touch_oe_read() | (1 << self->pin->number));
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
@ -92,11 +93,12 @@ bool common_hal_digitalio_digitalinout_get_value(
return !!(touch_i_read() & (1 << self->pin->number));
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t *self,
digitalio_drive_mode_t drive_mode) {
(void)self;
(void)drive_mode;
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(

View File

@ -97,7 +97,7 @@ void common_hal_digitalio_digitalinout_switch_to_input(
common_hal_digitalio_digitalinout_set_pull(self, pull);
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t* self, bool value,
digitalio_drive_mode_t drive_mode) {
self->output = true;
@ -108,6 +108,7 @@ void common_hal_digitalio_digitalinout_switch_to_output(
const gpio_pin_config_t config = { kGPIO_DigitalOutput, value, kGPIO_NoIntmode };
GPIO_PinInit(self->pin->gpio, self->pin->number, &config);
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
@ -125,7 +126,7 @@ bool common_hal_digitalio_digitalinout_get_value(
return GPIO_PinRead(self->pin->gpio, self->pin->number);
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t* self,
digitalio_drive_mode_t drive_mode) {
bool value = common_hal_digitalio_digitalinout_get_value(self);
@ -138,6 +139,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
if (value) {
common_hal_digitalio_digitalinout_set_value(self, value);
}
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(

View File

@ -65,12 +65,13 @@ void common_hal_digitalio_digitalinout_switch_to_input(
common_hal_digitalio_digitalinout_set_pull(self, pull);
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t *self, bool value,
digitalio_drive_mode_t drive_mode) {
common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
common_hal_digitalio_digitalinout_set_value(self, value);
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
@ -92,7 +93,7 @@ bool common_hal_digitalio_digitalinout_get_value(
: nrf_gpio_pin_out_read(self->pin->number);
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t *self,
digitalio_drive_mode_t drive_mode) {
nrf_gpio_cfg(self->pin->number,
@ -101,6 +102,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
NRF_GPIO_PIN_NOPULL,
drive_mode == DRIVE_MODE_OPEN_DRAIN ? NRF_GPIO_PIN_H0D1 : NRF_GPIO_PIN_H0H1,
NRF_GPIO_PIN_NOSENSE);
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(

View File

@ -85,12 +85,13 @@ void common_hal_digitalio_digitalinout_switch_to_input(
common_hal_digitalio_digitalinout_set_pull(self, pull);
}
void common_hal_digitalio_digitalinout_switch_to_output(
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(
digitalio_digitalinout_obj_t *self, bool value,
digitalio_drive_mode_t drive_mode) {
common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
common_hal_digitalio_digitalinout_set_value(self, value);
return DIGITALINOUT_OK;
}
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
@ -112,7 +113,7 @@ bool common_hal_digitalio_digitalinout_get_value(
: LL_GPIO_IsOutputPinSet(pin_port(self->pin->port), pin_mask(self->pin->number));
}
void common_hal_digitalio_digitalinout_set_drive_mode(
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(
digitalio_digitalinout_obj_t *self,
digitalio_drive_mode_t drive_mode) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
@ -122,6 +123,7 @@ void common_hal_digitalio_digitalinout_set_drive_mode(
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
return DIGITALINOUT_OK;
}
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(

View File

@ -131,7 +131,10 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
drive_mode = DRIVE_MODE_OPEN_DRAIN;
}
// do the transfer
common_hal_digitalio_digitalinout_switch_to_output(self, args[ARG_value].u_bool, drive_mode);
digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(self, args[ARG_value].u_bool, drive_mode);
if (result == DIGITALINOUT_INPUT_ONLY) {
mp_raise_NotImplementedError(translate("Pin is input only"));
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output);
@ -207,7 +210,10 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_direction(mp_obj_t self_in, mp_ob
if (value == &digitalio_direction_input_obj) {
common_hal_digitalio_digitalinout_switch_to_input(self, PULL_NONE);
} else if (value == &digitalio_direction_output_obj) {
common_hal_digitalio_digitalinout_switch_to_output(self, false, DRIVE_MODE_PUSH_PULL);
digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(self, false, DRIVE_MODE_PUSH_PULL);
if (result == DIGITALINOUT_INPUT_ONLY) {
mp_raise_NotImplementedError(translate("Pin is input only"));
}
} else {
mp_raise_ValueError(translate("Invalid direction."));
}

View File

@ -37,18 +37,19 @@ extern const mp_obj_type_t digitalio_digitalinout_type;
typedef enum {
DIGITALINOUT_OK,
DIGITALINOUT_PIN_BUSY
DIGITALINOUT_PIN_BUSY,
DIGITALINOUT_INPUT_ONLY
} digitalinout_result_t;
digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin);
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self);
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self);
void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_obj_t* self, digitalio_pull_t pull);
void common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t* self, bool value, digitalio_drive_mode_t drive_mode);
digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t* self, bool value, digitalio_drive_mode_t drive_mode);
digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(digitalio_digitalinout_obj_t* self);
void common_hal_digitalio_digitalinout_set_value(digitalio_digitalinout_obj_t* self, bool value);
bool common_hal_digitalio_digitalinout_get_value(digitalio_digitalinout_obj_t* self);
void common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t* self, digitalio_drive_mode_t drive_mode);
digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t* self, digitalio_drive_mode_t drive_mode);
digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(digitalio_digitalinout_obj_t* self);
void common_hal_digitalio_digitalinout_set_pull(digitalio_digitalinout_obj_t* self, digitalio_pull_t pull);
digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(digitalio_digitalinout_obj_t* self);