kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Merge pull request #1024 from pimoroni/ci/micropython-1.24.0
Bump to MicroPython v1.24.0pull/1025/head
commit
12b4e79cb6
|
@ -7,7 +7,8 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
MICROPYTHON_VERSION: v1.23.0
|
MICROPYTHON_VERSION: v1.24.0
|
||||||
|
MICROPYTHON_FLAVOUR: micropython
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -13,11 +13,9 @@ function log_warning {
|
||||||
}
|
}
|
||||||
|
|
||||||
function micropython_clone {
|
function micropython_clone {
|
||||||
log_inform "Using MicroPython $MICROPYTHON_VERSION"
|
log_inform "Using MicroPython $MICROPYTHON_FLAVOUR/$MICROPYTHON_VERSION"
|
||||||
git clone https://github.com/micropython/micropython
|
git clone https://github.com/$MICROPYTHON_FLAVOUR/micropython -b $MICROPYTHON_VERSION --depth=1
|
||||||
cd micropython
|
cd micropython
|
||||||
git checkout $MICROPYTHON_VERSION
|
|
||||||
git cherry-pick -n 932f76c6ba64c5a3e68de3324556d9979f09303b
|
|
||||||
git submodule update --init lib/pico-sdk
|
git submodule update --init lib/pico-sdk
|
||||||
git submodule update --init lib/cyw43-driver
|
git submodule update --init lib/cyw43-driver
|
||||||
git submodule update --init lib/lwip
|
git submodule update --init lib/lwip
|
||||||
|
|
|
@ -58,9 +58,10 @@ namespace pimoroni {
|
||||||
cs(pins.cs), dc(pins.dc), wr_sck(pins.wr_sck), rd_sck(pins.rd_sck), d0(pins.d0), bl(pins.bl) {
|
cs(pins.cs), dc(pins.dc), wr_sck(pins.wr_sck), rd_sck(pins.rd_sck), d0(pins.d0), bl(pins.bl) {
|
||||||
|
|
||||||
parallel_pio = pio1;
|
parallel_pio = pio1;
|
||||||
|
pio_set_gpio_base(parallel_pio, d0 + 8 >= 32 ? 16 : 0);
|
||||||
parallel_sm = pio_claim_unused_sm(parallel_pio, true);
|
parallel_sm = pio_claim_unused_sm(parallel_pio, true);
|
||||||
parallel_offset = pio_add_program(parallel_pio, &st7789_parallel_program);
|
parallel_offset = pio_add_program(parallel_pio, &st7789_parallel_program);
|
||||||
|
|
||||||
//gpio_init(wr_sck);
|
//gpio_init(wr_sck);
|
||||||
//gpio_set_dir(wr_sck, GPIO_OUT);
|
//gpio_set_dir(wr_sck, GPIO_OUT);
|
||||||
//gpio_set_function(wr_sck, GPIO_FUNC_SIO);
|
//gpio_set_function(wr_sck, GPIO_FUNC_SIO);
|
||||||
|
|
|
@ -1,136 +0,0 @@
|
||||||
diff --git a/src/rp2_common/pico_runtime/runtime.c b/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
index 144ace1..52bb6c9 100644
|
|
||||||
--- a/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
+++ b/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
@@ -20,6 +20,7 @@
|
|
||||||
#include "hardware/clocks.h"
|
|
||||||
#include "hardware/irq.h"
|
|
||||||
#include "hardware/resets.h"
|
|
||||||
+#include "hardware/gpio.h"
|
|
||||||
|
|
||||||
#include "pico/mutex.h"
|
|
||||||
#include "pico/time.h"
|
|
||||||
@@ -35,6 +36,21 @@
|
|
||||||
#include "pico/bootrom.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+// Pins to toggle on wakeup
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_MASK
|
|
||||||
+#define PICO_WAKEUP_PIN_MASK ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+// Direction
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_DIR
|
|
||||||
+#define PICO_WAKEUP_PIN_DIR ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+// Value
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_VALUE
|
|
||||||
+#define PICO_WAKEUP_PIN_VALUE ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
extern char __StackLimit; /* Set by linker. */
|
|
||||||
|
|
||||||
uint32_t __attribute__((section(".ram_vector_table"))) ram_vector_table[48];
|
|
||||||
@@ -64,7 +80,13 @@ void runtime_install_stack_guard(void *stack_bottom) {
|
|
||||||
| 0x10000000; // XN = disable instruction fetch; no other bits means no permissions
|
|
||||||
}
|
|
||||||
|
|
||||||
-void runtime_init(void) {
|
|
||||||
+void runtime_user_init(void) {
|
|
||||||
+ gpio_init_mask(PICO_WAKEUP_PIN_MASK);
|
|
||||||
+ gpio_set_dir_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_DIR);
|
|
||||||
+ gpio_put_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_VALUE);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void runtime_reset_peripherals(void) {
|
|
||||||
// Reset all peripherals to put system into a known state,
|
|
||||||
// - except for QSPI pads and the XIP IO bank, as this is fatal if running from flash
|
|
||||||
// - and the PLLs, as this is fatal if clock muxing has not been reset on this boot
|
|
||||||
@@ -89,7 +111,9 @@ void runtime_init(void) {
|
|
||||||
RESETS_RESET_UART1_BITS |
|
|
||||||
RESETS_RESET_USBCTRL_BITS
|
|
||||||
));
|
|
||||||
+}
|
|
||||||
|
|
||||||
+void runtime_init(void) {
|
|
||||||
// pre-init runs really early since we need it even for memcpy and divide!
|
|
||||||
// (basically anything in aeabi that uses bootrom)
|
|
||||||
|
|
||||||
diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
index 7d29f76..799ce19 100644
|
|
||||||
--- a/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
+++ b/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
@@ -11,6 +11,8 @@
|
|
||||||
#include "hardware/regs/addressmap.h"
|
|
||||||
#include "hardware/regs/sio.h"
|
|
||||||
#include "pico/binary_info/defs.h"
|
|
||||||
+#include "hardware/regs/resets.h"
|
|
||||||
+#include "hardware/regs/rosc.h"
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#ifndef COLLAPSE_IRQS
|
|
||||||
@@ -225,6 +227,23 @@ _reset_handler:
|
|
||||||
cmp r0, #0
|
|
||||||
bne hold_non_core0_in_bootrom
|
|
||||||
|
|
||||||
+ // Increase ROSC frequency to ~48MHz (range 14.4 - 96)
|
|
||||||
+ // Startup drops from ~160ms to ~32ms on Pico W MicroPython
|
|
||||||
+ ldr r0, =(ROSC_BASE + ROSC_DIV_OFFSET)
|
|
||||||
+ ldr r1, =0xaa2
|
|
||||||
+ str r1, [r0]
|
|
||||||
+
|
|
||||||
+ ldr r1, =runtime_reset_peripherals
|
|
||||||
+ blx r1
|
|
||||||
+
|
|
||||||
+ ldr r1, =runtime_user_init
|
|
||||||
+ blx r1
|
|
||||||
+
|
|
||||||
+ // Read GPIO state for front buttons and store
|
|
||||||
+ movs r3, 0xd0 // Load 0xd0 into r3
|
|
||||||
+ lsls r3, r3, 24 // Shift left 24 to get 0xd0000000
|
|
||||||
+ ldr r6, [r3, 4] // Load GPIO state (0xd0000004) into r6
|
|
||||||
+
|
|
||||||
// In a NO_FLASH binary, don't perform .data copy, since it's loaded
|
|
||||||
// in-place by the SRAM load. Still need to clear .bss
|
|
||||||
#if !PICO_NO_FLASH
|
|
||||||
@@ -251,6 +270,10 @@ bss_fill_test:
|
|
||||||
cmp r1, r2
|
|
||||||
bne bss_fill_loop
|
|
||||||
|
|
||||||
+ // runtime_wakeup_gpio_state gets zero init above
|
|
||||||
+ ldr r2, =runtime_wakeup_gpio_state // Load output var addr into r2
|
|
||||||
+ str r6, [r2] // Store r6 to r2
|
|
||||||
+
|
|
||||||
platform_entry: // symbol for stack traces
|
|
||||||
// Use 32-bit jumps, in case these symbols are moved out of branch range
|
|
||||||
// (e.g. if main is in SRAM and crt0 in flash)
|
|
||||||
@@ -310,6 +333,18 @@ data_cpy_table:
|
|
||||||
runtime_init:
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
+.weak runtime_user_init
|
|
||||||
+.type runtime_user_init,%function
|
|
||||||
+.thumb_func
|
|
||||||
+runtime_user_init:
|
|
||||||
+ bx lr
|
|
||||||
+
|
|
||||||
+.weak runtime_reset_peripherals
|
|
||||||
+.type runtime_reset_peripherals,%function
|
|
||||||
+.thumb_func
|
|
||||||
+runtime_reset_peripherals:
|
|
||||||
+ bx lr
|
|
||||||
+
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// If core 1 somehow gets into crt0 due to a spectacular VTOR mishap, we need to
|
|
||||||
// catch it and send back to the sleep-and-launch code in the bootrom. Shouldn't
|
|
||||||
@@ -350,3 +385,9 @@ spacer_section .heap
|
|
||||||
.p2align 2
|
|
||||||
.equ HeapSize, PICO_HEAP_SIZE
|
|
||||||
.space HeapSize
|
|
||||||
+
|
|
||||||
+.section .data._reset_handler
|
|
||||||
+.global runtime_wakeup_gpio_state
|
|
||||||
+.align 4
|
|
||||||
+runtime_wakeup_gpio_state:
|
|
||||||
+.word 0x00000000
|
|
|
@ -1,136 +0,0 @@
|
||||||
diff --git a/src/rp2_common/pico_runtime/runtime.c b/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
index 144ace1..52bb6c9 100644
|
|
||||||
--- a/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
+++ b/src/rp2_common/pico_runtime/runtime.c
|
|
||||||
@@ -20,6 +20,7 @@
|
|
||||||
#include "hardware/clocks.h"
|
|
||||||
#include "hardware/irq.h"
|
|
||||||
#include "hardware/resets.h"
|
|
||||||
+#include "hardware/gpio.h"
|
|
||||||
|
|
||||||
#include "pico/mutex.h"
|
|
||||||
#include "pico/time.h"
|
|
||||||
@@ -35,6 +36,21 @@
|
|
||||||
#include "pico/bootrom.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+// Pins to toggle on wakeup
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_MASK
|
|
||||||
+#define PICO_WAKEUP_PIN_MASK ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+// Direction
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_DIR
|
|
||||||
+#define PICO_WAKEUP_PIN_DIR ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+// Value
|
|
||||||
+#ifndef PICO_WAKEUP_PIN_VALUE
|
|
||||||
+#define PICO_WAKEUP_PIN_VALUE ((0b1 << 2) | (0b1 << 6))
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
extern char __StackLimit; /* Set by linker. */
|
|
||||||
|
|
||||||
uint32_t __attribute__((section(".ram_vector_table"))) ram_vector_table[48];
|
|
||||||
@@ -64,7 +80,13 @@ void runtime_install_stack_guard(void *stack_bottom) {
|
|
||||||
| 0x10000000; // XN = disable instruction fetch; no other bits means no permissions
|
|
||||||
}
|
|
||||||
|
|
||||||
-void runtime_init(void) {
|
|
||||||
+void runtime_user_init(void) {
|
|
||||||
+ gpio_init_mask(PICO_WAKEUP_PIN_MASK);
|
|
||||||
+ gpio_set_dir_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_DIR);
|
|
||||||
+ gpio_put_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_VALUE);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void runtime_reset_peripherals(void) {
|
|
||||||
// Reset all peripherals to put system into a known state,
|
|
||||||
// - except for QSPI pads and the XIP IO bank, as this is fatal if running from flash
|
|
||||||
// - and the PLLs, as this is fatal if clock muxing has not been reset on this boot
|
|
||||||
@@ -89,7 +111,9 @@ void runtime_init(void) {
|
|
||||||
RESETS_RESET_UART1_BITS |
|
|
||||||
RESETS_RESET_USBCTRL_BITS
|
|
||||||
));
|
|
||||||
+}
|
|
||||||
|
|
||||||
+void runtime_init(void) {
|
|
||||||
// pre-init runs really early since we need it even for memcpy and divide!
|
|
||||||
// (basically anything in aeabi that uses bootrom)
|
|
||||||
|
|
||||||
diff --git a/src/rp2_common/pico_standard_link/crt0.S b/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
index 7d29f76..799ce19 100644
|
|
||||||
--- a/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
+++ b/src/rp2_common/pico_standard_link/crt0.S
|
|
||||||
@@ -11,6 +11,8 @@
|
|
||||||
#include "hardware/regs/addressmap.h"
|
|
||||||
#include "hardware/regs/sio.h"
|
|
||||||
#include "pico/binary_info/defs.h"
|
|
||||||
+#include "hardware/regs/resets.h"
|
|
||||||
+#include "hardware/regs/rosc.h"
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#ifndef COLLAPSE_IRQS
|
|
||||||
@@ -225,6 +227,23 @@ _reset_handler:
|
|
||||||
cmp r0, #0
|
|
||||||
bne hold_non_core0_in_bootrom
|
|
||||||
|
|
||||||
+ // Increase ROSC frequency to ~48MHz (range 14.4 - 96)
|
|
||||||
+ // Startup drops from ~160ms to ~32ms on Pico W MicroPython
|
|
||||||
+ ldr r0, =(ROSC_BASE + ROSC_DIV_OFFSET)
|
|
||||||
+ ldr r1, =0xaa2
|
|
||||||
+ str r1, [r0]
|
|
||||||
+
|
|
||||||
+ ldr r1, =runtime_reset_peripherals
|
|
||||||
+ blx r1
|
|
||||||
+
|
|
||||||
+ ldr r1, =runtime_user_init
|
|
||||||
+ blx r1
|
|
||||||
+
|
|
||||||
+ // Read GPIO state for front buttons and store
|
|
||||||
+ movs r3, 0xd0 // Load 0xd0 into r3
|
|
||||||
+ lsls r3, r3, 24 // Shift left 24 to get 0xd0000000
|
|
||||||
+ ldr r6, [r3, 4] // Load GPIO state (0xd0000004) into r6
|
|
||||||
+
|
|
||||||
// In a NO_FLASH binary, don't perform .data copy, since it's loaded
|
|
||||||
// in-place by the SRAM load. Still need to clear .bss
|
|
||||||
#if !PICO_NO_FLASH
|
|
||||||
@@ -251,6 +270,10 @@ bss_fill_test:
|
|
||||||
cmp r1, r2
|
|
||||||
bne bss_fill_loop
|
|
||||||
|
|
||||||
+ // runtime_wakeup_gpio_state gets zero init above
|
|
||||||
+ ldr r2, =runtime_wakeup_gpio_state // Load output var addr into r2
|
|
||||||
+ str r6, [r2] // Store r6 to r2
|
|
||||||
+
|
|
||||||
platform_entry: // symbol for stack traces
|
|
||||||
// Use 32-bit jumps, in case these symbols are moved out of branch range
|
|
||||||
// (e.g. if main is in SRAM and crt0 in flash)
|
|
||||||
@@ -310,6 +333,18 @@ data_cpy_table:
|
|
||||||
runtime_init:
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
+.weak runtime_user_init
|
|
||||||
+.type runtime_user_init,%function
|
|
||||||
+.thumb_func
|
|
||||||
+runtime_user_init:
|
|
||||||
+ bx lr
|
|
||||||
+
|
|
||||||
+.weak runtime_reset_peripherals
|
|
||||||
+.type runtime_reset_peripherals,%function
|
|
||||||
+.thumb_func
|
|
||||||
+runtime_reset_peripherals:
|
|
||||||
+ bx lr
|
|
||||||
+
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// If core 1 somehow gets into crt0 due to a spectacular VTOR mishap, we need to
|
|
||||||
// catch it and send back to the sleep-and-launch code in the bootrom. Shouldn't
|
|
||||||
@@ -350,3 +385,9 @@ spacer_section .heap
|
|
||||||
.p2align 2
|
|
||||||
.equ HeapSize, PICO_HEAP_SIZE
|
|
||||||
.space HeapSize
|
|
||||||
+
|
|
||||||
+.section .data._reset_handler
|
|
||||||
+.global runtime_wakeup_gpio_state
|
|
||||||
+.align 4
|
|
||||||
+runtime_wakeup_gpio_state:
|
|
||||||
+.word 0x00000000
|
|
|
@ -157,6 +157,7 @@ static const mp_map_elem_t picographics_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_UNICORN_PACK), MP_ROM_INT(DISPLAY_UNICORN_PACK) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_UNICORN_PACK), MP_ROM_INT(DISPLAY_UNICORN_PACK) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_SCROLL_PACK), MP_ROM_INT(DISPLAY_SCROLL_PACK) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_SCROLL_PACK), MP_ROM_INT(DISPLAY_SCROLL_PACK) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_PICO_W_EXPLORER), MP_ROM_INT(DISPLAY_PICO_W_EXPLORER) },
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_PICO_W_EXPLORER), MP_ROM_INT(DISPLAY_PICO_W_EXPLORER) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_DISPLAY_EXPLORER), MP_ROM_INT(DISPLAY_EXPLORER) },
|
||||||
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) },
|
{ MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_PEN_P4), MP_ROM_INT(PEN_P4) },
|
{ MP_ROM_QSTR(MP_QSTR_PEN_P4), MP_ROM_INT(PEN_P4) },
|
||||||
|
|
|
@ -44,6 +44,13 @@ typedef struct _ModPicoGraphics_obj_t {
|
||||||
|
|
||||||
bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height, int &rotate, int &pen_type, PicoGraphicsBusType &bus_type) {
|
bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height, int &rotate, int &pen_type, PicoGraphicsBusType &bus_type) {
|
||||||
switch(display) {
|
switch(display) {
|
||||||
|
case DISPLAY_EXPLORER:
|
||||||
|
width = 320;
|
||||||
|
height = 240;
|
||||||
|
bus_type = BUS_PARALLEL;
|
||||||
|
if(rotate == -1) rotate = (int)Rotation::ROTATE_0;
|
||||||
|
if(pen_type == -1) pen_type = PEN_RGB565;
|
||||||
|
break;
|
||||||
case DISPLAY_PICO_DISPLAY:
|
case DISPLAY_PICO_DISPLAY:
|
||||||
width = 240;
|
width = 240;
|
||||||
height = 135;
|
height = 135;
|
||||||
|
@ -335,6 +342,10 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||||
} else if (display == DISPLAY_PICO_W_EXPLORER) {
|
} else if (display == DISPLAY_PICO_W_EXPLORER) {
|
||||||
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, 17, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, SPI_DEFAULT_MISO, 9};
|
spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, 17, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, SPI_DEFAULT_MISO, 9};
|
||||||
}
|
}
|
||||||
|
} else if (bus_type == BUS_PARALLEL) {
|
||||||
|
if (display == DISPLAY_EXPLORER) {
|
||||||
|
parallel_bus = {27, 28, 30, 31, 32, 26};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,7 +360,8 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
||||||
// TODO grab BUSY and RESET from ARG_extra_pins
|
// TODO grab BUSY and RESET from ARG_extra_pins
|
||||||
self->display = m_new_class(Inky73, width, height, (Rotation)rotate, spi_bus);
|
self->display = m_new_class(Inky73, width, height, (Rotation)rotate, spi_bus);
|
||||||
|
|
||||||
} else if (display == DISPLAY_TUFTY_2040) {
|
} else if (display == DISPLAY_TUFTY_2040
|
||||||
|
|| display == DISPLAY_EXPLORER) {
|
||||||
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);
|
self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus);
|
||||||
|
|
||||||
} else if (display == DISPLAY_LCD_160X80) {
|
} else if (display == DISPLAY_LCD_160X80) {
|
||||||
|
|
|
@ -30,7 +30,8 @@ enum PicoGraphicsDisplay {
|
||||||
DISPLAY_STELLAR_UNICORN,
|
DISPLAY_STELLAR_UNICORN,
|
||||||
DISPLAY_UNICORN_PACK,
|
DISPLAY_UNICORN_PACK,
|
||||||
DISPLAY_SCROLL_PACK,
|
DISPLAY_SCROLL_PACK,
|
||||||
DISPLAY_PICO_W_EXPLORER
|
DISPLAY_PICO_W_EXPLORER,
|
||||||
|
DISPLAY_EXPLORER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PicoGraphicsPenType {
|
enum PicoGraphicsPenType {
|
||||||
|
|
|
@ -1,4 +1,25 @@
|
||||||
#include "wakeup.h"
|
#include "wakeup.h"
|
||||||
|
#include "hardware/gpio.h"
|
||||||
|
#include "wakeup.config.hpp"
|
||||||
|
#include "pico/runtime_init.h"
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t runtime_wakeup_gpio_state = 0;
|
||||||
|
|
||||||
|
// Pins to toggle on wakeup
|
||||||
|
#ifndef PICO_WAKEUP_PIN_MASK
|
||||||
|
#define PICO_WAKEUP_PIN_MASK ((0b1 << 2) | (0b1 << 6))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Direction
|
||||||
|
#ifndef PICO_WAKEUP_PIN_DIR
|
||||||
|
#define PICO_WAKEUP_PIN_DIR ((0b1 << 2) | (0b1 << 6))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Value
|
||||||
|
#ifndef PICO_WAKEUP_PIN_VALUE
|
||||||
|
#define PICO_WAKEUP_PIN_VALUE ((0b1 << 2) | (0b1 << 6))
|
||||||
|
#endif
|
||||||
|
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_get_gpio_state_obj, Wakeup_get_gpio_state);
|
static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_get_gpio_state_obj, Wakeup_get_gpio_state);
|
||||||
static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_reset_gpio_state_obj, Wakeup_reset_gpio_state);
|
static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_reset_gpio_state_obj, Wakeup_reset_gpio_state);
|
||||||
|
@ -23,4 +44,17 @@ const mp_obj_module_t wakeup_user_cmodule = {
|
||||||
MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule, MODULE_WAKEUP_ENABLED);
|
MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule, MODULE_WAKEUP_ENABLED);
|
||||||
#else
|
#else
|
||||||
MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule);
|
MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void runtime_init_latch(void) {
|
||||||
|
runtime_wakeup_gpio_state = gpio_get_all();
|
||||||
|
|
||||||
|
gpio_init_mask(PICO_WAKEUP_PIN_MASK);
|
||||||
|
gpio_set_dir_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_DIR);
|
||||||
|
gpio_put_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_VALUE);
|
||||||
|
};
|
||||||
|
|
||||||
|
// After runtime_init_early_resets, PICO_RUNTIME_INIT_EARLY_RESETS ?
|
||||||
|
PICO_RUNTIME_INIT_FUNC_HW(runtime_init_latch, "00101");
|
||||||
|
// Too early?
|
||||||
|
// PICO_RUNTIME_INIT_FUNC_HW(runtime_init_latch, PICO_RUNTIME_INIT_EARLIEST);
|
||||||
|
|
Ładowanie…
Reference in New Issue