Atmel Software Framework

hx8347a.c File Reference

HX8347A display controller driver.

Copyright (c) 2012-2015 Atmel Corporation. All rights reserved.

#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 void hx8347a_interface_init ( void  )
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 __always_inline uint8_t hx8347a_read_byte ( void  )
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 void hx8347a_select_register ( uint8_t  address)
static

Used to select a register within the controller.

Helper function to use for selecting a register to write to.

Parameters
addressthe 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 __always_inline void hx8347a_send_byte ( uint8_t  data)
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.

Parameters
datathe 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 __always_inline void hx8347a_write_packet ( const uint8_t *  data,
const uint32_t  length 
)
static

Helper function to write a number of bytes.

This function is used to write several bytes to the interface in one go.

Parameters
datapointer to the location of the data to write
lengththe 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().