Add LCD send command for debug

pull/130/head
DiSlord 5 years ago
parent c8fea63042
commit 0ff1d09f30

@ -326,6 +326,39 @@ static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data)
//LCD_CS_HIGH;
}
// Disable inline for this function
uint32_t lcd_send_command(uint8_t cmd, uint8_t len, const uint8_t *data)
{
// Uncomment on low speed SPI (possible get here before previous tx complete)
while (SPI_IN_TX_RX(LCD_SPI));
// Set read speed (if need different)
SPI_BR_SET(LCD_SPI, SPI_BR_DIV256);
LCD_CS_LOW;
LCD_DC_CMD;
SPI_WRITE_8BIT(LCD_SPI, cmd);
// Need wait transfer complete and set data bit
while (SPI_IN_TX_RX(LCD_SPI))
;
// Send command data (if need)
LCD_DC_DATA;
while (len-- > 0) {
while (SPI_TX_IS_NOT_EMPTY(LCD_SPI))
;
SPI_WRITE_8BIT(LCD_SPI, *data++);
}
// Skip data from rx buffer
spi_DropRx();
uint32_t ret = 0;
ret|= spi_RxByte();ret<<=8;
ret|= spi_RxByte();ret<<=8;
ret|= spi_RxByte();ret<<=8;
ret|= spi_RxByte();
LCD_CS_HIGH;
SPI_BR_SET(LCD_SPI, LCD_SPI_SPEED);
return ret;
}
static const uint8_t ili9341_init_seq[] = {
// cmd, len, data...,
// SW reset

@ -227,7 +227,6 @@ extern const uint8_t numfont16x22[];
#define NUM_FONT_GET_HEIGHT 22
#define NUM_FONT_GET_DATA(ch) (&numfont16x22[ch*2*NUM_FONT_GET_HEIGHT])
// Offset of plot area (size of additional info at left side)
#define OFFSETX 10
#define OFFSETY 0
@ -484,6 +483,7 @@ void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size);
void ili9341_drawfont(uint8_t ch, int x, int y);
void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t* out);
void ili9341_line(int x0, int y0, int x1, int y1);
uint32_t lcd_send_command(uint8_t cmd, uint8_t len, const uint8_t *data);
// SD Card support, discio functions for FatFS lib implemented in ili9341.c
#ifdef __USE_SD_CARD__

Loading…
Cancel
Save

Powered by TurnKey Linux.