Merge remote-tracking branch 'adafruit/master' into improve_verification

This commit is contained in:
Scott Shawcroft 2020-05-13 08:23:55 -07:00
commit 7546d47f77
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E
36 changed files with 452 additions and 19 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\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"
@ -254,6 +254,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Sebuah channel hardware interrupt sedang digunakan"
@ -1248,6 +1249,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\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"
@ -253,6 +253,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr ""
@ -1236,6 +1237,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2020-04-30 17:01+0000\n"
"Last-Translator: Jeff Epler <jepler@gmail.com>\n"
"Language-Team: German <https://later.unpythonic.net/projects/circuitpython/"
@ -262,6 +262,7 @@ msgstr "0.0 zu einer komplexen Potenz"
msgid "3-arg pow() not supported"
msgstr "3-arg pow() wird nicht unterstützt"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Ein Hardware Interrupt Kanal wird schon benutzt"
@ -1258,6 +1259,10 @@ msgstr "Zugang verweigert"
msgid "Pin does not have ADC capabilities"
msgstr "Pin hat keine ADC Funktionalität"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -253,6 +253,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr ""
@ -1236,6 +1237,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\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/"
@ -260,6 +260,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Avast! A hardware interrupt channel be used already"
@ -1245,6 +1246,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Belay that! Th' Pin be not ADC capable"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -255,6 +255,7 @@ msgstr "0.0 a una potencia compleja"
msgid "3-arg pow() not supported"
msgstr "pow() con 3 argumentos no soportado"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "El canal EXTINT ya está siendo utilizado"
@ -1250,6 +1251,10 @@ msgstr "Permiso denegado"
msgid "Pin does not have ADC capabilities"
msgstr "Pin no tiene capacidad ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -256,6 +256,7 @@ msgstr "0.0 para sa complex power"
msgid "3-arg pow() not supported"
msgstr "3-arg pow() hindi suportado"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Isang channel ng hardware interrupt ay ginagamit na"
@ -1256,6 +1257,10 @@ msgstr "Walang pahintulot"
msgid "Pin does not have ADC capabilities"
msgstr "Ang pin ay walang kakayahan sa ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2020-05-05 20:24+0000\n"
"Last-Translator: Jeff Epler <jepler@gmail.com>\n"
"Language-Team: French <https://later.unpythonic.net/projects/circuitpython/"
@ -264,6 +264,7 @@ msgstr "0.0 à une puissance complexe"
msgid "3-arg pow() not supported"
msgstr "pow() non supporté avec 3 arguments"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Un canal d'interruptions matérielles est déjà utilisé"
@ -1277,6 +1278,10 @@ msgstr "Permission refusée"
msgid "Pin does not have ADC capabilities"
msgstr "La broche ne peut être utilisée pour l'ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -255,6 +255,7 @@ msgstr "0.0 elevato alla potenza di un numero complesso"
msgid "3-arg pow() not supported"
msgstr "pow() con tre argmomenti non supportata"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Un canale di interrupt hardware è già in uso"
@ -1265,6 +1266,10 @@ msgstr "Permesso negato"
msgid "Pin does not have ADC capabilities"
msgstr "Il pin non ha capacità di ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -255,6 +255,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr ""
@ -1240,6 +1241,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -254,6 +254,7 @@ msgstr "0.0 do potęgi zespolonej"
msgid "3-arg pow() not supported"
msgstr "3-argumentowy pow() jest niewspierany"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Kanał przerwań sprzętowych w użyciu"
@ -1241,6 +1242,10 @@ msgstr "Odmowa dostępu"
msgid "Pin does not have ADC capabilities"
msgstr "Nóżka nie obsługuje ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -255,6 +255,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Um canal de interrupção de hardware já está em uso"
@ -1251,6 +1252,10 @@ msgstr "Permissão negada"
msgid "Pin does not have ADC capabilities"
msgstr "O pino não tem recursos de ADC"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
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-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\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"
@ -253,6 +253,7 @@ msgstr ""
msgid "3-arg pow() not supported"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr ""
@ -1236,6 +1237,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"POT-Creation-Date: 2020-05-12 14:37+1000\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -260,6 +260,7 @@ msgstr "0.0 dào fùzá diànyuán"
msgid "3-arg pow() not supported"
msgstr "bù zhīchí 3-arg pow ()"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "A hardware interrupt channel is already in use"
msgstr "Yìngjiàn zhōngduàn tōngdào yǐ zài shǐyòng zhōng"
@ -1255,6 +1256,10 @@ msgstr "Quánxiàn bèi jùjué"
msgid "Pin does not have ADC capabilities"
msgstr "Pin méiyǒu ADC nénglì"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
msgstr ""
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
msgstr ""

