Driver.c File Reference

write the Framebuffer More...

`#include "Driver.h"`
Include dependency graph for Driver.c:

## Functions

uint32_t | vDriver_GetId (void)
| get LCD driver chip id More...
static esp_err_t | iDriver_sendLineFinish (void)
| send finish after line More...
void | vDriver_spiPreTransferCallback (spi_transaction_t *t)
| Pre Transfer Callback. More...
esp_err_t | iDriver_sendCmd (const uint8_t u8Cmd)
| Send a command to the LCD. More...
static esp_err_t | iDriver_sendLines (uint16_t u16Ypos, uint16_t *pu16Linedata)
| send line to lcd chip More...
esp_err_t | iDriver_SendData (const uint8_t *pu8Data, uint16_t u16Len)
| Send data to the LCD. More...
void | vDriver_getFramenufferPerLine (uint16_t *pu16Dest, uint16_t u16Line, uint16_t u16Linect, uint16_t ***pu16Framebuffer)
| Get the pixel data for a set of lines (with implied line size of 320) More...
esp_err_t | vDriver_init (void)
| Initialize the driver. More...
esp_err_t | iDriver_writeFramebuffer (uint16_t ***pu16Framebuffer)
| write framebuffer to LCD via SPI More...

## Variables

spi_device_handle_t | spi
uint16_t * | lines [2]
int16_t | sending_line =-1
int16_t | calc_line =0
static DRAM_ATTR const lcd_init_cmd_t | st_init_cmds []
static DRAM_ATTR const lcd_init_cmd_t | ili_init_cmds []

## Detailed Description

write the Framebuffer

Author
  Hendrik Schutter

Version
  V1.0

Date
  03.11.2020

This code used SPI to write data to the LCD driver like ILI9341 or ST7789V.

## Function Documentation

## iDriver_sendCmd()

esp_err_t iDriver_sendCmd | ( | const uint8_t | u8Cmd | ) |

Send a command to the LCD.

Parameters

  const | uint8_t u8Cmd

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

Send a command to the LCD. Uses spi_device_polling_transmit, which waits until the transfer is complete.

Since command transactions are usually small, they are handled in polling mode for higher speed. The overhead of interrupt transactions is more than just waiting for the transaction to complete.

Here is the caller graph for this function:

## iDriver_SendData()

esp_err_t iDriver_SendData | ( | const uint8_t * | pu8Data,
|  | uint16_t | u16Len
| ) |  |

Send data to the LCD.

Parameters

  const | uint8_t *pu8Data
  uint16_t | u16Len

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

Send data to the LCD. Uses spi_device_polling_transmit, which waits until the transfer is complete.

Since data transactions are usually small, they are handled in polling mode for higher speed. The overhead of interrupt transactions is more than just waiting for the transaction to complete.

Here is the caller graph for this function:

## iDriver_sendLineFinish()

static esp_err_t iDriver_sendLineFinish | ( | void |  | ) |

static

send finish after line

Parameters

  void |

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

Here is the caller graph for this function:

## iDriver_sendLines()

static esp_err_t iDriver_sendLines | ( | uint16_t | u16Ypos,
|  | uint16_t * | pu16Linedata
| ) |  |

static

send line to lcd chip

Parameters

  uint16_t | u16Ypos
  uint16_t | *pu16Linedata

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

To send a set of lines we have to send a command, 2 data bytes, another command, 2 more data bytes and another command before sending the line data itself; a total of 6 transactions. (We can't put all of this in just one transaction because the D/C line needs to be toggled in the middle.) This routine queues these commands up as interrupt transactions so they get sent faster (compared to calling spi_device_transmit several times), and at the mean while the lines for next transactions can get calculated.

Here is the caller graph for this function:

## iDriver_writeFramebuffer()

esp_err_t iDriver_writeFramebuffer | ( | uint16_t *** | pu16Framebuffer | ) |

write framebuffer to LCD via SPI

Parameters

  uint16_t | ***pu16Framebuffer

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

Here is the call graph for this function:
Here is the caller graph for this function:

## vDriver_getFramenufferPerLine()

void vDriver_getFramenufferPerLine | ( | uint16_t * | pu16Dest,
|  | uint16_t | u16Line,
|  | uint16_t | u16Linect,
|  | uint16_t *** | pu16Framebuffer
| ) |  |

Get the pixel data for a set of lines (with implied line size of 320)

Parameters

  uint16_t | *pu16Dest
  uint16_t | u16Line
  uint16_t | u16Linect
  uint16_t | ***pu16Framebuffer

Returns
  void

Author
  Hendrik Schutter

Date
  3.11.2020

Here is the caller graph for this function:

## vDriver_GetId()

uint32_t vDriver_GetId | ( | void |  | ) |

get LCD driver chip id

Parameters

  void |

Returns
  uint32_t

Author
  Hendrik Schutter

Date
  3.11.2020

Here is the call graph for this function:
Here is the caller graph for this function:

## vDriver_init()

esp_err_t vDriver_init | ( | void |  | ) |

Initialize the driver.

Parameters

  void |

Returns
  esp error code

Author
  Hendrik Schutter

Date
  3.11.2020

Enable backlight

Here is the call graph for this function:
Here is the caller graph for this function:

## vDriver_spiPreTransferCallback()

void vDriver_spiPreTransferCallback | ( | spi_transaction_t * | t | ) |

Pre Transfer Callback.

Parameters

  spi_transaction_t | *t

Returns
  void

Author
  Hendrik Schutter

Date
  3.11.2020

This function is called (in irq context!) just before a transmission starts. It will set the D/C line to the value indicated in the user field.

Here is the caller graph for this function:

## Variable Documentation

## calc_line

int16_t calc_line =0

## ili_init_cmds

DRAM_ATTR const lcd_init_cmd_t ili_init_cmds[]

static

## lines

uint16_t* lines[2]

## sending_line

int16_t sending_line =-1

## spi

spi_device_handle_t spi

## st_init_cmds

DRAM_ATTR const lcd_init_cmd_t st_init_cmds[]

static