Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ILI9341 Display Controller Component Driver

See Quick Start Guide for the ILI9341 Display Controller Component Driver.

This is the low level component driver for the ILI9341 display controller. It provides basic functions for initializing, writing and reading the controller. In addition to hardware control and use of the LCD controller internal functions.

Warning
This component driver is not reentrant and can not be used in interrupt service routines without extra care.

Before writing data to the display call ili9341_init() which will set up the physical interface and the display. A configuration file conf_ili9341.h is needed to define which interface to use, pin connections and communication speed.

An example conf_ili9341.h file for the XMEGA could look like:

#define CONF_ILI9341_USART_SPI &USARTC0
#define CONF_ILI9341_CLOCK_SPEED 8000000UL
#define CONF_ILI9341_CS_PIN IOPORT_CREATE_PIN(PORTC, 5)
#define CONF_ILI9341_DC_PIN IOPORT_CREATE_PIN(PORTC, 4)
#define CONF_ILI9341_BACKLIGHT_PIN IOPORT_CREATE_PIN(PORTA, 5)
#define CONF_ILI9341_RESET_PIN IOPORT_CREATE_PIN(PORTA, 7)

Dependencies

This component driver depends on the following modules:

Modules

 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the ILI9341 Display Controller Component Driver.
 

Macros

#define ILI9341_COLOR(r, g, b)
 This macro generates a 16-bit native color for the display from a 24-bit RGB value. More...
 
#define ILI9341_DEFAULT_HEIGHT   240
 Height of display using default orientation. More...
 
#define ILI9341_DEFAULT_WIDTH   320
 Width of display using default orientation. More...
 
#define ILI9341_SWITCH_XY_HEIGHT   320
 Height of display using swapped X/Y orientation. More...
 
#define ILI9341_SWITCH_XY_WIDTH   240
 Width of display using swapped X/Y orientation. More...
 

Typedefs

typedef uint16_t ili9341_color_t
 Type define for an integer type large enough to store a pixel color. More...
 
typedef int16_t ili9341_coord_t
 Type define for an integer type large enough to store a pixel coordinate. More...
 

Display orientation flags

#define ILI9341_FLIP_X   1
 Bit mask for flipping X for ili9341_set_orientation() More...
 
#define ILI9341_FLIP_Y   2
 Bit mask for flipping Y for ili9341_set_orientation() More...
 
#define ILI9341_SWITCH_XY   4
 Bit mask for swapping X and Y for ili9341_set_orientation() More...
 

Controller primitive graphical functions

ili9341_color_t ili9341_read_gram (void)
 Read a single color from the graphical memory. More...
 
void ili9341_write_gram (ili9341_color_t color)
 Write the graphical memory with a single color pixel. More...
 
void ili9341_set_top_left_limit (ili9341_coord_t x, ili9341_coord_t y)
 Set the display top left drawing limit. More...
 
void ili9341_set_bottom_right_limit (ili9341_coord_t x, ili9341_coord_t y)
 Set the display bottom right drawing limit. More...
 
void ili9341_set_limits (ili9341_coord_t start_x, ili9341_coord_t start_y, ili9341_coord_t end_x, ili9341_coord_t end_y)
 Set the full display drawing limits. More...
 
void ili9341_set_orientation (uint8_t flags)
 Sets the orientation of the display data. More...
 
void ili9341_copy_pixels_to_screen (const ili9341_color_t *pixels, uint32_t count)
 Copy pixels from SRAM to the screen. More...
 
void ili9341_copy_pixels_from_screen (ili9341_color_t *pixels, uint32_t count)
 Copy pixels from the screen to a pixel buffer. More...
 
void ili9341_duplicate_pixel (const ili9341_color_t color, uint32_t count)
 Set a given number of pixels to the same color. More...
 

Controller and display initialization and management

void ili9341_init (void)
 Initialize the controller. More...
 
static void ili9341_backlight_on (void)
 Function to turn on the display back light. More...
 
static void ili9341_backlight_off (void)
 Function to turn off the display back light. More...
 

