Merge pull request #16 from adafruit/rp2350_fixes
Fix high-numbered RP2350's
This commit is contained in:
commit
fc96155cf3
6 changed files with 128 additions and 136 deletions
|
|
@ -294,11 +294,7 @@ Adafruit_NeoPXL8::~Adafruit_NeoPXL8() {
|
|||
neopxl8_ptr = NULL;
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
bool Adafruit_NeoPXL8::begin(bool dbuf, PIO pio_instance) {
|
||||
#else
|
||||
bool Adafruit_NeoPXL8::begin(bool dbuf) {
|
||||
#endif
|
||||
Adafruit_NeoPixel::begin(); // Call base class begin() function 1st
|
||||
if (pixels) { // Successful malloc of NeoPixel buffer?
|
||||
uint8_t bytesPerPixel = (wOffset == rOffset) ? 3 : 4;
|
||||
|
|
@ -308,9 +304,6 @@ bool Adafruit_NeoPXL8::begin(bool dbuf) {
|
|||
neopxl8_ptr = this; // Save object pointer for interrupt
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
|
||||
pio = pio_instance;
|
||||
|
||||
// Validate pins, must be within any 8 consecutive GPIO bits
|
||||
int16_t least_pin = 0x7FFF, most_pin = -1;
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
|
|
@ -332,8 +325,19 @@ bool Adafruit_NeoPXL8::begin(bool dbuf) {
|
|||
dmaBuf[1] = dbuf ? &dmaBuf[0][buf_size] : dmaBuf[0];
|
||||
|
||||
// Set up PIO code & clock
|
||||
offset = pio_add_program(pio, &neopxl8_program);
|
||||
sm = pio_claim_unused_sm(pio, true); // 0-3
|
||||
// Find a PIO with enough available space in its instruction memory
|
||||
pio = NULL;
|
||||
|
||||
if (!pio_claim_free_sm_and_add_program_for_gpio_range(
|
||||
&neopxl8_program, &pio, &sm, &offset, least_pin, 8, true)) {
|
||||
pio = NULL;
|
||||
sm = -1;
|
||||
offset = 0;
|
||||
return false; // No PIO available
|
||||
}
|
||||
|
||||
// offset = pio_add_program(pio, &neopxl8_program);
|
||||
// sm = pio_claim_unused_sm(pio, true); // 0-3
|
||||
pio_sm_config conf = pio_get_default_sm_config();
|
||||
conf.pinctrl = 0; // SDK fails to set this
|
||||
sm_config_set_wrap(&conf, offset, offset + neopxl8_program.length - 1);
|
||||
|
|
@ -525,7 +529,8 @@ bool Adafruit_NeoPXL8::begin(bool dbuf) {
|
|||
|
||||
if (dbuf) {
|
||||
alignedAddr[1] =
|
||||
(uint32_t *)((uint32_t)(&allocAddr[buf_size + EXTRASTARTBYTES + 3]) &
|
||||
(uint32_t
|
||||
*)((uint32_t)(&allocAddr[buf_size + EXTRASTARTBYTES + 3]) &
|
||||
~3);
|
||||
dmaBuf[1] = (uint8_t *)alignedAddr[1] - EXTRASTARTBYTES;
|
||||
memset(dmaBuf[1], 0, EXTRASTARTBYTES);
|
||||
|
|
@ -571,7 +576,8 @@ bool Adafruit_NeoPXL8::begin(bool dbuf) {
|
|||
; // Wait for enable
|
||||
#else
|
||||
// Enable GCLK for TCC0
|
||||
GCLK->CLKCTRL.reg = (uint16_t)(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 |
|
||||
GCLK->CLKCTRL.reg =
|
||||
(uint16_t)(GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 |
|
||||
GCLK_CLKCTRL_ID(GCM_TCC0_TCC1));
|
||||
while (GCLK->STATUS.bit.SYNCBUSY == 1)
|
||||
;
|
||||
|
|
@ -852,13 +858,7 @@ Adafruit_NeoPXL8HDR::~Adafruit_NeoPXL8HDR() {
|
|||
free(pixel_buf[0]);
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
bool Adafruit_NeoPXL8HDR::begin(bool blend, uint8_t bits, bool dbuf,
|
||||
PIO pio_instance) {
|
||||
#else
|
||||
bool Adafruit_NeoPXL8HDR::begin(bool blend, uint8_t bits, bool dbuf) {
|
||||
#endif
|
||||
|
||||
// If blend flag is set, allocate 3X pixel buffers, else 2X (for
|
||||
// temporal dithering only). Result is the buffer size in 16-bit
|
||||
// words (not bytes).
|
||||
|
|
@ -869,15 +869,12 @@ bool Adafruit_NeoPXL8HDR::begin(bool blend, uint8_t bits, bool dbuf) {
|
|||
if ((pixel_buf[0] = (uint16_t *)malloc(buf_size * sizeof(uint16_t)))) {
|
||||
if ((dither_table =
|
||||
(uint16_t *)malloc((1 << dither_bits) * sizeof(uint16_t)))) {
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
if (Adafruit_NeoPXL8::begin(dbuf, pio_instance)) {
|
||||
mutex_init(&mutex);
|
||||
#else
|
||||
if (Adafruit_NeoPXL8::begin(dbuf)) {
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
mutex_init(&mutex);
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
mutex = xSemaphoreCreateMutex();
|
||||
#endif // end ESP32S3
|
||||
#endif // end !RP2040
|
||||
#endif // end ESP32S3/RP2040
|
||||
|
||||
// All allocations & initializations were successful.
|
||||
// Generate bit-flip table for ordered dithering...
|
||||
|
|
|
|||
|
|
@ -81,11 +81,7 @@ public:
|
|||
NeoPXL8HDR's use. Currently ignored on SAMD.
|
||||
@return true on successful alloc/init, false otherwise.
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
bool begin(bool dbuf = false, PIO pio_instance = pio0);
|
||||
#else
|
||||
bool begin(bool dbuf = false);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief Process and issue new data to the NeoPixel strands.
|
||||
|
|
@ -175,11 +171,11 @@ public:
|
|||
|
||||
protected:
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
PIO pio; ///< PIO peripheral
|
||||
uint8_t sm; ///< State machine #
|
||||
PIO pio = NULL; ///< PIO peripheral
|
||||
uint sm = -1; ///< State machine #
|
||||
uint offset = 0;
|
||||
int dma_channel; ///< DMA channel #
|
||||
dma_channel_config dma_config; ///< DMA configuration
|
||||
uint offset;
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
gdma_channel_handle_t dma_chan; ///< DMA channel
|
||||
dma_descriptor_t *desc; ///< DMA descriptor pointer
|
||||
|
|
@ -253,12 +249,7 @@ public:
|
|||
others just waste RAM. Currently ignored on SAMD.
|
||||
@return true on successful alloc/init, false otherwise.
|
||||
*/
|
||||
#if defined(ARDUINO_ARCH_RP2040)
|
||||
bool begin(bool blend = false, uint8_t bits = 4, bool dbuf = false,
|
||||
PIO pio_instance = pio0);
|
||||
#else
|
||||
bool begin(bool blend = false, uint8_t bits = 4, bool dbuf = false);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief Set peak output brightness for all channels (RGB and W if
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
// This is a companion to "move2msc" in the extras/Processing folder.
|
||||
// It plays preconverted videos from the on-board flash filesystem.
|
||||
|
||||
#include "SdFat_Adafruit_Fork.h"
|
||||
#include <Adafruit_NeoPXL8.h>
|
||||
#include <Adafruit_CPFS.h> // For accessing CIRCUITPY drive
|
||||
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
// This is a companion to "move2serial" in the extras/Processing folder.
|
||||
|
||||
#include "SdFat_Adafruit_Fork.h"
|
||||
#include <Adafruit_NeoPXL8.h>
|
||||
#include <Adafruit_CPFS.h> // For accessing CIRCUITPY drive
|
||||
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
// This is a companion to "move2msc" in the extras/Processing folder.
|
||||
// It plays preconverted videos from the on-board flash filesystem.
|
||||
|
||||
#include "SdFat_Adafruit_Fork.h"
|
||||
#include <Adafruit_NeoPXL8.h>
|
||||
#include <Adafruit_CPFS.h> // For accessing CIRCUITPY drive
|
||||
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
// This is a companion to "move2serial" in the extras/Processing folder.
|
||||
|
||||
#include "SdFat_Adafruit_Fork.h"
|
||||
#include <Adafruit_NeoPXL8.h>
|
||||
#include <Adafruit_CPFS.h> // For accessing CIRCUITPY drive
|
||||
#define ARDUINOJSON_ENABLE_COMMENTS 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue