summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Hooper <rhooper@toybox.ca>2020-01-08 15:15:27 -0500
committerRoy Hooper <rhooper@toybox.ca>2020-01-08 15:15:27 -0500
commit4e040b01522ff955cc480489de74e784876680be (patch)
treead40b185826323d6087d9e2061c896d18d2bb777
parent34c9e00f08b77f5336db911e376f15512bf0790b (diff)
add reset of heap to board reset for nrf port
-rw-r--r--ports/nrf/common-hal/neopixel_write/__init__.c14
-rw-r--r--ports/nrf/supervisor/port.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c
index d097f96e3..cf1b36705 100644
--- a/ports/nrf/common-hal/neopixel_write/__init__.c
+++ b/ports/nrf/common-hal/neopixel_write/__init__.c
@@ -97,6 +97,16 @@ static NRF_PWM_Type* find_free_pwm (void) {
return NULL;
}
+static uint16_t* pixels_pattern_heap = NULL;
+static size_t pixels_pattern_heap_size = 0;
+static bool pattern_on_heap = false;
+// Called during reset_port() to free the pattern buffer
+void neopixel_write_reset(void) {
+ pixels_pattern_heap = NULL;
+ pixels_pattern_heap_size = 0;
+ pattern_on_heap = false;
+}
+
uint64_t next_start_tick_ms = 0;
uint32_t next_start_tick_us = 1000;
@@ -113,12 +123,8 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
// using DWT
#define PATTERN_SIZE(numBytes) (numBytes * 8 * sizeof(uint16_t) + 2 * sizeof(uint16_t))
-
uint32_t pattern_size = PATTERN_SIZE(numBytes);
uint16_t* pixels_pattern = NULL;
- static uint16_t* pixels_pattern_heap = NULL;
- static size_t pixels_pattern_heap_size = 0;
- bool pattern_on_heap = false;
// Use the stack to store 1 pixels worth of PWM data for the status led. uint32_t to ensure alignment.
// Make it at least as big as PATTERN_SIZE(3), for one pixel of RGB data.
diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c
index af858aa4a..d240e3be0 100644
--- a/ports/nrf/supervisor/port.c
+++ b/ports/nrf/supervisor/port.c
@@ -47,6 +47,7 @@
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PulseIn.h"
#include "common-hal/rtc/RTC.h"
+#include "common-hal/neopixel_write/__init__.h"
#include "tick.h"
#include "shared-bindings/rtc/__init__.h"
@@ -106,6 +107,7 @@ void reset_port(void) {
i2c_reset();
spi_reset();
uart_reset();
+ neopixel_write_reset();
#if CIRCUITPY_AUDIOBUSIO
i2s_reset();