Skip to content

Commit d6dd968

Browse files
committed
CMakeLists.txt
display.h spi.cpp spi.h
1 parent 74a9f22 commit d6dd968

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
cmake_minimum_required(VERSION 2.8)
22

3+
project(fbcp-ili9341)
34
if(NOT CMAKE_BUILD_TYPE)
45
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
56
endif()
@@ -227,6 +228,9 @@ elseif(KEDEI_V63_MPI3501)
227228
if (USE_DMA_TRANSFERS)
228229
message(FATAL_ERROR "DMA is unfortunately not possible with KeDei MPI3501. Please disable with -DUSE_DMA_TRANSFERS=OFF.")
229230
endif()
231+
elseif(KEDEI_TRASH)
232+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKEDEI_TRASH")
233+
message(STATUS "Targeting KeDei 3.5 inch SPI TFTLCD 480*320 16bit/18bit version 3.0 2015/4/9 display")
230234
elseif(ILI9341)
231235
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DILI9341")
232236
message(STATUS "Targeting ILI9341")
@@ -278,4 +282,4 @@ endif()
278282

279283
add_executable(fbcp-ili9341 ${sourceFiles})
280284

281-
target_link_libraries(fbcp-ili9341 pthread bcm_host atomic)
285+
target_link_libraries(fbcp-ili9341 pthread bcm_host atomic bcm2835)

display.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#if defined(ILI9341) || defined(ILI9340)
99
#include "ili9341.h"
10+
#elif defined(KEDEI_TRASH)
11+
#include "kedei_trash.h"
1012
#elif defined(ILI9486L)
1113
#include "ili9486l.h"
1214
#elif defined(ILI9488)

spi.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static uint32_t writeCounter = 0;
4141
TOGGLE_CHIP_SELECT_LINE(); \
4242
DEBUG_PRINT_WRITTEN_BYTE(w); \
4343
} while(0)
44-
44+
4545
int mem_fd = -1;
4646
volatile void *bcm2835 = 0;
4747
volatile GPIORegisterFile *gpio = 0;
@@ -322,7 +322,6 @@ void RunSPITask(SPITask *task)
322322

323323
SET_GPIO(GPIO_TFT_DATA_CONTROL);
324324
#endif
325-
326325
// Send the data payload:
327326
while(tStart < tPrefillEnd) WRITE_FIFO(*tStart++);
328327
while(tStart < tEnd)
@@ -338,6 +337,11 @@ void RunSPITask(SPITask *task)
338337
}
339338
#else
340339

340+
#ifdef KEDEI_TRASH
341+
extern void lcd_data8(uint8_t *data);
342+
extern void lcd_cmd(uint8_t data);
343+
#endif
344+
341345
void RunSPITask(SPITask *task)
342346
{
343347
WaitForPolledSPITransferToFinish();
@@ -355,6 +359,15 @@ void RunSPITask(SPITask *task)
355359
const uint32_t payloadSize = tEnd - tStart;
356360
uint8_t *tPrefillEnd = tStart + MIN(15, payloadSize);
357361

362+
#ifdef KEDEI_TRASH
363+
lcd_cmd(task->cmd);
364+
while(tStart < tEnd)
365+
{
366+
lcd_data8(tStart);
367+
tStart += 2;
368+
}
369+
#else // not KEDEI_TRASH
370+
358371
// Send the command word if display is 4-wire (3-wire displays can omit this, commands are interleaved in the data payload stream above)
359372
#ifndef SPI_3WIRE_PROTOCOL
360373
// An SPI transfer to the display always starts with one control (command) byte, followed by N data bytes.
@@ -365,7 +378,6 @@ void RunSPITask(SPITask *task)
365378
WRITE_FIFO(0x00);
366379
#endif
367380
WRITE_FIFO(task->cmd);
368-
369381
#ifdef DISPLAY_SPI_BUS_IS_16BITS_WIDE
370382
while(!(spi->cs & (BCM2835_SPI0_CS_DONE))) /*nop*/;
371383
spi->fifo;
@@ -393,7 +405,11 @@ void RunSPITask(SPITask *task)
393405
else
394406
#endif
395407
{
396-
while(tStart < tPrefillEnd) WRITE_FIFO(*tStart++);
408+
while(tStart < tPrefillEnd)
409+
{
410+
WRITE_FIFO(*tStart++);
411+
412+
}
397413
while(tStart < tEnd)
398414
{
399415
uint32_t cs = spi->cs;
@@ -402,10 +418,12 @@ void RunSPITask(SPITask *task)
402418
if ((cs & (BCM2835_SPI0_CS_RXR|BCM2835_SPI0_CS_RXF))) spi->cs = BCM2835_SPI0_CS_CLEAR_RX | BCM2835_SPI0_CS_TA | DISPLAY_SPI_DRIVE_SETTINGS;
403419
}
404420
}
421+
#endif // not KEDEI_TRASH
405422

406423
#ifdef DISPLAY_NEEDS_CHIP_SELECT_SIGNAL
407424
END_SPI_COMMUNICATION();
408425
#endif
426+
409427
}
410428
#endif
411429

spi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ typedef struct __attribute__((packed)) SPITask
112112
#else
113113
uint8_t cmd;
114114
#endif
115-
uint32_t dmaSpiHeader;
116115
#ifdef OFFLOAD_PIXEL_COPY_TO_DMA_CPP
117116
uint8_t *fb;
118117
uint8_t *prevFb;
119118
uint16_t width;
120119
#endif
120+
uint32_t dmaSpiHeader;
121121
uint8_t data[]; // Contains both 8-bit and 9-bit tasks back to back, 8-bit first, then 9-bit.
122122

123123
#ifdef SPI_3WIRE_PROTOCOL
@@ -130,6 +130,7 @@ typedef struct __attribute__((packed)) SPITask
130130
inline uint8_t *PayloadEnd() { return data + size; }
131131
inline uint32_t PayloadSize() const { return size; }
132132
inline uint32_t *DmaSpiHeaderAddress() { return &dmaSpiHeader; }
133+
// inline uint32_t *DmaSpiHeaderAddress() { return 0; }
133134
#endif
134135

135136
} SPITask;

0 commit comments

Comments
 (0)