#define ILI9341_COLOR (   r,
  g,
  b 
)
Value:
Swap16((((uint16_t)b) >> 3) |\
((((uint16_t)g) << 3) & 0x07E0) |\
((((uint16_t)r) << 8) & 0xf800))
JOCTET b[APPN_DATA_LEN]
Definition: jdmarker.c:693
#define Swap16(u16)
Toggles the endianism of u16 (by swapping its bytes).
Definition: compiler.h:1155

This macro generates a 16-bit native color for the display from a 24-bit RGB value.

Referenced by ili9341_copy_pixels_from_screen(), and ili9341_read_gram().

#define ILI9341_DEFAULT_HEIGHT   240

Height of display using default orientation.

Referenced by gfx_ili9341_init(), gfx_ili9341_set_orientation(), and ili9341_controller_init_registers().

#define ILI9341_DEFAULT_WIDTH   320

Width of display using default orientation.

Referenced by gfx_ili9341_init(), gfx_ili9341_set_orientation(), and ili9341_controller_init_registers().

#define ILI9341_FLIP_X   1

Bit mask for flipping X for ili9341_set_orientation()

Referenced by ili9341_set_orientation().

#define ILI9341_FLIP_Y   2

Bit mask for flipping Y for ili9341_set_orientation()

Referenced by ili9341_set_orientation().

#define ILI9341_SWITCH_XY   4

Bit mask for swapping X and Y for ili9341_set_orientation()

Referenced by ili9341_set_orientation().

#define ILI9341_SWITCH_XY_HEIGHT   320

Height of display using swapped X/Y orientation.

Referenced by gfx_ili9341_set_orientation().

#define ILI9341_SWITCH_XY_WIDTH   240

Width of display using swapped X/Y orientation.

Referenced by gfx_ili9341_set_orientation().

typedef uint16_t ili9341_color_t

Type define for an integer type large enough to store a pixel color.

typedef int16_t ili9341_coord_t

Type define for an integer type large enough to store a pixel coordinate.

static void ili9341_backlight_off ( void  )
inlinestatic

Function to turn off the display back light.

Use this function to simply set the pin controlling the back light low to turn off the back light.

References ioport_set_pin_level().

static void ili9341_backlight_on ( void  )
inlinestatic

Function to turn on the display back light.

Use this function to simply set the pin controlling the back light high to turn on the back light.

Note
It is up to the user application if other means of controlling this pin should be used, e.g. a PWM signal to be able to dim the display.

References ioport_set_pin_level().

Referenced by gfx_ili9341_init().

void ili9341_copy_pixels_from_screen ( ili9341_color_t pixels,
uint32_t  count 
)

Copy pixels from the screen to a pixel buffer.

Use this function to copy pixels from the display to an internal SRAM buffer.

Limits have to be set prior to calling this function, e.g.:

Parameters
pixelsPointer to the pixel buffer to read to
countNumber of pixels to read

References Assert, ILI9341_CMD_MEMORY_READ, ILI9341_COLOR, ili9341_deselect_chip(), ili9341_read_byte(), and ili9341_send_command().

void ili9341_copy_pixels_to_screen ( const ili9341_color_t pixels,
uint32_t  count 
)

Copy pixels from SRAM to the screen.

Used to copy a large quantitative of data to the screen in one go.

Limits have to be set prior to calling this function, e.g.:

Parameters
pixelsPointer to the pixel data
countNumber of pixels to copy to the screen

References Assert, i, ILI9341_CMD_MEMORY_WRITE, ili9341_deselect_chip(), ili9341_send_byte(), ili9341_send_command(), ili9341_wait_for_send_done(), le16_to_cpu, min, NULL, pdca_disable(), pdca_enable(), pdca_reload_channel(), pdca_set_peripheral_select(), pdca_set_transfer_size(), and PDCA_TRANSFER_SIZE_BYTE.

void ili9341_duplicate_pixel ( const ili9341_color_t  color,
uint32_t  count 
)

Set a given number of pixels to the same color.

Use this function to write a certain number of pixels to the same color within a set limit.

