summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-04-15 10:29:05 -0400
committerLucian Copeland <hierophect@gmail.com>2020-04-15 10:29:05 -0400
commit54abfc2e8b88ed0dd1caaf3ac926466b0aba717a (patch)
treeb5154c84f807ee6ce3b0716b3a8d7b64dca46061 /ports
parent0f87a75f4f0675ff55e31437907101226d5fb66b (diff)
parentae549fc9da555778884ff64a2ffe45df0a5248db (diff)
translations-merge
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/board.c1
-rw-r--r--ports/atmel-samd/boards/hallowing_m4_express/board.c1
-rw-r--r--ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/monster_m4sk/board.c1
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/board.c1
-rw-r--r--ports/atmel-samd/boards/pybadge/board.c1
-rw-r--r--ports/atmel-samd/boards/pybadge_airlift/board.c1
-rw-r--r--ports/atmel-samd/boards/pycubed/mpconfigboard.mk4
-rw-r--r--ports/atmel-samd/boards/pygamer/board.c1
-rw-r--r--ports/atmel-samd/boards/pygamer_advance/board.c1
-rw-r--r--ports/atmel-samd/boards/pyportal/board.c1
-rw-r--r--ports/atmel-samd/boards/pyportal_titano/board.c1
-rw-r--r--ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/ugame10/board.c1
-rw-r--r--ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/common-hal/_protomatter/Protomatter.c78
-rw-r--r--ports/atmel-samd/common-hal/_protomatter/Protomatter.h35
-rw-r--r--ports/atmel-samd/common-hal/_protomatter/__init__.c0
-rw-r--r--ports/atmel-samd/common-hal/microcontroller/Pin.c12
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PWMOut.c27
-rw-r--r--ports/atmel-samd/mpconfigport.mk12
-rw-r--r--ports/atmel-samd/timer_handler.c7
-rw-r--r--ports/atmel-samd/timer_handler.h5
-rw-r--r--ports/cxd56/boards/spresense/mpconfigboard.h3
-rw-r--r--ports/mimxrt10xx/mpconfigport.h2
-rw-r--r--ports/nrf/boards/clue_nrf52840_express/board.c1
-rw-r--r--ports/nrf/boards/ohs2020_badge/board.c1
-rw-r--r--ports/nrf/common-hal/_protomatter/Protomatter.c66
-rw-r--r--ports/nrf/common-hal/_protomatter/Protomatter.h35
-rw-r--r--ports/nrf/common-hal/_protomatter/__init__.c0
-rw-r--r--ports/nrf/common-hal/microcontroller/Pin.c12
-rw-r--r--ports/nrf/common-hal/pulseio/PulseOut.c5
-rw-r--r--ports/nrf/mpconfigport.mk3
-rw-r--r--ports/nrf/peripherals/nrf/timers.c55
-rw-r--r--ports/nrf/peripherals/nrf/timers.h5
-rw-r--r--ports/stm/boards/meowbit_v121/board.c1
37 files changed, 366 insertions, 22 deletions
diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c
index 0b44bd4bb..9a1db9ca9 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/board.c
+++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c
@@ -97,6 +97,7 @@ void board_init(void) {
false, // Pixels in a byte share a row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c
index 5dbdd499a..3e4a04ae2 100644
--- a/ports/atmel-samd/boards/hallowing_m4_express/board.c
+++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c
@@ -77,6 +77,7 @@ void board_init(void) {
false, // Pixels in a byte share a row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
index 5429bcf86..f7223790a 100644
--- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
@@ -11,8 +11,10 @@ LONGINT_IMPL = MPZ
# Not needed.
CIRCUITPY_AUDIOBUSIO = 0
+CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_NETWORK = 0
+CIRCUITPY_PROTOMATTER = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_AUDIOMP3 = 0
diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c
index 684639c30..55d6f80c9 100644
--- a/ports/atmel-samd/boards/monster_m4sk/board.c
+++ b/ports/atmel-samd/boards/monster_m4sk/board.c
@@ -78,6 +78,7 @@ void board_init(void) {
false, // pixels in a byte share a row. Only valid for depths < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c
index 0f8936696..cf8439cf0 100644
--- a/ports/atmel-samd/boards/pewpew_m4/board.c
+++ b/ports/atmel-samd/boards/pewpew_m4/board.c
@@ -128,6 +128,7 @@ void board_init(void) {
false, // pixels in byte share row. only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c
index 257d72e30..ffddf0397 100644
--- a/ports/atmel-samd/boards/pybadge/board.c
+++ b/ports/atmel-samd/boards/pybadge/board.c
@@ -100,6 +100,7 @@ void board_init(void) {
false, // pixels in byte share row. only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c
index 7df245a72..8274d0ebe 100644
--- a/ports/atmel-samd/boards/pybadge_airlift/board.c
+++ b/ports/atmel-samd/boards/pybadge_airlift/board.c
@@ -78,6 +78,7 @@ void board_init(void) {
false, // pixels in byte share row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk
index adbb4aedb..c14a29615 100644
--- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk
@@ -15,10 +15,12 @@ LONGINT_IMPL = MPZ
# Not needed.
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_DISPLAYIO = 0
+CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_GAMEPAD = 0
+CIRCUITPY_PROTOMATTER = 0
CIRCUITPY_PS2IO = 0
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
-FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD \ No newline at end of file
+FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD
diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c
index 7c3ca6e33..c7f2f6e1d 100644
--- a/ports/atmel-samd/boards/pygamer/board.c
+++ b/ports/atmel-samd/boards/pygamer/board.c
@@ -100,6 +100,7 @@ void board_init(void) {
false, // pixels in a byte share a row. Only valid for depths < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c
index 7fd3ebc5e..6053fedb0 100644
--- a/ports/atmel-samd/boards/pygamer_advance/board.c
+++ b/ports/atmel-samd/boards/pygamer_advance/board.c
@@ -78,6 +78,7 @@ void board_init(void) {
false, // pixels in a byte share a row. Only valid for depths < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c
index a86f0ee48..ed3006e3c 100644
--- a/ports/atmel-samd/boards/pyportal/board.c
+++ b/ports/atmel-samd/boards/pyportal/board.c
@@ -87,6 +87,7 @@ void board_init(void) {
false, // pixels_in_byte_share_row (unused for depths > 8)
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/pyportal_titano/board.c b/ports/atmel-samd/boards/pyportal_titano/board.c
index a9ded1760..e7763b6e5 100644
--- a/ports/atmel-samd/boards/pyportal_titano/board.c
+++ b/ports/atmel-samd/boards/pyportal_titano/board.c
@@ -104,6 +104,7 @@ void board_init(void) {
false, // pixels_in_byte_share_row (unused for depths > 8)
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
index fd4f22230..57eb7f1b9 100644
--- a/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/robohatmm1_m4/mpconfigboard.mk
@@ -17,7 +17,9 @@ LONGINT_IMPL = MPZ
CIRCUITPY_AUDIOBUSIO = 0
# Make room for more stuff
CIRCUITPY_DISPLAYIO = 0
+CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_FREQUENCYIO = 0
+CIRCUITPY_PROTOMATTER = 0
# Include these Python libraries in firmware.
#FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c
index 07814d558..38661950f 100644
--- a/ports/atmel-samd/boards/ugame10/board.c
+++ b/ports/atmel-samd/boards/ugame10/board.c
@@ -97,6 +97,7 @@ void board_init(void) {
false, // pixels in byte share row. Only used with depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
index d91369f75..691c1c136 100644
--- a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
@@ -18,6 +18,7 @@ CIRCUITPY_AUDIOIO = 1
# Disable modules that are unusable on this special-purpose board.
CIRCUITPY_BITBANGIO = 0
+CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_AUDIOBUSIO = 0
@@ -27,6 +28,7 @@ CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
+CIRCUITPY_PROTOMATTER = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_USB_HID = 0
CIRCUITPY_RTC = 0
diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
index 166eaad3f..ed97aef4c 100644
--- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
@@ -21,10 +21,12 @@ CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_BLEIO = 0
CIRCUITPY_DISPLAYIO = 0
+CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
+CIRCUITPY_PROTOMATTER = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_USB_HID = 0
diff --git a/ports/atmel-samd/common-hal/_protomatter/Protomatter.c b/ports/atmel-samd/common-hal/_protomatter/Protomatter.c
new file mode 100644
index 000000000..bf9cafb6b
--- /dev/null
+++ b/ports/atmel-samd/common-hal/_protomatter/Protomatter.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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 <stddef.h>
+
+#include "common-hal/_protomatter/Protomatter.h"
+
+#include "samd/timers.h"
+#include "timer_handler.h"
+
+void *common_hal_protomatter_timer_allocate() {
+ uint8_t timer_index = find_free_timer();
+ if (timer_index == 0xff) {
+ return NULL;
+ }
+ timer_never_reset(timer_index, true);
+ return tc_insts[timer_index];
+}
+
+static uint8_t tc_index_from_ptr(void* ptr) {
+ for (uint8_t i = TC_INST_NUM; i > 0; i--) {
+ if (tc_insts[i] == ptr) {
+ return i;
+ }
+ }
+ return 0xff;
+}
+
+void common_hal_protomatter_timer_enable(void* ptr) {
+ uint8_t timer_index = tc_index_from_ptr(ptr);
+ if (timer_index == 0xff) {
+ return;
+ }
+ set_timer_handler(true, timer_index, TC_HANDLER_PROTOMATTER);
+ turn_on_clocks(true, timer_index, 1);
+}
+
+void common_hal_protomatter_timer_disable(void* ptr) {
+ uint8_t timer_index = tc_index_from_ptr(ptr);
+ if (timer_index == 0xff) {
+ return;
+ }
+ set_timer_handler(true, timer_index, TC_HANDLER_NO_INTERRUPT);
+ tc_set_enable(ptr, false);
+}
+
+void common_hal_protomatter_timer_free(void* ptr) {
+ uint8_t timer_index = tc_index_from_ptr(ptr);
+ if (timer_index == 0xff) {
+ return;
+ }
+ tc_set_enable(ptr, false);
+ tc_reset(ptr);
+ timer_reset_ok(timer_index, true);
+}
diff --git a/ports/atmel-samd/common-hal/_protomatter/Protomatter.h b/ports/atmel-samd/common-hal/_protomatter/Protomatter.h
new file mode 100644
index 000000000..8185bed0e
--- /dev/null
+++ b/ports/atmel-samd/common-hal/_protomatter/Protomatter.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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_ATMEL_SAMD_COMMON_HAL_PROTOMATTER_PROTOMATTER_H
+#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PROTOMATTER_PROTOMATTER_H
+
+void *common_hal_protomatter_timer_allocate(void);
+void common_hal_protomatter_timer_enable(void*);
+void common_hal_protomatter_timer_disable(void*);
+void common_hal_protomatter_timer_free(void*);
+
+#endif
diff --git a/ports/atmel-samd/common-hal/_protomatter/__init__.c b/ports/atmel-samd/common-hal/_protomatter/__init__.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/atmel-samd/common-hal/_protomatter/__init__.c
diff --git a/ports/atmel-samd/common-hal/microcontroller/Pin.c b/ports/atmel-samd/common-hal/microcontroller/Pin.c
index 9719ea5b1..cf78673b2 100644
--- a/ports/atmel-samd/common-hal/microcontroller/Pin.c
+++ b/ports/atmel-samd/common-hal/microcontroller/Pin.c
@@ -240,3 +240,15 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) {
return pin_number_is_free(pin->number);
}
+
+uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin) {
+ return pin->number;
+}
+
+void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
+ return claim_pin(pin);
+}
+
+void common_hal_mcu_pin_reset_number(uint8_t pin_no) {
+ reset_pin_number(pin_no);
+}
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
index fef581584..1da0da844 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
@@ -61,22 +61,31 @@ uint8_t tcc_channels[5]; // Set by pwmout_reset() to {0xc0, 0xf0, 0xf8, 0xfc,
static uint8_t never_reset_tc_or_tcc[TC_INST_NUM + TCC_INST_NUM];
-void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
- if (self->timer->is_tc) {
- never_reset_tc_or_tcc[self->timer->index] += 1;
+STATIC void timer_refcount(int index, bool is_tc, int increment) {
+ if (is_tc) {
+ never_reset_tc_or_tcc[index] += increment;
} else {
- never_reset_tc_or_tcc[TC_INST_NUM + self->timer->index] += 1;
+ never_reset_tc_or_tcc[TC_INST_NUM + index] += increment;
}
+}
+
+void timer_never_reset(int index, bool is_tc) {
+ timer_refcount(index, is_tc, 1);
+}
+
+void timer_reset_ok(int index, bool is_tc) {
+ timer_refcount(index, is_tc, -1);
+}
+
+
+void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+ timer_never_reset(self->timer->index, self->timer->is_tc);
never_reset_pin_number(self->pin->number);
}
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
- if (self->timer->is_tc) {
- never_reset_tc_or_tcc[self->timer->index] -= 1;
- } else {
- never_reset_tc_or_tcc[TC_INST_NUM + self->timer->index] -= 1;
- }
+ timer_reset_ok(self->timer->index, self->timer->is_tc);
}
void pwmout_reset(void) {
diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk
index c2408feae..61f7c206a 100644
--- a/ports/atmel-samd/mpconfigport.mk
+++ b/ports/atmel-samd/mpconfigport.mk
@@ -70,6 +70,18 @@ CIRCUITPY_ULAB = 1
endif
endif
+ifndef CIRCUITPY_PROTOMATTER
+ifneq ($(CIRCUITPY_SMALL_BUILD),1)
+CIRCUITPY_PROTOMATTER = 1
+endif
+endif
+
+ifndef CIRCUITPY_FRAMEBUFFERIO
+ifneq ($(CIRCUITPY_SMALL_BUILD),1)
+CIRCUITPY_FRAMEBUFFERIO = 1
+endif
+endif
+
endif # samd51
INTERNAL_LIBM = 1
diff --git a/ports/atmel-samd/timer_handler.c b/ports/atmel-samd/timer_handler.c
index 5d6de3093..598fad564 100644
--- a/ports/atmel-samd/timer_handler.c
+++ b/ports/atmel-samd/timer_handler.c
@@ -33,6 +33,8 @@
#include "shared-module/_pew/PewPew.h"
#include "common-hal/frequencyio/FrequencyIn.h"
+extern void _PM_IRQ_HANDLER(void);
+
static uint8_t tc_handler[TC_INST_NUM];
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler) {
@@ -62,6 +64,11 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
frequencyin_interrupt_handler(index);
#endif
break;
+ case TC_HANDLER_PROTOMATTER:
+ #if CIRCUITPY_PROTOMATTER
+ _PM_IRQ_HANDLER();
+ #endif
+ break;
default:
break;
}
diff --git a/ports/atmel-samd/timer_handler.h b/ports/atmel-samd/timer_handler.h
index 4a7adb58c..646cd54ec 100644
--- a/ports/atmel-samd/timer_handler.h
+++ b/ports/atmel-samd/timer_handler.h
@@ -30,8 +30,13 @@
#define TC_HANDLER_PULSEOUT 0x1
#define TC_HANDLER_PEW 0x2
#define TC_HANDLER_FREQUENCYIN 0x3
+#define TC_HANDLER_PROTOMATTER 0x4
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
void shared_timer_handler(bool is_tc, uint8_t index);
+// implementation of these functions is in PWMOut.c
+void timer_never_reset(int index, bool is_tc);
+void timer_reset_ok(int index, bool is_tc);
+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_TIMER_HANDLER_H
diff --git a/ports/cxd56/boards/spresense/mpconfigboard.h b/ports/cxd56/boards/spresense/mpconfigboard.h
index 0245e2045..c53f6b418 100644
--- a/ports/cxd56/boards/spresense/mpconfigboard.h
+++ b/ports/cxd56/boards/spresense/mpconfigboard.h
@@ -36,3 +36,6 @@
#define DEFAULT_UART_BUS_RX (&pin_UART2_RXD)
#define DEFAULT_UART_BUS_TX (&pin_UART2_TXD)
+
+#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
+
diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h
index 745c12f7d..7e7df0123 100644
--- a/ports/mimxrt10xx/mpconfigport.h
+++ b/ports/mimxrt10xx/mpconfigport.h
@@ -44,7 +44,7 @@ extern uint8_t _ld_default_stack_size;
#define MICROPY_PY_FUNCTION_ATTRS (0)
#define MICROPY_PY_IO (1)
#define MICROPY_PY_UJSON (1)
-#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
+#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR ((uint32_t) &_ld_filesystem_start)
diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c
index e9f8d244e..2370a0aa1 100644
--- a/ports/nrf/boards/clue_nrf52840_express/board.c
+++ b/ports/nrf/boards/clue_nrf52840_express/board.c
@@ -77,6 +77,7 @@ void board_init(void) {
false, // Pixels in a byte share a row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c
index 88c68bcb8..bbb20cc6e 100644
--- a/ports/nrf/boards/ohs2020_badge/board.c
+++ b/ports/nrf/boards/ohs2020_badge/board.c
@@ -77,6 +77,7 @@ void board_init(void) {
false, // Pixels in a byte share a row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
diff --git a/ports/nrf/common-hal/_protomatter/Protomatter.c b/ports/nrf/common-hal/_protomatter/Protomatter.c
new file mode 100644
index 000000000..b6e55bbd4
--- /dev/null
+++ b/ports/nrf/common-hal/_protomatter/Protomatter.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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 <stddef.h>
+
+#include "common-hal/_protomatter/Protomatter.h"
+
+#include "peripherals/nrf/timers.h"
+
+extern void _PM_IRQ_HANDLER(void);
+
+void *common_hal_protomatter_timer_allocate() {
+ nrfx_timer_t *timer = nrf_peripherals_allocate_timer_or_throw();
+ nrf_peripherals_timer_never_reset(timer);
+ return timer->p_reg;
+}
+
+
+static void protomatter_event_handler(nrf_timer_event_t event_type, void *p_context) {
+ _PM_IRQ_HANDLER();
+}
+
+void common_hal_protomatter_timer_enable(void* ptr) {
+ nrfx_timer_t *timer = nrf_peripherals_timer_from_reg(ptr);
+ static const nrfx_timer_config_t timer_config = {
+ .frequency = NRF_TIMER_FREQ_16MHz,
+ .mode = NRF_TIMER_MODE_TIMER,
+ .bit_width = NRF_TIMER_BIT_WIDTH_16,
+ .interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY,
+ .p_context = NULL,
+ };
+ nrfx_timer_init(timer, &timer_config, &protomatter_event_handler);
+}
+
+void common_hal_protomatter_timer_disable(void* ptr) {
+ nrfx_timer_t *timer = nrf_peripherals_timer_from_reg(ptr);
+ nrfx_timer_uninit(timer);
+}
+
+void common_hal_protomatter_timer_free(void* ptr) {
+ nrfx_timer_t *timer = nrf_peripherals_timer_from_reg(ptr);
+ nrf_peripherals_free_timer(timer);
+}
diff --git a/ports/nrf/common-hal/_protomatter/Protomatter.h b/ports/nrf/common-hal/_protomatter/Protomatter.h
new file mode 100644
index 000000000..8185bed0e
--- /dev/null
+++ b/ports/nrf/common-hal/_protomatter/Protomatter.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler 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_ATMEL_SAMD_COMMON_HAL_PROTOMATTER_PROTOMATTER_H
+#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PROTOMATTER_PROTOMATTER_H
+
+void *common_hal_protomatter_timer_allocate(void);
+void common_hal_protomatter_timer_enable(void*);
+void common_hal_protomatter_timer_disable(void*);
+void common_hal_protomatter_timer_free(void*);
+
+#endif
diff --git a/ports/nrf/common-hal/_protomatter/__init__.c b/ports/nrf/common-hal/_protomatter/__init__.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/nrf/common-hal/_protomatter/__init__.c
diff --git a/ports/nrf/common-hal/microcontroller/Pin.c b/ports/nrf/common-hal/microcontroller/Pin.c
index b7931a2e1..3132c7631 100644
--- a/ports/nrf/common-hal/microcontroller/Pin.c
+++ b/ports/nrf/common-hal/microcontroller/Pin.c
@@ -196,3 +196,15 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
return pin_number_is_free(pin->number);
}
+
+uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin) {
+ return pin->number;
+}
+
+void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
+ claim_pin(pin);
+}
+
+void common_hal_mcu_pin_reset_number(uint8_t pin_no) {
+ reset_pin_number(pin_no);
+}
diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c
index d0433247a..270cb45d6 100644
--- a/ports/nrf/common-hal/pulseio/PulseOut.c
+++ b/ports/nrf/common-hal/pulseio/PulseOut.c
@@ -102,10 +102,7 @@ void pulseout_reset() {
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
const pulseio_pwmout_obj_t* carrier) {
if (refcount == 0) {
- timer = nrf_peripherals_allocate_timer();
- if (timer == NULL) {
- mp_raise_RuntimeError(translate("All timers in use"));
- }
+ timer = nrf_peripherals_allocate_timer_or_throw();
}
refcount++;
diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk
index fcc59c484..5ca1f0f35 100644
--- a/ports/nrf/mpconfigport.mk
+++ b/ports/nrf/mpconfigport.mk
@@ -51,6 +51,9 @@ endif
# frequencyio not yet implemented
CIRCUITPY_FREQUENCYIO = 0
+CIRCUITPY_PROTOMATTER = 1
+CIRCUITPY_FRAMEBUFFERIO = 1
+
# nRF52840-specific
ifeq ($(MCU_CHIP),nrf52840)
diff --git a/ports/nrf/peripherals/nrf/timers.c b/ports/nrf/peripherals/nrf/timers.c
index 88f3dd468..fd814968d 100644
--- a/ports/nrf/peripherals/nrf/timers.c
+++ b/ports/nrf/peripherals/nrf/timers.c
@@ -25,6 +25,7 @@
*/
#include "common-hal/pulseio/PulseOut.h"
+#include "peripherals/nrf/timers.h"
#include <stdint.h>
@@ -54,14 +55,47 @@ STATIC nrfx_timer_t nrfx_timers[] = {
};
static bool nrfx_timer_allocated[ARRAY_SIZE(nrfx_timers)];
+static bool nrfx_timer_never_reset[ARRAY_SIZE(nrfx_timers)];
void timers_reset(void) {
for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) {
+ if (nrfx_timer_never_reset[i]) {
+ continue;
+ }
nrfx_timer_uninit(&nrfx_timers[i]);
nrfx_timer_allocated[i] = false;
}
}
+void nrf_peripherals_timer_never_reset(nrfx_timer_t* timer) {
+ int idx = nrf_peripherals_timer_idx_from_timer(timer);
+ nrfx_timer_never_reset[idx] = true;
+}
+
+void nrf_peripherals_timer_reset_ok(nrfx_timer_t* timer) {
+ int idx = nrf_peripherals_timer_idx_from_timer(timer);
+ nrfx_timer_never_reset[idx] = false;
+}
+
+nrfx_timer_t* nrf_peripherals_timer_from_reg(NRF_TIMER_Type* ptr) {
+ for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) {
+ if (nrfx_timers[i].p_reg == ptr) {
+ return &nrfx_timers[i];
+ }
+ }
+ return NULL;
+}
+
+size_t nrf_peripherals_timer_idx_from_timer(nrfx_timer_t* ptr) {
+ for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) {
+ if (&nrfx_timers[i] == ptr) {
+ return i;
+ }
+ }
+ return ~(size_t)0;
+}
+
+
// Returns a free nrfx_timer instance, and marks it as allocated.
// The caller should init as with the desired config.
// Returns NULL if no timer is available.
@@ -75,14 +109,21 @@ nrfx_timer_t* nrf_peripherals_allocate_timer(void) {
return NULL;
}
+nrfx_timer_t* nrf_peripherals_allocate_timer_or_throw(void) {
+ nrfx_timer_t* result = nrf_peripherals_allocate_timer();
+ if (!result) {
+ mp_raise_RuntimeError(translate("All timers in use"));
+ }
+ return result;
+}
+
// Free a timer, which may or may not have been initialized.
void nrf_peripherals_free_timer(nrfx_timer_t* timer) {
- for (size_t i = 0; i < ARRAY_SIZE(nrfx_timers); i ++) {
- if (timer == &nrfx_timers[i]) {
- nrfx_timer_allocated[i] = false;
- // Safe to call even if not initialized.
- nrfx_timer_uninit(timer);
- return;
- }
+ size_t idx = nrf_peripherals_timer_idx_from_timer(timer);
+ if (idx != ~(size_t)0) {
+ nrfx_timer_allocated[idx] = false;
+ nrfx_timer_never_reset[idx] = false;
+ // Safe to call even if not initialized.
+ nrfx_timer_uninit(timer);
}
}
diff --git a/ports/nrf/peripherals/nrf/timers.h b/ports/nrf/peripherals/nrf/timers.h
index 7d3815579..cf96c6273 100644
--- a/ports/nrf/peripherals/nrf/timers.h
+++ b/ports/nrf/peripherals/nrf/timers.h
@@ -29,4 +29,9 @@
void timers_reset(void);
nrfx_timer_t* nrf_peripherals_allocate_timer(void);
+nrfx_timer_t* nrf_peripherals_allocate_timer_or_throw(void);
void nrf_peripherals_free_timer(nrfx_timer_t* timer);
+void nrf_peripherals_timer_never_reset(nrfx_timer_t* timer);
+void nrf_peripherals_timer_reset_ok(nrfx_timer_t* timer);
+nrfx_timer_t* nrf_peripherals_timer_from_reg(NRF_TIMER_Type* ptr);
+size_t nrf_peripherals_timer_idx_from_timer(nrfx_timer_t* ptr);
diff --git a/ports/stm/boards/meowbit_v121/board.c b/ports/stm/boards/meowbit_v121/board.c
index 9e2d99bce..68eed2926 100644
--- a/ports/stm/boards/meowbit_v121/board.c
+++ b/ports/stm/boards/meowbit_v121/board.c
@@ -98,6 +98,7 @@ void board_init(void) {
false, // Pixels in a byte share a row. Only used for depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command