14 #define USE_DMA_FOR_PUSH_PIXELS 0 15 #define USE_DMA_FOR_PUSH_COLOR 0 17 #define USE_DMA (USE_DMA_FOR_PUSH_PIXELS|USE_DMA_FOR_PUSH_COLOR) 50 while (Device::TearingEffectPin.group().IDR()->
get(Device::TearingEffectPin.pin())) {
54 while (!Device::TearingEffectPin.group().IDR()->
get(Device::TearingEffectPin.pin())) {
68 #define SEND_COMMAND(c, ...) {*CommandAddress = Command::c; uint8_t data[] = {__VA_ARGS__}; for (unsigned int i=0;i<sizeof(data);i++) { *DataAddress = data[i];};} 95 DMAEngine.SM0AR(DMAStream)->set((
uint32_t)DataAddress);
100 DMAEngine.SCR(DMAStream)->setMINC(
false);
105 while (DMAEngine.SCR(DMAStream)->getEN()) {
109 static inline void startDMAUpload(
const KDColor * src,
bool incrementSrc,
uint16_t length) {
111 DMAEngine.LIFCR()->set(0xF7D0F7D);
113 DMAEngine.SNDTR(DMAStream)->set(length);
114 DMAEngine.SPAR(DMAStream)->set((
uint32_t)src);
115 DMAEngine.SCR(DMAStream)->setPINC(incrementSrc);
116 DMAEngine.SCR(DMAStream)->setEN(
true);
122 for(
const GPIOPin & g : FSMCPins) {
129 PowerPin.group().ODR()->set(PowerPin.pin(),
true);
133 ResetPin.group().ODR()->set(ResetPin.pin(),
true);
137 ExtendedCommandPin.group().ODR()->set(ExtendedCommandPin.pin(),
true);
149 for(
const GPIOPin & g : FSMCPins) {
175 FSMC.
BCR(FSMCMemoryBank)->setEXTMOD(
true);
176 FSMC.
BCR(FSMCMemoryBank)->setWREN(
true);
179 FSMC.
BCR(FSMCMemoryBank)->setMUXEN(
false);
180 FSMC.
BCR(FSMCMemoryBank)->setMBKEN(
true);
209 FSMC.
BTR(FSMCMemoryBank)->setADDSET(2);
210 FSMC.
BTR(FSMCMemoryBank)->setADDHLD(0);
211 FSMC.
BTR(FSMCMemoryBank)->setDATAST(36);
212 FSMC.
BTR(FSMCMemoryBank)->setBUSTURN(10);
216 FSMC.
BWTR(FSMCMemoryBank)->setADDSET(2);
217 FSMC.
BWTR(FSMCMemoryBank)->setADDHLD(0);
218 FSMC.
BWTR(FSMCMemoryBank)->setDATAST(3);
219 FSMC.
BWTR(FSMCMemoryBank)->setBUSTURN(3);
248 uint16_t x_start, x_end, y_start, y_end;
253 x_end = r.
x() + r.
width() - 1;
255 y_end = r.
y() + r.
height() - 1;
259 x_end = r.
y() + r.
height() - 1;
265 *DataAddress = (x_start >> 8);
266 *DataAddress = (x_start & 0xFF);
267 *DataAddress = (x_end >> 8);
268 *DataAddress = (x_end & 0xFF);
271 *DataAddress = (y_start >> 8);
272 *DataAddress = (y_start & 0xFF);
273 *DataAddress = (y_end >> 8);
274 *DataAddress = (y_end & 0xFF);
283 #if USE_DMA_FOR_PUSH_PIXELS 284 startDMAUpload(pixels,
true, numberOfPixels);
286 while (numberOfPixels > 8) {
287 *DataAddress = *pixels++;
288 *DataAddress = *pixels++;
289 *DataAddress = *pixels++;
290 *DataAddress = *pixels++;
291 *DataAddress = *pixels++;
292 *DataAddress = *pixels++;
293 *DataAddress = *pixels++;
294 *DataAddress = *pixels++;
297 while (numberOfPixels--) {
298 *DataAddress = *pixels++;
305 #if USE_DMA_FOR_PUSH_COLOR 312 startDMAUpload(&staticColor,
false, (numberOfPixels > 64000 ? 64000 : numberOfPixels));
314 while (numberOfPixels--) {
315 *DataAddress = color;
321 if (numberOfPixels == 0) {
328 if (numberOfPixels == 0) {
333 uint16_t firstPixel = (
one & 0xF800) | (
one & 0xFC) << 3 | (two & 0xF800) >> 11;
337 if (numberOfPixels == 0) {
341 uint16_t secondPixel = (two & 0xF8) << 8 | (three & 0xFC00) >> 5 | (three & 0xF8) >> 3;
void Display(const char *input)
void pullPixels(KDColor *pixels, size_t numberOfPixels)
void setDrawingArea(KDRect r, Orientation o)
void pullRect(KDRect r, KDColor *pixels)
void pushPixels(const KDColor *pixels, size_t numberOfPixels)
void pushRect(KDRect r, const KDColor *pixels)
#define SEND_COMMAND(c,...)
void pushColor(KDColor color, size_t numberOfPixels)
static constexpr KDColor RGB16(uint16_t rgb)
volatile BCR * BCR(int index) const
volatile BTR * BTR(int index) const
void waitForPendingDMAUploadCompletion()
KDCoordinate width() const
volatile BWTR * BWTR(int index) const
void pushRectUniform(KDRect r, KDColor c)
KDCoordinate height() const