Limits have to be set prior to calling this function, e.g.:

Parameters
colorThe color to write to the display
countThe number of pixels to write with this color

References Assert, i, ILI9341_CMD_MEMORY_WRITE, ili9341_deselect_chip(), ili9341_send_byte(), ili9341_send_command(), ili9341_wait_for_send_done(), le16_to_cpu, min, NULL, pdca_disable(), pdca_enable(), pdca_reload_channel(), pdca_set_peripheral_select(), pdca_set_transfer_size(), and PDCA_TRANSFER_SIZE_BYTE.

void ili9341_init ( void  )

Initialize the controller.

Used to initialize the ILI9341 display controller by setting up the hardware interface, and setting up the controller according to the manufacturer's description. It also set up the screen orientation to the default state (portrait).

References ili9341_controller_init_registers(), ili9341_exit_standby(), ili9341_interface_init(), and ili9341_reset_display().

Referenced by gfx_ili9341_init().

ili9341_color_t ili9341_read_gram ( void  )

Read a single color from the graphical memory.

Use this function to read a color from the graphical memory of the controller.

Limits have to be set prior to calling this function, e.g.:

Return values
ili9341_color_tThe read color pixel

References ILI9341_CMD_MEMORY_READ, ILI9341_COLOR, ili9341_deselect_chip(), ili9341_read_byte(), and ili9341_send_command().

Referenced by gfx_ili9341_get_pixel().

void ili9341_set_bottom_right_limit ( ili9341_coord_t  x,
ili9341_coord_t  y 
)

Set the display bottom right drawing limit.

Use this function to set the bottom right corner of the drawing limit box.

Parameters
xThe x coordinate of the bottom right corner
yThe y coordinate of the bottom right corner

References ili9341_send_draw_limits(), limit_end_x, limit_end_y, x, and y.

void ili9341_set_limits ( ili9341_coord_t  start_x,
ili9341_coord_t  start_y,
ili9341_coord_t  end_x,
ili9341_coord_t  end_y 
)

Set the full display drawing limits.

Use this function to set the full drawing limit box.

Parameters
start_xThe x coordinate of the top left corner
start_yThe y coordinate of the top left corner
end_xThe x coordinate of the bottom right corner
end_yThe y coordinate of the bottom right corner

References ili9341_send_draw_limits(), limit_end_x, limit_end_y, limit_start_x, and limit_start_y.

Referenced by ili9341_controller_init_registers().

void ili9341_set_orientation ( uint8_t  flags)

Sets the orientation of the display data.

Configures the display for a given orientation, including mirroring and/or screen rotation.

Parameters
flagsOrientation flags to use, see ILI9341_FLIP_X, ILI9341_FLIP_Y and ILI9341_SWITCH_XY.

References ILI9341_CMD_MEMORY_ACCESS_CONTROL, ili9341_deselect_chip(), ILI9341_FLIP_X, ILI9341_FLIP_Y, ili9341_send_byte(), ili9341_send_command(), ILI9341_SWITCH_XY, and ili9341_wait_for_send_done().

Referenced by gfx_ili9341_set_orientation(), and ili9341_controller_init_registers().

void ili9341_set_top_left_limit ( ili9341_coord_t  x,
ili9341_coord_t  y 
)

Set the display top left drawing limit.

Use this function to set the top left limit of the drawing limit box.

Parameters
xThe x coordinate of the top left corner
yThe y coordinate of the top left corner

References ili9341_send_draw_limits(), limit_start_x, limit_start_y, x, and y.

void ili9341_write_gram ( ili9341_color_t  color)

Write the graphical memory with a single color pixel.

Use this function to write a single color pixel to the controller memory.

Limits have to be set prior to calling this function, e.g.:

Parameters
colorThe color pixel to write to the screen

References Assert, ILI9341_CMD_MEMORY_WRITE, ili9341_deselect_chip(), ili9341_send_byte(), ili9341_send_command(), and ili9341_wait_for_send_done().

Referenced by gfx_ili9341_draw_line_pixel(), and gfx_ili9341_draw_pixel().