View File

@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_ROTARYIO = 0

View File

@ -19,6 +19,7 @@ CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_VECTORIO = 0
CFLAGS_INLINE_LIMIT = 55

View File

@ -9,10 +9,10 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
CIRCUITPY_COUNTIO = 0
SUPEROPT_GC = 0
CFLAGS_BOARD = --param max-inline-insns-auto=15
ifeq ($(TRANSLATION), zh_Latn_pinyin)
CFLAGS_INLINE_LIMIT = 35
endif
endif

View File

@ -12,6 +12,7 @@ EXTERNAL_FLASH_DEVICES = W25Q32BV
LONGINT_IMPL = MPZ
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0

View File

@ -23,6 +23,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE=0
CIRCUITPY_TOUCHIO=0
CIRCUITPY_USB_MIDI=0
CIRCUITPY_RTC=0
CIRCUITPY_COUNTIO=0
# Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice

View File

@ -0,0 +1,83 @@
#include "common-hal/countio/Counter.h"
#include "atmel_start_pins.h"
#include "eic_handler.h"
#include "samd/external_interrupts.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
void common_hal_countio_counter_construct(countio_counter_obj_t* self,
const mcu_pin_obj_t* pin_a) {
if (!pin_a->has_extint) {
mp_raise_RuntimeError(translate("Pin must support hardware interrupts"));
}
if (eic_get_enable()) {
if (!eic_channel_free(pin_a->extint_channel)) {
mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use"));
}
} else {
turn_on_external_interrupt_controller();
}
// These default settings apply when the EIC isn't yet enabled.
self->eic_channel_a = pin_a->extint_channel;
self->pin_a = pin_a->number;
gpio_set_pin_function(self->pin_a, GPIO_PIN_FUNCTION_A);
gpio_set_pin_pull_mode(self->pin_a, GPIO_PULL_UP);
set_eic_channel_data(self->eic_channel_a, (void*) self);
self->count = 0;
claim_pin(pin_a);
set_eic_handler(self->eic_channel_a, EIC_HANDLER_COUNTER);
turn_on_eic_channel(self->eic_channel_a, EIC_CONFIG_SENSE0_FALL_Val);
}
bool common_hal_countio_counter_deinited(countio_counter_obj_t* self) {
return self->pin_a == NO_PIN;
}
void common_hal_countio_counter_deinit(countio_counter_obj_t* self) {
if (common_hal_countio_counter_deinited(self)) {
return;
}
set_eic_handler(self->eic_channel_a, EIC_HANDLER_NO_INTERRUPT);
turn_off_eic_channel(self->eic_channel_a);
reset_pin_number(self->pin_a);
self->pin_a = NO_PIN;
}
mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self) {
return self->count;
}
void common_hal_countio_counter_set_count(countio_counter_obj_t* self,
mp_int_t new_count) {
self->count = new_count;
}
void common_hal_countio_counter_reset(countio_counter_obj_t* self){
self->count = 0;
}
void counter_interrupt_handler(uint8_t channel) {
countio_counter_obj_t* self = get_eic_channel_data(channel);
self->count += 1;
}

View File

@ -0,0 +1,19 @@
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNTER_H
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNTER_H
#include "common-hal/microcontroller/Pin.h"
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
uint8_t pin_a;
uint8_t eic_channel_a:4;
mp_int_t count;
} countio_counter_obj_t;
void counter_interrupt_handler(uint8_t channel);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_COUNTIO_COUNT_H

View File

@ -0,0 +1 @@
//No countio module functions

View File

