3#include "platforms/arm/teensy/is_teensy.h"
5#if defined(FL_IS_TEENSY_4X)
9#include "platforms/arm/teensy/teensy4_common/dmamem.h"
30#define BYTES_PER_DMA 150
38static_assert(BYTES_PER_DMA >= 90,
39 "BYTES_PER_DMA must be >= 90 to keep the ISR refill margin "
40 "ahead of the DMA major-loop tick. See #3406 round-2 race.");
45 2 * BYTES_PER_DMA * 32,
46 "ObjectFLED ISR half-buffer refill needs a full double buffer");
52class ObjectFLEDDmaManager {
54 static ObjectFLEDDmaManager& getInstance() {
55 static ObjectFLEDDmaManager instance;
59 void acquire(
void* owner);
60 void release(
void* owner);
61 void waitForCompletion();
63 void* getCurrentOwner()
const {
return mCurrentOwner; }
75 bool ensureBitdata(uint32_t numbytes);
90 static FL_DMAMEM
uint32_t bitmask[4] __attribute__((aligned(32)));
99 volatile uint32_t framebuffer_index = 0;
103 uint8_t pin_bitnum[NUM_DIGITAL_PINS];
104 uint8_t pin_offset[NUM_DIGITAL_PINS];
107 ObjectFLEDDmaManager() =
default;
108 ~ObjectFLEDDmaManager() =
default;
109 ObjectFLEDDmaManager(
const ObjectFLEDDmaManager&) =
delete;
110 ObjectFLEDDmaManager& operator=(
const ObjectFLEDDmaManager&) =
delete;
112 void* mCurrentOwner =
nullptr;
113 void* mBitdataAlloc =
nullptr;
fl::Grid< CRGB > frameBuffer
Base definition for an LED controller.
constexpr uint32_t bitdataWordsFor(uint32_t numbytes, uint32_t bytesPerDma)
Words of bitdata a frame of numbytes bytes per strip needs.