FastLED 3.9.15
Loading...
Searching...
No Matches
ObjectFLEDDmaManager.h
Go to the documentation of this file.
1#pragma once
2
3#include "platforms/arm/teensy/is_teensy.h"
4
5#if defined(FL_IS_TEENSY_4X) // Teensy 4.0/4.1 only
6
7#include <Arduino.h>
8#include "DMAChannel.h"
9
10namespace fl {
11
12// Forward declarations
13#ifndef BYTES_PER_DMA
14#define BYTES_PER_DMA 20
15#endif
16
21class ObjectFLEDDmaManager {
22 public:
23 static ObjectFLEDDmaManager& getInstance() {
24 static ObjectFLEDDmaManager instance;
25 return instance;
26 }
27
28 void acquire(void* owner);
29 void release(void* owner);
30 void waitForCompletion();
31 bool isBusy();
32 void* getCurrentOwner() const { return mCurrentOwner; }
33
34 // Shared DMA resources
35 DMAChannel dma1;
36 DMAChannel dma2;
37 DMAChannel dma3;
38 DMASetting dma2next;
39
40 // DMAMEM buffers must be static to work with section attributes
41 static DMAMEM uint32_t bitdata[BYTES_PER_DMA * 64] __attribute__((used, aligned(32)));
42 static DMAMEM uint32_t bitmask[4] __attribute__((used, aligned(32)));
43
44 // Shared state for ISR
45 volatile uint32_t framebuffer_index = 0;
46 uint8_t* frameBuffer = nullptr;
47 uint32_t numbytes = 0;
48 uint8_t numpins = 0;
49 uint8_t pin_bitnum[NUM_DIGITAL_PINS];
50 uint8_t pin_offset[NUM_DIGITAL_PINS];
51
52 private:
53 ObjectFLEDDmaManager() = default;
54 ~ObjectFLEDDmaManager() = default;
55 ObjectFLEDDmaManager(const ObjectFLEDDmaManager&) = delete;
56 ObjectFLEDDmaManager& operator=(const ObjectFLEDDmaManager&) = delete;
57
58 void* mCurrentOwner = nullptr;
59};
60
61} // namespace fl
62
63#endif // FL_IS_TEENSY_4X
#define BYTES_PER_DMA
Definition ObjectFLED.h:61
fl::Grid< CRGB > frameBuffer
Definition Corkscrew.h:102
fl::u32 uint32_t
Definition s16x16x4.h:219
unsigned char uint8_t
Definition s16x16x4.h:209
Base definition for an LED controller.
Definition crgb.hpp:179