@ -27,6 +27,7 @@
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/ps2io/Ps2.h"
#include "common-hal/rotaryio/IncrementalEncoder.h"
#include "common-hal/countio/Counter.h"
#include "shared-bindings/microcontroller/__init__.h"
//#include "samd/external_interrupts.h"
#include "eic_handler.h"
@ -59,6 +60,12 @@ void shared_eic_handler(uint8_t channel) {
break;
#endif
#if CIRCUITPY_COUNTIO
case EIC_HANDLER_COUNTER:
counter_interrupt_handler(channel);
break;
#endif
default:
break;
}

View File

@ -30,6 +30,7 @@
#define EIC_HANDLER_PULSEIN 0x1
#define EIC_HANDLER_INCREMENTAL_ENCODER 0x2
#define EIC_HANDLER_PS2 0x3
#define EIC_HANDLER_COUNTER 0x04
void set_eic_handler(uint8_t channel, uint8_t eic_handler);
void shared_eic_handler(uint8_t channel);

View File

@ -18,5 +18,5 @@ CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
INTERNAL_LIBM = 1

View File

@ -25,7 +25,7 @@ CIRCUITPY_NVM = 0
CIRCUITPY_PULSEIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_COUNTIO = 0
# Enable USB support
CIRCUITPY_USB_HID = 1
CIRCUITPY_USB_MIDI = 1

View File

@ -26,5 +26,5 @@ CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_COUNTIO = 0
LONGINT_IMPL = MPZ

View File

@ -36,6 +36,8 @@ CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_RGBMATRIX ?= 1
CIRCUITPY_FRAMEBUFFERIO ?= 1
CIRCUITPY_COUNTIO = 0
# nRF52840-specific
ifeq ($(MCU_CHIP),nrf52840)

View File

@ -13,6 +13,7 @@ ifeq ($(MCU_SERIES),F4)
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0
@ -30,6 +31,7 @@ ifeq ($(MCU_SERIES),H7)
CIRCUITPY_NVM = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_FREQUENCYIO = 0
@ -44,6 +46,7 @@ ifeq ($(MCU_SERIES),F7)
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0

View File

@ -139,6 +139,9 @@ endif
ifeq ($(CIRCUITPY_BUSIO),1)
SRC_PATTERNS += busio/% bitbangio/OneWire.%
endif
ifeq ($(CIRCUITPY_COUNTIO),1)
SRC_PATTERNS += countio/%
endif
ifeq ($(CIRCUITPY_DIGITALIO),1)
SRC_PATTERNS += digitalio/%
endif
@ -269,6 +272,8 @@ SRC_COMMON_HAL_ALL = \
busio/SPI.c \
busio/UART.c \
busio/__init__.c \
countio/Counter.c \
countio/__init__.c \
digitalio/DigitalInOut.c \
digitalio/__init__.c \
displayio/ParallelBus.c \

View File

@ -321,6 +321,13 @@ extern const struct _mp_obj_module_t busio_module;
#define BUSIO_MODULE
#endif
#if CIRCUITPY_COUNTIO
extern const struct _mp_obj_module_t countio_module;
#define COUNTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_countio), (mp_obj_t)&countio_module },
#else
#define COUNTIO_MODULE
#endif
#if CIRCUITPY_DIGITALIO
extern const struct _mp_obj_module_t digitalio_module;
#define DIGITALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module },
@ -645,6 +652,7 @@ extern const struct _mp_obj_module_t ustack_module;
BLEIO_MODULE \
BOARD_MODULE \
BUSIO_MODULE \
COUNTIO_MODULE \
DIGITALIO_MODULE \
DISPLAYIO_MODULE \
FONTIO_MODULE \

View File

@ -88,6 +88,9 @@ CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
CIRCUITPY_DIGITALIO ?= 1
CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO)
CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)

View File

