HX8347A display controller driver.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "conf_hx8347a.h"
#include "hx8347a.h"
#include "hx8347a_regs.h"
#include <sysclk.h>
#include <gpio.h>
#include <delay.h>
Functions | |
void | hx8347a_clear_register (uint8_t address, uint8_t bitmask) |
Helper function for easier register access. More... | |
static void | hx8347a_controller_init_registers (void) |
Initialize all the display registers. More... | |
void | hx8347a_copy_pixels_from_screen (hx8347a_color_t *pixels, uint32_t count) |
Copy pixels from the screen to a pixel buffer. More... | |
void | hx8347a_copy_pixels_to_screen (const hx8347a_color_t *pixels, uint32_t count) |
Copy pixels from SRAM to the screen. More... | |
void | hx8347a_copy_progmem_pixels_to_screen (hx8347a_color_t PROGMEM_PTR_T pixels, uint32_t count) |
Copy pixels from progmem to the screen. More... | |
static __always_inline void | hx8347a_deselect_chip (void) |
Helper function to de-select the CS of the controller on the bus. More... | |
void | hx8347a_duplicate_pixel (const hx8347a_color_t color, uint32_t count) |
Write a set color to the screen. More... | |
void | hx8347a_exit_standby (void) |
Send display commands to exit standby mode. More... | |
void | hx8347a_init (void) |
Initialize the controller. More... | |
static void | hx8347a_interface_init (void) |
Initialize the hardware interface to the controller. More... | |
static __always_inline uint8_t | hx8347a_read_byte (void) |
Helper function to read a byte from an arbitrary interface. More... | |
hx8347a_color_t | hx8347a_read_gram (void) |
Read a single color from the graphical memory. More... | |
uint8_t | hx8347a_read_register (uint8_t address) |
Read the value of a specific register in the controller. More... | |
void | hx8347a_reset_display (void) |
Reset the display using the digital control interface. More... | |
static __always_inline void | hx8347a_select_chip (void) |
Helper function to select the CS of the controller on the bus. More... | |
static void | hx8347a_select_register (uint8_t address) |
Used to select a register within the controller. More... | |
static __always_inline void | hx8347a_send_byte (uint8_t data) |
Helper function to send a byte over an arbitrary interface. More... | |
void | hx8347a_set_bottom_right_limit (hx8347a_coord_t x, hx8347a_coord_t y) |
Set the display bottom right drawing limit. More... | |
void | hx8347a_set_limits (hx8347a_coord_t start_x, hx8347a_coord_t start_y, hx8347a_coord_t end_x, hx8347a_coord_t end_y) |
Set the fully display drawing limits. More... | |
void | hx8347a_set_orientation (uint8_t flags) |
Set the display orientation. More... | |
void | hx8347a_set_register (uint8_t address, uint8_t bitmask) |
Helper function for easier register access. More... | |
void | hx8347a_set_top_left_limit (hx8347a_coord_t x, hx8347a_coord_t y) |
Set the display top left drawing limit. More... | |
void | hx8347a_write_gram (hx8347a_color_t color) |
Write the graphical memory with a single color pixel. More... | |
static __always_inline void | hx8347a_write_packet (const uint8_t *data, const uint32_t length) |
Helper function to write a number of bytes. More... | |
void | hx8347a_write_register (uint8_t address, uint8_t value) |
Write a specific register in the controller with a single byte. More... | |
|
static |
Initialize all the display registers.
This function will set up all the internal registers according the the manufacturer's description. What this values do are unfortunately undocumented from the manufacturer side.
References delay_ms, HX8347A_COLENDHIGH, HX8347A_COLENDLOW, HX8347A_COLSTARTHIGH, HX8347A_COLSTARTLOW, HX8347A_CYCLECTRL1, HX8347A_CYCLECTRL1_X, HX8347A_CYCLECTRL2, HX8347A_CYCLECTRL2_X, HX8347A_CYCLECTRL3, HX8347A_CYCLECTRL3_X, HX8347A_CYCLECTRL4, HX8347A_CYCLECTRL5, HX8347A_CYCLECTRL6, HX8347A_CYCLECTRL7, HX8347A_DISPCTRL1, HX8347A_DISPCTRL10, HX8347A_DISPCTRL2, HX8347A_DISPCTRL3, HX8347A_DISPCTRL4, HX8347A_DISPCTRL5, HX8347A_DISPCTRL6, HX8347A_DISPCTRL7, HX8347A_DISPCTRL8, HX8347A_DISPCTRL9, HX8347A_DISPMODECTRL, HX8347A_GAMMACTRL1, HX8347A_GAMMACTRL10, HX8347A_GAMMACTRL11, HX8347A_GAMMACTRL12, HX8347A_GAMMACTRL2, HX8347A_GAMMACTRL3, HX8347A_GAMMACTRL4, HX8347A_GAMMACTRL5, HX8347A_GAMMACTRL6, HX8347A_GAMMACTRL7, HX8347A_GAMMACTRL8, HX8347A_GAMMACTRL9, HX8347A_INTERNAL28, HX8347A_MEMACCESSCTRL, HX8347A_OSCCTRL1, HX8347A_POWERCTRL1, HX8347A_POWERCTRL2, HX8347A_POWERCTRL3, HX8347A_POWERCTRL4, HX8347A_POWERCTRL5, HX8347A_POWERCTRL6, HX8347A_ROWENDHIGH, HX8347A_ROWENDLOW, HX8347A_ROWSTARTHIGH, HX8347A_ROWSTARTLOW, HX8347A_VCOMCTRL1, HX8347A_VCOMCTRL2, HX8347A_VCOMCTRL3, and hx8347a_write_register().
Referenced by hx8347a_init().
|
static |
Helper function to de-select the CS of the controller on the bus.
References gpio_set_pin_high.
Referenced by hx8347a_copy_pixels_from_screen(), hx8347a_copy_pixels_to_screen(), hx8347a_copy_progmem_pixels_to_screen(), hx8347a_duplicate_pixel(), hx8347a_read_gram(), hx8347a_read_register(), hx8347a_select_register(), hx8347a_write_gram(), and hx8347a_write_register().
|
static |
Initialize the hardware interface to the controller.
This will initialize the module used for communication with the controller. Currently supported interface by this driver is the SPI interface trough either the SPI module in master mode or the USART in Master SPI mode. Configurations has to be done in the conf_hx8347a.h file.
References usart_spi_device::id, spi_device::id, spi_master_init(), spi_master_setup_device(), SPI_MODE_3, usart_spi_init(), and usart_spi_setup_device().
Referenced by hx8347a_init().
|
static |
Helper function to read a byte from an arbitrary interface.
This function is used to hide what interface is used by the driver, e.g. the driver does not need to know if USART in SPI mode is used or the native SPI module.
References data, spi_is_rx_full(), spi_read_single(), spi_write_single(), usart_spi_read_packet(), and usart_spi_read_single().
Referenced by hx8347a_copy_pixels_from_screen(), hx8347a_read_gram(), and hx8347a_read_register().
|
static |
Helper function to select the CS of the controller on the bus.
References gpio_set_pin_low.
Referenced by hx8347a_copy_pixels_from_screen(), hx8347a_copy_pixels_to_screen(), hx8347a_copy_progmem_pixels_to_screen(), hx8347a_duplicate_pixel(), hx8347a_read_gram(), hx8347a_read_register(), hx8347a_select_register(), hx8347a_write_gram(), and hx8347a_write_register().
|
static |
Used to select a register within the controller.
Helper function to use for selecting a register to write to.
address | the address of the register to select |
References hx8347a_deselect_chip(), hx8347a_select_chip(), hx8347a_send_byte(), and HX8347A_START_WRITEIDX.
Referenced by hx8347a_copy_pixels_from_screen(), hx8347a_copy_pixels_to_screen(), hx8347a_copy_progmem_pixels_to_screen(), hx8347a_duplicate_pixel(), hx8347a_read_gram(), hx8347a_read_register(), hx8347a_write_gram(), and hx8347a_write_register().
|
static |
Helper function to send a byte over an arbitrary interface.
This function is used to hide what interface is used by the driver, e.g. the driver does not need to know if USART in SPI mode is used or the native SPI module.
data | the byte to be transfered |
References spi_is_tx_ok(), spi_write_single(), usart_spi_write_packet(), and usart_spi_write_single().
Referenced by hx8347a_copy_pixels_from_screen(), hx8347a_copy_pixels_to_screen(), hx8347a_copy_progmem_pixels_to_screen(), hx8347a_duplicate_pixel(), hx8347a_read_gram(), hx8347a_read_register(), hx8347a_select_register(), hx8347a_write_gram(), and hx8347a_write_register().
|
static |
Helper function to write a number of bytes.
This function is used to write several bytes to the interface in one go.
data | pointer to the location of the data to write |
length | the number of bytes to write |
References spi_write_packet(), and usart_spi_write_packet().
Referenced by hx8347a_copy_pixels_to_screen(), and hx8347a_duplicate_pixel().