more debugging: async still not working, but looking at 8-bit color status & bios

This commit is contained in:
Jorj Bauer 2022-01-20 08:19:16 -05:00
parent 6d41176ee6
commit eb60d86ab5
3 changed files with 16 additions and 26 deletions

View File

@ -79,6 +79,10 @@
#define TCR_MASK (LPSPI_TCR_PCS(3) | LPSPI_TCR_FRAMESZ(31) | LPSPI_TCR_CONT | LPSPI_TCR_RXMSK )
#define _565toR(c) ( ((c) & 0xF800) >> 8 )
#define _565toG(c) ( ((c) & 0x07E0) >> 3 )
#define _565toB(c) ( ((c) & 0x001F) << 3 )
static RA8875_t4 *_dmaActiveDisplay[3];
RA8875_t4::RA8875_t4(const uint8_t cs_pin, const uint8_t rst_pin, const uint8_t mosi_pin, const uint8_t sck_pin, const uint8_t miso_pin)
@ -95,7 +99,6 @@ RA8875_t4::RA8875_t4(const uint8_t cs_pin, const uint8_t rst_pin, const uint8_t
_pspi = NULL;
_pfbtft = NULL;
_dma_state = 0;
pending_rx_count = 0;
_frame_complete_callback = NULL;
_frame_callback_on_HalfDone = false;
_dma_frame_count = 0;
@ -146,7 +149,6 @@ void RA8875_t4::begin(uint32_t spi_clock, uint32_t spi_clock_read)
// DIRECT_WRITE_HIGH(_csport, _cspinmask);
digitalWriteFast(_cs, HIGH);
pending_rx_count = 0; // Make sure it is zero if we we do a second begin...
_spi_tcr_current = _pimxrt_spi->TCR; // get the current TCR value
maybeUpdateTCR(LPSPI_TCR_PCS(3)|LPSPI_TCR_FRAMESZ(7));
@ -348,11 +350,10 @@ bool RA8875_t4::updateScreenAsync(bool update_cont)
while (pftbft < pfbtft_end) {
_pspi->transfer(*pftbft++);
}
pending_rx_count++; // waiting for one more full transaction to complete
waitTransmitComplete();
_endSend();
return;
return true;
// DEBUG END
if (!_pfbtft) return false;
@ -427,9 +428,9 @@ void RA8875_t4::fillWindow(uint16_t color)
_writeRegister(RA8875_DLVER0 + 1,y1 >> 8);
// Set the color
_writeRegister(RA8875_FGCR0,((color & 0xF800) >> 11)); // 5 bits red
_writeRegister(RA8875_FGCR0+1,((color & 0x07E0) >> 5)); // 6 bits green
_writeRegister(RA8875_FGCR0+2,((color & 0x001F) )); // 5 bits blue
_writeRegister(RA8875_FGCR0,_565toR(color) >> 2); // 5 bits red -> 3 bits red
_writeRegister(RA8875_FGCR0+1,_565toG(color) >> 3); // 6 bits green -> 3 bits green
_writeRegister(RA8875_FGCR0+2,_565toB(color) >> 3); // 5 bits blue -> 2 bits blue
// Send fill
writeCommand(RA8875_DCR); // draw control register
@ -619,18 +620,6 @@ void RA8875_t4::process_dma_interrupt(void) {
}
}
void RA8875_t4::waitTransmitComplete(void) {
uint32_t tmp __attribute__((unused));
while (pending_rx_count) {
if ((_pimxrt_spi->RSR & LPSPI_RSR_RXEMPTY) == 0) {
tmp = _pimxrt_spi->RDR; // Read any pending RX bytes in
pending_rx_count--; //decrement count of bytes still levt
}
}
_pimxrt_spi->CR = LPSPI_CR_MEN | LPSPI_CR_RRF; // Clear receive FIFO and leave module enabled
}
// Other possible methods, that I don't think we'll need:
// void RA8875_t4::setFrameCompleteCB(void (*pcb)(), bool fCallAlsoHalfDone)

View File

@ -49,7 +49,6 @@ private:
// These are the old style RA8875 calls -- replace them ***
void writeCommand(const uint8_t d);
void writeData16(uint16_t data);
void waitTransmitComplete(void);
void _writeData(uint8_t data);
void _writeRegister(const uint8_t reg, uint8_t val);
@ -91,7 +90,6 @@ private:
uint32_t _spi_fcr_save;
uint8_t *_pfbtft;
volatile uint8_t _dma_state;
uint8_t pending_rx_count;
uint32_t _spi_tcr_current;
volatile uint32_t _dma_frame_count;
volatile uint16_t _dma_sub_frame_count;

View File

@ -80,7 +80,7 @@ TeensyDisplay::~TeensyDisplay()
void TeensyDisplay::flush()
{
// Nothing to flush, b/c there's no DMA in this driver and we draw it all in real-time. (Eww.)
tft.updateScreenAsync(false);
}
void TeensyDisplay::redraw()
@ -114,7 +114,10 @@ void TeensyDisplay::blit()
// Start updates, if they're not running already
// if (!tft.asyncUpdateActive())
// tft.updateScreenAsync(true);
tft.updateScreenAsync(false);
// DEBUGGING: not refreshing every time so I can see the machine boot
static uint32_t ctr = 0;
if (((ctr++) & 0x0F) == 0)
tft.updateScreenAsync(false);
// draw overlay, if any, occasionally
{
@ -209,12 +212,12 @@ void TeensyDisplay::clrScr(uint8_t coloridx)
if (coloridx == c_black) {
tft.fillWindow();
} else if (coloridx == c_white) {
tft.fillWindow();
tft.fillWindow(loresPixelColors[c_white]);
} else {
uint16_t color16 = loresPixelColors[c_black];
if (coloridx < 16)
color16 = loresPixelColors[coloridx];
tft.fillWindow();
tft.fillWindow(color16);
}
}