@ -0,0 +1,151 @@
#include <stdint.h>
#include "lib/utils/context_manager_helpers.h"
#include "py/objproperty.h"
#include "py/runtime.h"
#include "py/runtime0.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/countio/Counter.h"
#include "shared-bindings/util.h"
//| .. currentmodule:: countio
//|
//| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin
//| ========================================================================================
//|
//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin
//|
//| .. class:: Counter(pin_a)
//|
//| Create a Counter object associated with the given pin. It tracks the number of
//| falling pulses relative when the object is constructed.
//|
//| :param ~microcontroller.Pin pin_a: Pin to read pulses from.
//|
//|
//| For example::
//|
//| import countio
//| import time
//| from board import *
//|
//| pin_counter = countio.Counter(board.D1)
//| #reset the count after 100 counts
//| while True:
//| if pin_counter.count == 100:
//| pin_counter.reset()
//| print(pin_counter.count)
//|
STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_pin_a };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ }
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t);
self->base.type = &countio_counter_type;
common_hal_countio_counter_construct(self, pin_a);
return MP_OBJ_FROM_PTR(self);
}
//| .. method:: deinit()
//|
//| Deinitializes the Counter and releases any hardware resources for reuse.
//|
STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) {
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_countio_counter_deinit(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_deinit_obj, countio_counter_deinit);
STATIC void check_for_deinit(countio_counter_obj_t *self) {
if (common_hal_countio_counter_deinited(self)) {
raise_deinited_error();
}
}
//| .. method:: __enter__()
//|
//| No-op used by Context Managers.
//|
// Provided by context manager helper.
//| .. method:: __exit__()
//|
//| Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
common_hal_countio_counter_deinit(args[0]);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__);
//| .. attribute:: count
//|
//| The current count in terms of pulses.
//|
//|
STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) {
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return mp_obj_new_int(common_hal_countio_counter_get_count(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_get_count_obj, countio_counter_obj_get_count);
STATIC mp_obj_t countio_counter_obj_set_count(mp_obj_t self_in, mp_obj_t new_count) {
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
common_hal_countio_counter_set_count(self, mp_obj_get_int(new_count));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(countio_counter_set_count_obj, countio_counter_obj_set_count);
const mp_obj_property_t countio_counter_count_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&countio_counter_get_count_obj,
(mp_obj_t)&countio_counter_set_count_obj,
(mp_obj_t)&mp_const_none_obj},
};
STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
//set the position to zero for reset
common_hal_countio_counter_reset(self);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset);
STATIC const mp_rom_map_elem_t countio_counter_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&countio_counter_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&countio_counter___exit___obj) },
{ MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&countio_counter_count_obj) },
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&countio_counter_reset_obj) },
};
STATIC MP_DEFINE_CONST_DICT(countio_counter_locals_dict, countio_counter_locals_dict_table);
const mp_obj_type_t countio_counter_type = {
{ &mp_type_type },
.name = MP_QSTR_Counter,
.make_new = countio_counter_make_new,
.locals_dict = (mp_obj_dict_t*)&countio_counter_locals_dict,
};

View File

@ -0,0 +1,18 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/countio/Counter.h"
extern const mp_obj_type_t countio_counter_type;
extern void common_hal_countio_counter_construct(countio_counter_obj_t* self,
const mcu_pin_obj_t* pin_a);
extern void common_hal_countio_counter_deinit(countio_counter_obj_t* self);
extern bool common_hal_countio_counter_deinited(countio_counter_obj_t* self);
extern mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self);
extern void common_hal_countio_counter_set_count(countio_counter_obj_t* self,
mp_int_t new_count);
extern void common_hal_countio_counter_reset(countio_counter_obj_t* self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H

View File

@ -0,0 +1,48 @@
#include <stdint.h>
#include "py/obj.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/countio/__init__.h"
#include "shared-bindings/countio/Counter.h"
//| :mod:`countio` --- Support for edge counting
//| ========================================================
//|
//| .. module:: countio
//| :synopsis: Support for edge counting
//| :platform: SAMD
//|
//| The `countio` module contains logic to read and count edge transistions
//|
//| Libraries
//|
//| .. toctree::
//| :maxdepth: 3
//|
//| Counter
//|
//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the
//| :ref:`module-support-matrix` for more info.
//|
//| All classes change hardware state and should be deinitialized when they
//| are no longer needed if the program continues after use. To do so, either
//| call :py:meth:`!deinit` or use a context manager. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
STATIC const mp_rom_map_elem_t countio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_countio) },
{ MP_ROM_QSTR(MP_QSTR_Counter), MP_ROM_PTR(&countio_counter_type) },
};
STATIC MP_DEFINE_CONST_DICT(countio_module_globals, countio_module_globals_table);
const mp_obj_module_t countio_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&countio_module_globals,
};

View File

@ -0,0 +1,9 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H
#define MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H
#include "py/obj.h"
// Nothing now.
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO___INIT___H