Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Display - ILI93XX Controller

Low-level driver for the ILI93XX LCD controller.

This is a driver for LCD with ili93xx.

This driver provides access to the main features of the ILI93XX controller. Now ILI9325 and ILI9341 are supported.

Now this driver supports ili9325 and ili9341.This component is custom LCD used for SAM4E-EK. The driver provides functions for initializtion and control of the LCD.

See Quick Start Guide for the ILI93XX.

Modules

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

Data Structures

struct  ili93xx_font
 Font structure. More...
 
struct  ili93xx_opt_t
 Input parameters when initializing ili9325 driver. More...
 

Macros

#define COLOR_AZUR   (0xF0FFFFu)
 
#define COLOR_BEIGE   (0xF5F5DCu)
 
#define COLOR_BLACK   (0x000000u)
 Define EBI access for ILI93xx 8-bit System Interface. More...
 
#define COLOR_BLUE   (0x0000FFu)
 
#define COLOR_BLUEVIOLET   (0x8A2BE2u)
 
#define COLOR_BROWN   (0xA52A2Au)
 
#define COLOR_CYAN   (0x00FFFFu)
 
#define COLOR_DARKBLUE   (0x00008Bu)
 
#define COLOR_DARKCYAN   (0x008B8Bu)
 
#define COLOR_DARKGRAY   (0xA9A9A9u)
 
#define COLOR_DARKGREEN   (0x006400u)
 
#define COLOR_DARKRED   (0x800000u)
 
#define COLOR_DARKVIOLET   (0x9400D3u)
 
#define COLOR_GOLD   (0xFFD700u)
 
#define COLOR_GRAY   (0x808080u)
 
#define COLOR_GREEN   (0x00FF00u)
 
#define COLOR_GREENYELLOW   (0xADFF2Fu)
 
#define COLOR_INDIGO   (0x4B0082u)
 
#define COLOR_LIGHTBLUE   (0xADD8E6u)
 
#define COLOR_LIGHTCYAN   (0xE0FFFFu)
 
#define COLOR_LIGHTGREEN   (0x90EE90u)
 
#define COLOR_LIGHTGREY   (0xD3D3D3u)
 
#define COLOR_MAGENTA   (0xFF00FFu)
 
#define COLOR_NAVY   (0x000080u)
 
#define COLOR_OLIVE   (0x808000u)
 
#define COLOR_ORANGE   (0xFFA500u)
 
#define COLOR_RED   (0xFF0000u)
 
#define COLOR_SIENNA   (0xA0522Du)
 
#define COLOR_SILVER   (0xC0C0C0u)
 
#define COLOR_SKYBLUE   (0x87CEEBu)
 
#define COLOR_SNOW   (0xFFFAFAu)
 
#define COLOR_TOMATO   (0xFF6347u)
 
#define COLOR_TURQUOISE   (0x40E0D0u)
 
#define COLOR_VIOLET   (0xEE82EEu)
 
#define COLOR_WHITE   (0xFFFFFFu)
 
#define COLOR_YELLOW   (0xFFFF00u)
 
#define COLOR_YELLOWGREEN   (0x9ACD32u)
 
#define DEVICE_TYPE_ILI9325   1
 
#define DEVICE_TYPE_ILI9341   2
 
#define ILI9325_DEVICE_CODE   (0x9325u)
 ili93xx ID code More...
 
#define ILI9341_DEVICE_CODE   (0x9341u)
 
#define ILI93XX_COLOR(r, g, b)   ((r << 16) | (g << 8) | b)
 This macro generates a 16-bit native color for the display from a 24-bit RGB value. More...
 
#define ILI93XX_FLIP_X   1
 Bit mask for flipping X for ili93xx_set_orientation() More...
 
#define ILI93XX_FLIP_Y   2
 Bit mask for flipping Y for ili93xx_set_orientation() More...
 
#define ILI93XX_LCD_HEIGHT   320
 
#define ILI93XX_LCD_WIDTH   240
 ili93xx screen size More...
 
#define ILI93XX_SWITCH_XY   4
 Bit mask for swapping X and Y for ili93xx_set_orientation() More...
 
#define ILI93XX_SWITCH_XY_HEIGHT   320
 
#define ILI93XX_SWITCH_XY_WIDTH   240
 
#define LCD_DATA_CACHE_SIZE   ILI93XX_LCD_WIDTH
 Pixel cache used to speed up communication. More...
 

Typedefs

typedef ili93xx_color_t gfx_color_t
 
typedef int16_t gfx_coord_t
 
typedef uint32_t ili93xx_color_t
 Type define for an integer type large enough to store a pixel color. More...
 
typedef int16_t ili93xx_coord_t
 Type define for an integer type large enough to store a pixel coordinate. More...
 

Enumerations

enum  ili93xx_display_direction {
  LANDSCAPE = 0,
  PORTRAIT = 1
}
 Display direction option. More...
 
enum  ili93xx_scan_direction {
  V_INCREASE = 0,
  V_DEREASE = 1
}
 Scan direction option. More...
 
enum  ili93xx_shift_direction {
  H_INCREASE = 0,
  H_DECREASE = 1
}
 Shift direction option. More...
 

Functions

static void ili93xx_check_box_coordinates (uint32_t *p_ul_x1, uint32_t *p_ul_y1, uint32_t *p_ul_x2, uint32_t *p_ul_y2)
 Check box coordinates. More...
 
void ili93xx_copy_pixels_from_screen (ili93xx_color_t *pixels, uint32_t count)
 Copy pixels from the screen to a pixel buffer. More...
 
void ili93xx_copy_pixels_to_screen (const ili93xx_color_t *pixels, uint32_t count)
 Copy pixels from SRAM to the screen. More...
 
void ili93xx_copy_raw_pixel_24bits_to_screen (const uint8_t *raw_pixels, uint32_t count)
 Copy pixels from SRAM to the screen. More...
 
static void ili93xx_delay (uint32_t ul_ms)
 Delay function. More...
 
uint8_t ili93xx_device_type (void)
 get the device type. More...
 
uint8_t ili93xx_device_type_identify (void)
 Read device ID to idenfity the device ILI9325 device ID locates in Device Code Read (R00h) register. More...
 
void ili93xx_disable_scroll (void)
 Disable the scrolling feature. More...
 
void ili93xx_display_off (void)
 Turn off the LCD. More...
 
void ili93xx_display_on (void)
 Turn on the LCD. More...
 
static void ili93xx_draw_char (uint32_t ul_x, uint32_t ul_y, uint8_t uc_c)
 Draw an ASCII character on LCD. More...
 
uint32_t ili93xx_draw_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r)
 Draw a circle on LCD. More...
 
uint32_t ili93xx_draw_filled_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r)
 Draw a filled circle on LCD. More...
 
void ili93xx_draw_filled_rectangle (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a filled rectangle on LCD. More...
 
void ili93xx_draw_line (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a line on LCD. More...
 
static void ili93xx_draw_line_bresenham (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a line on LCD, which is not horizontal or vertical. More...
 
uint32_t ili93xx_draw_pixel (uint32_t ul_x, uint32_t ul_y)
 Draw a pixel on LCD. More...
 
void ili93xx_draw_pixmap (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height, const ili93xx_color_t *p_ul_pixmap)
 Draw a pixmap on LCD. More...
 
void ili93xx_draw_rectangle (uint32_t ul_x1, uint32_t ul_y1, uint32_t ul_x2, uint32_t ul_y2)
 Draw a rectangle on LCD. More...
 
void ili93xx_draw_string (uint32_t ul_x, uint32_t ul_y, const uint8_t *p_str)
 Draw a string on LCD. More...
 
void ili93xx_duplicate_pixel (const ili93xx_color_t color, uint32_t count)
 Set a given number of pixels to the same color. More...
 
void ili93xx_enable_scroll (void)
 Enable the scrolling feature. More...
 
void ili93xx_fill (ili93xx_color_t ul_color)
 Fill the LCD buffer with the specified color. More...
 
uint32_t ili93xx_get_lcd_type (void)
 
ili93xx_color_t ili93xx_get_pixel (uint32_t ul_x, uint32_t ul_y)
 Get a pixel from LCD. More...
 
uint32_t ili93xx_init (struct ili93xx_opt_t *p_opt)
 Initialize the ILI93XX lcd driver. More...
 
ili93xx_color_t ili93xx_read_gram (void)
 Read a single color from the graphical memory. More...
 
static uint32_t ili93xx_read_ram (void)
 Read data to LCD GRAM for ili93xx. More...
 
static void ili93xx_read_ram_prepare (void)
 Prepare to read GRAM data for ili93xx. More...
 
static void ili93xx_read_register (uint8_t uc_reg, uint8_t *p_data, uint8_t uc_datacnt)
 Read data from LCD Register. More...
 
void ili93xx_scroll (int32_t ul_lines)
 Scroll up/down for the number of specified lines. More...
 
static void ili93xx_send_draw_limits (const bool send_end_limits)
 Helper function to send the drawing limits (boundaries) to the display. More...
 
void ili93xx_set_bottom_right_limit (ili93xx_coord_t x, ili93xx_coord_t y)
 Set the display bottom right drawing limit. More...
 
void ili93xx_set_cursor_position (uint16_t us_x, uint16_t us_y)
 Set cursor of LCD screen. More...
 
void ili93xx_set_display_direction (enum ili93xx_display_direction e_dd, enum ili93xx_shift_direction e_shd, enum ili93xx_scan_direction e_scd)
 Set display direction. More...
 
void ili93xx_set_foreground_color (ili93xx_color_t ul_color)
 Set foreground color. More...
 
void ili93xx_set_limits (ili93xx_coord_t start_x, ili93xx_coord_t start_y, ili93xx_coord_t end_x, ili93xx_coord_t end_y)
 Set the full display drawing limits. More...
 
void ili93xx_set_orientation (uint8_t flags)
 Sets the orientation of the display data. More...
 
void ili93xx_set_top_left_limit (ili93xx_coord_t x, ili93xx_coord_t y)
 Set the display top left drawing limit. More...
 
void ili93xx_set_window (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height)
 Set display window. More...
 
void ili93xx_vscroll_area_define (uint16_t us_tfa, uint16_t us_vsa, uint16_t us_bfa)
 Vertical Scroll area definition for ili9341. More...
 
void ili93xx_write_gram (ili93xx_color_t color)
 Write the graphical memory with a single color pixel. More...
 
static void ili93xx_write_ram (ili93xx_color_t ul_color)
 Write data to LCD GRAM. More...
 
static void ili93xx_write_ram_buffer (const ili93xx_color_t *p_ul_buf, uint32_t ul_size)
 Write multiple data in buffer to LCD controller for ili93xx. More...
 
static void ili93xx_write_ram_prepare (void)
 Prepare to write GRAM data for ili93xx. More...
 
static void ili93xx_write_register (uint8_t uc_reg, uint8_t *p_data, uint8_t uc_datacnt)
 Write data to LCD Register for ili93xx. More...
 
static void ili93xx_write_register_word (uint8_t uc_reg, uint16_t us_data)
 Write a word (16bits)to LCD Register. More...
 

Variables

static uint8_t g_uc_device_type = 0
 Device type. More...
 
static uint32_t g_ul_lcd_x_length = ILI93XX_LCD_WIDTH
 LCD X-axis and Y-axis length. More...
 
static uint32_t g_ul_lcd_y_length = ILI93XX_LCD_HEIGHT
 
static ili93xx_color_t g_ul_pixel_cache [LCD_DATA_CACHE_SIZE]
 
struct ili93xx_font gfont = {10, 14}
 Global variable describing the font size used by the driver. More...
 
static volatile ili93xx_coord_t limit_end_x
 
static volatile ili93xx_coord_t limit_end_y
 
static volatile ili93xx_coord_t limit_start_x
 
static volatile ili93xx_coord_t limit_start_y
 
const uint8_t p_uc_charset10x14 []
 Character set table for font 10x14 Coding format: Char height is 14 bits, which is coded using 2 bytes per column (2 unused bits). More...
 

#define COLOR_AZUR   (0xF0FFFFu)
#define COLOR_BEIGE   (0xF5F5DCu)
#define COLOR_BLACK   (0x000000u)

Define EBI access for ILI93xx 8-bit System Interface.

RGB 24-bits color table definition (RGB888).

#define COLOR_BLUE   (0x0000FFu)
#define COLOR_BLUEVIOLET   (0x8A2BE2u)
#define COLOR_BROWN   (0xA52A2Au)
#define COLOR_CYAN   (0x00FFFFu)
#define COLOR_DARKBLUE   (0x00008Bu)
#define COLOR_DARKCYAN   (0x008B8Bu)
#define COLOR_DARKGRAY   (0xA9A9A9u)
#define COLOR_DARKGREEN   (0x006400u)
#define COLOR_DARKRED   (0x800000u)
#define COLOR_DARKVIOLET   (0x9400D3u)
#define COLOR_GOLD   (0xFFD700u)
#define COLOR_GRAY   (0x808080u)
#define COLOR_GREEN   (0x00FF00u)
#define COLOR_GREENYELLOW   (0xADFF2Fu)
#define COLOR_INDIGO   (0x4B0082u)
#define COLOR_LIGHTBLUE   (0xADD8E6u)
#define COLOR_LIGHTCYAN   (0xE0FFFFu)
#define COLOR_LIGHTGREEN   (0x90EE90u)
#define COLOR_LIGHTGREY   (0xD3D3D3u)
#define COLOR_MAGENTA   (0xFF00FFu)
#define COLOR_NAVY   (0x000080u)
#define COLOR_OLIVE   (0x808000u)
#define COLOR_ORANGE   (0xFFA500u)
#define COLOR_RED   (0xFF0000u)
#define COLOR_SIENNA   (0xA0522Du)
#define COLOR_SILVER   (0xC0C0C0u)
#define COLOR_SKYBLUE   (0x87CEEBu)
#define COLOR_SNOW   (0xFFFAFAu)
#define COLOR_TOMATO   (0xFF6347u)
#define COLOR_TURQUOISE   (0x40E0D0u)
#define COLOR_VIOLET   (0xEE82EEu)
#define COLOR_WHITE   (0xFFFFFFu)
#define COLOR_YELLOW   (0xFFFF00u)
#define COLOR_YELLOWGREEN   (0x9ACD32u)
#define ILI9325_DEVICE_CODE   (0x9325u)

ili93xx ID code

#define ILI9341_DEVICE_CODE   (0x9341u)
#define ILI93XX_COLOR (   r,
  g,
 
)    ((r << 16) | (g << 8) | b)

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

#define ILI93XX_FLIP_X   1

Bit mask for flipping X for ili93xx_set_orientation()

Referenced by ili93xx_set_orientation().

#define ILI93XX_FLIP_Y   2

Bit mask for flipping Y for ili93xx_set_orientation()

Referenced by ili93xx_set_orientation().

#define ILI93XX_SWITCH_XY   4

Bit mask for swapping X and Y for ili93xx_set_orientation()

Referenced by ili93xx_set_orientation().

#define ILI93XX_SWITCH_XY_HEIGHT   320
#define ILI93XX_SWITCH_XY_WIDTH   240
#define LCD_DATA_CACHE_SIZE   ILI93XX_LCD_WIDTH

Pixel cache used to speed up communication.

Referenced by ili93xx_draw_filled_rectangle(), and ili93xx_set_foreground_color().

typedef int16_t gfx_coord_t
typedef uint32_t ili93xx_color_t

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

typedef int16_t ili93xx_coord_t

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

Display direction option.

Enumerator
LANDSCAPE 
PORTRAIT 

Scan direction option.

Enumerator
V_INCREASE 
V_DEREASE 

Shift direction option.

Enumerator
H_INCREASE 
H_DECREASE 

static void ili93xx_check_box_coordinates ( uint32_t *  p_ul_x1,
uint32_t *  p_ul_y1,
uint32_t *  p_ul_x2,
uint32_t *  p_ul_y2 
)
static

Check box coordinates.

Parameters
p_ul_x1X coordinate of upper-left corner on LCD.
p_ul_y1Y coordinate of upper-left corner on LCD.
p_ul_x2X coordinate of lower-right corner on LCD.
p_ul_y2Y coordinate of lower-right corner on LCD.

References g_ul_lcd_x_length, and g_ul_lcd_y_length.

Referenced by ili93xx_draw_filled_rectangle(), ili93xx_draw_pixmap(), and ili93xx_draw_rectangle().

void ili93xx_copy_pixels_from_screen ( ili93xx_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.

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

Remove warnings

References UNUSED.

void ili93xx_copy_pixels_to_screen ( const ili93xx_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.

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

Sanity check to make sure that the pixel count is not zero

References Assert, DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, and ILI9341_CMD_WRITE_MEMORY_CONTINUE.

void ili93xx_copy_raw_pixel_24bits_to_screen ( const uint8_t *  raw_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.

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

Sanity check to make sure that the pixel count is not zero

References Assert, DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, and ILI9341_CMD_WRITE_MEMORY_CONTINUE.

static void ili93xx_delay ( uint32_t  ul_ms)
static

Delay function.

Referenced by ili93xx_init().

uint8_t ili93xx_device_type ( void  )

get the device type.

References g_uc_device_type.

Referenced by gfx_draw_bmpfile(), run_test_control_setting(), and run_test_init().

uint8_t ili93xx_device_type_identify ( void  )

Read device ID to idenfity the device ILI9325 device ID locates in Device Code Read (R00h) register.

   ILI9341 device ID locates in Read ID4 (RD3h) register.
Returns
0 if secceed in identifying device; otherwise fails.

Read ID4 (RD4h) register to get device code for ILI9341

Driver Code Read (R00h) for ILI9325

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_DEVICE_CODE, ILI9325_DEVICE_CODE_REG, ILI9341_CMD_READ_ID4, ILI9341_DEVICE_CODE, and ili93xx_read_register().

Referenced by ili93xx_init().

static void ili93xx_draw_char ( uint32_t  ul_x,
uint32_t  ul_y,
uint8_t  uc_c 
)
static

Draw an ASCII character on LCD.

Parameters
ul_xX coordinate of character upper-left corner.
ul_yY coordinate of character upper-left corner.
uc_ccharacter to print.

Compute offset according of the specified ASCII character Note: the first 32 characters of the ASCII table are not handled

Compute the first and second byte offset of a column

Draw pixel on screen depending on the corresponding bit value from the charset

References ili93xx_draw_pixel(), and p_uc_charset10x14.

Referenced by ili93xx_draw_string().

uint32_t ili93xx_draw_circle ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_r 
)

Draw a circle on LCD.

Parameters
ul_xX coordinate of circle center.
ul_yY coordinate of circle center.
ul_rcircle radius.
Returns
0 if succeeds, otherwise fails.

References ili93xx_draw_pixel().

Referenced by main().

uint32_t ili93xx_draw_filled_circle ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_r 
)

Draw a filled circle on LCD.

Parameters
ul_xX coordinate of circle center.
ul_yY coordinate of circle center.
ul_rcircle radius.
Returns
0 if succeeds, otherwise fails.

References ili93xx_draw_filled_rectangle().

void ili93xx_draw_filled_rectangle ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a filled rectangle on LCD.

Parameters
ul_x1X coordinate of upper-left corner on LCD.
ul_y1Y coordinate of upper-left corner on LCD.
ul_x2X coordinate of lower-right corner on LCD.
ul_y2Y coordinate of lower-right corner on LCD.

Swap coordinates if necessary

Determine the refresh window area

Set cursor

Prepare to write in Graphic RAM

Send pixels blocks => one SPI IT / block

Send remaining pixels

Reset the refresh window area

References g_ul_lcd_x_length, g_ul_lcd_y_length, g_ul_pixel_cache, ili93xx_check_box_coordinates(), ili93xx_set_cursor_position(), ili93xx_set_window(), ili93xx_write_ram_buffer(), ili93xx_write_ram_prepare(), and LCD_DATA_CACHE_SIZE.

Referenced by gfx_task(), ili93xx_draw_filled_circle(), ili93xx_draw_line(), ili93xx_draw_rectangle(), main(), and run_test_init().

void ili93xx_draw_line ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a line on LCD.

Parameters
ul_x1X coordinate of line start.
ul_y1Y coordinate of line start.
ul_x2X coordinate of line end.
ul_y2Y coordinate of line end.

References ili93xx_draw_filled_rectangle(), and ili93xx_draw_line_bresenham().

Referenced by main().

static void ili93xx_draw_line_bresenham ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)
static

Draw a line on LCD, which is not horizontal or vertical.

Parameters
ul_x1X coordinate of line start.
ul_y1Y coordinate of line start.
ul_x2X coordinate of line end.
ul_y2Y coordinate of line endl.

References ili93xx_draw_pixel().

Referenced by ili93xx_draw_line().

uint32_t ili93xx_draw_pixel ( uint32_t  ul_x,
uint32_t  ul_y 
)

Draw a pixel on LCD.

Parameters
ul_xX coordinate of pixel.
ul_yY coordinate of pixel.
Returns
0 if succeeds, otherwise fails.

Set cursor

Prepare to write in GRAM

Prepare to write in GRAM

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, g_ul_lcd_x_length, g_ul_lcd_y_length, g_ul_pixel_cache, ili93xx_set_cursor_position(), ili93xx_set_window(), ili93xx_write_ram(), and ili93xx_write_ram_prepare().

Referenced by ili93xx_draw_char(), ili93xx_draw_circle(), ili93xx_draw_line_bresenham(), and run_test_data_read_write().

void ili93xx_draw_pixmap ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_width,
uint32_t  ul_height,
const ili93xx_color_t p_ul_pixmap 
)

Draw a pixmap on LCD.

Parameters
ul_xX coordinate of upper-left corner on LCD.
ul_yY coordinate of upper-left corner on LCD.
ul_widthwidth of the picture.
ul_heightheight of the picture.
p_ul_pixmappixmap of the image.

Swap coordinates if necessary

Determine the refresh window area

Set cursor

Prepare to write in GRAM

Reset the refresh window area

Prepare to write in GRAM

Reset the refresh window area

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, g_ul_lcd_x_length, g_ul_lcd_y_length, ili93xx_check_box_coordinates(), ili93xx_set_cursor_position(), ili93xx_set_window(), ili93xx_write_ram_buffer(), and ili93xx_write_ram_prepare().

void ili93xx_draw_rectangle ( uint32_t  ul_x1,
uint32_t  ul_y1,
uint32_t  ul_x2,
uint32_t  ul_y2 
)

Draw a rectangle on LCD.

Parameters
ul_x1X coordinate of upper-left corner on LCD.
ul_y1Y coordinate of upper-left corner on LCD.
ul_x2X coordinate of lower-right corner on LCD.
ul_y2Y coordinate of lower-right corner on LCD.

References ili93xx_check_box_coordinates(), and ili93xx_draw_filled_rectangle().

Referenced by gfx_task().

void ili93xx_draw_string ( uint32_t  ul_x,
uint32_t  ul_y,
const uint8_t *  p_str 
)

Draw a string on LCD.

Parameters
ul_xX coordinate of string top-left corner.
ul_yY coordinate of string top-left corner.
p_strString to display.

If newline, jump to the next line (font height + 2)

Draw the character and place cursor right after (font width + 2)

References ili93xx_font::height, ili93xx_draw_char(), and ili93xx_font::width.

Referenced by gfx_task(), and main().

void ili93xx_duplicate_pixel ( const ili93xx_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.

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

Sanity check to make sure that the pixel count is not zero

Write Data to GRAM (R22h)

References Assert, DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, and ILI9341_CMD_WRITE_MEMORY_CONTINUE.

void ili93xx_enable_scroll ( void  )
uint32_t ili93xx_get_lcd_type ( void  )

References g_uc_device_type.

Referenced by demo_draw_bmpfile().

ili93xx_color_t ili93xx_get_pixel ( uint32_t  ul_x,
uint32_t  ul_y 
)

Get a pixel from LCD.

Parameters
ul_xX coordinate of pixel.
ul_yY coordinate of pixel.
Returns
the pixel color.

Set cursor

Prepare to write in GRAM

Prepare to write in GRAM

References Assert, DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, g_ul_lcd_x_length, g_ul_lcd_y_length, ili93xx_read_ram(), ili93xx_read_ram_prepare(), ili93xx_set_cursor_position(), and ili93xx_set_window().

Referenced by run_test_data_read_write().

uint32_t ili93xx_init ( struct ili93xx_opt_t p_opt)

Initialize the ILI93XX lcd driver.

Note
Make sure below works have been done before calling ili93xx_init()
  1. ILI93xx related Pins have been initialized correctly.
  2. SMC has been configured correctly for access ILI93xx (8-bit system interface for now).
Parameters
p_optpointer to ILI93xx option structure.
Returns
0 if initialization succeeds, otherwise fails.

Identify the LCD driver device

Turn off LCD

Start initial sequence

Disable sleep and standby mode

Start internal OSC

Set SS bit and direction output from S720 to S1

Set 1 line inversion

Disable resizing feature

Set the back porch and front porch

Set non-display area refresh cycle ISC[3:0]

Disable FMARK function

18-bit RGB interface and writing display data by system interface

Set the output position of frame cycle

RGB interface polarity

Power on sequence

Disable sleep and standby mode

Selects the operating frequency of the step-up circuit 1,2 and Sets the ratio factor of Vci.

Set VREG1OUT voltage

Set VCOM amplitude

Enable power supply and source driver

Adjusts the constant current and Sets the factor used in the step-up circuits.

Select the operating frequency of the step-up circuit 1,2 and Sets the ratio factor of Vci

Internal reference voltage= Vci

Set VDV[4:0] for VCOM amplitude

Set VCM[5:0] for VCOMH

Set Frame Rate

Adjust the Gamma Curve

Use the high speed write mode (HWM=1) When TRI = 1, data are transferred to the internal RAM in 8-bit x 3 transfers mode via the 8-bit interface. DFM Set the mode of transferring data to the internal RAM when TRI = 1. I/D[1:0] = 11 Horizontal : increment Vertical : increment, AM=0:Horizontal

Sets the number of lines to drive the LCD at an interval of 8 lines. The scan direction is from G320 to G1

Vertical Scrolling

Disable scrolling and enable the grayscale inversion

Disable Partial Display

Panel Control

init for ILI9341

power control A configuration

power control B configuration

Pump Ratio Control configuration

Power Control 1 configuration

Power Control 2 configuration

VOM Control 1 configuration

VOM control 2 configuration

Driver Timing Control A configuration

Driver Timing Control B configuration

Memory Access Control configuration

Colmod Pixel Format Set configuation

Display Function Control

set window area

Leave sleep mode

Display on

exit with return value 1 if device type is not supported.

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, ili93xx_opt_t::foreground_color, g_uc_device_type, g_ul_lcd_x_length, g_ul_lcd_y_length, ILI9325_BASE_IMG_DISP_CTRL, ILI9325_BASE_IMG_DISP_CTRL_REV, ILI9325_DISP_CTRL1, ILI9325_DISP_CTRL1_D, ILI9325_DISP_CTRL1_DTE, ILI9325_DISP_CTRL1_GON, ILI9325_DISP_CTRL2, ILI9325_DISP_CTRL2_BP, ILI9325_DISP_CTRL2_FP, ILI9325_DISP_CTRL3, ILI9325_DISP_CTRL4, ILI9325_DRIVER_OUTPUT_CTRL1, ILI9325_DRIVER_OUTPUT_CTRL1_SS, ILI9325_DRIVER_OUTPUT_CTRL2, ILI9325_DRIVER_OUTPUT_CTRL2_GS, ILI9325_DRIVER_OUTPUT_CTRL2_NL, ILI9325_ENTRY_MODE, ILI9325_ENTRY_MODE_BGR, ILI9325_ENTRY_MODE_DFM, ILI9325_ENTRY_MODE_ID, ILI9325_ENTRY_MODE_TRI, ILI9325_FRAME_MAKER_POS, ILI9325_FRAME_RATE_AND_COLOR_CTRL, ILI9325_FRAME_RATE_AND_COLOR_CTRL_FRS, ILI9325_GAMMA_CTL1, ILI9325_GAMMA_CTL10, ILI9325_GAMMA_CTL10_VRN0, ILI9325_GAMMA_CTL10_VRN1, ILI9325_GAMMA_CTL2, ILI9325_GAMMA_CTL2_KP2, ILI9325_GAMMA_CTL2_KP3, ILI9325_GAMMA_CTL3, ILI9325_GAMMA_CTL3_KP4, ILI9325_GAMMA_CTL3_KP5, ILI9325_GAMMA_CTL4, ILI9325_GAMMA_CTL4_RP0, ILI9325_GAMMA_CTL4_RP1, ILI9325_GAMMA_CTL5, ILI9325_GAMMA_CTL5_VRP0, ILI9325_GAMMA_CTL5_VRP1, ILI9325_GAMMA_CTL6, ILI9325_GAMMA_CTL6_KN0, ILI9325_GAMMA_CTL6_KN1, ILI9325_GAMMA_CTL7, ILI9325_GAMMA_CTL7_KN2, ILI9325_GAMMA_CTL7_KN3, ILI9325_GAMMA_CTL8, ILI9325_GAMMA_CTL8_KN4, ILI9325_GAMMA_CTL8_KN5, ILI9325_GAMMA_CTL9, ILI9325_GAMMA_CTL9_RN0, ILI9325_GAMMA_CTL9_RN1, ILI9325_LCD_DRIVING_CTRL, ILI9325_LCD_DRIVING_CTRL_BC0, ILI9325_LCD_DRIVING_CTRL_BIT10, ILI9325_LCD_DRIVING_CTRL_EOR, ILI9325_PANEL_INTERFACE_CTRL1, ILI9325_PANEL_INTERFACE_CTRL1_RTNI, ILI9325_PANEL_INTERFACE_CTRL2, ILI9325_PANEL_INTERFACE_CTRL2_NOWI, ILI9325_PANEL_INTERFACE_CTRL4, ILI9325_PANEL_INTERFACE_CTRL4_DIVE, ILI9325_PANEL_INTERFACE_CTRL4_RTNE, ILI9325_PARTIAL_IMG1_AREA_END_LINE, ILI9325_PARTIAL_IMG1_AREA_START_LINE, ILI9325_PARTIAL_IMG1_DISP_POS, ILI9325_PARTIAL_IMG2_AREA_END_LINE, ILI9325_PARTIAL_IMG2_AREA_START_LINE, ILI9325_PARTIAL_IMG2_DISP_POS, ILI9325_POWER_CTRL1, ILI9325_POWER_CTRL1_AP, ILI9325_POWER_CTRL1_APE, ILI9325_POWER_CTRL1_BT, ILI9325_POWER_CTRL1_SAP, ILI9325_POWER_CTRL2, ILI9325_POWER_CTRL2_DC0, ILI9325_POWER_CTRL2_DC1, ILI9325_POWER_CTRL2_VC, ILI9325_POWER_CTRL3, ILI9325_POWER_CTRL3_PON, ILI9325_POWER_CTRL3_VRH, ILI9325_POWER_CTRL4, ILI9325_POWER_CTRL4_VDV, ILI9325_POWER_CTRL7, ILI9325_POWER_CTRL7_VCM, ILI9325_RESIZE_CTRL, ILI9325_RGB_DISP_INTERFACE_CTRL1, ILI9325_RGB_DISP_INTERFACE_CTRL2, ILI9325_START_OSC_CTRL, ILI9325_START_OSC_CTRL_EN, ILI9325_VERTICAL_SCROLL_CTRL, ILI9341_CMD_DISPLAY_FUNCTION_CTL, ILI9341_CMD_DISPLAY_ON, ILI9341_CMD_DRIVER_TIMING_CTL_A, ILI9341_CMD_DRIVER_TIMING_CTL_B, ILI9341_CMD_MEMORY_ACCESS_CONTROL, ILI9341_CMD_MEMORY_ACCESS_CONTROL_BGR, ILI9341_CMD_MEMORY_ACCESS_CONTROL_MX, ILI9341_CMD_PIXEL_FORMAT_SET, ILI9341_CMD_POWER_CONTROL_1, ILI9341_CMD_POWER_CONTROL_2, ILI9341_CMD_POWER_CONTROL_A, ILI9341_CMD_POWER_CONTROL_B, ILI9341_CMD_PUMP_RATIO_CONTROL, ILI9341_CMD_SLEEP_OUT, ILI9341_CMD_VCOM_CONTROL_1, ILI9341_CMD_VCOM_CONTROL_2, ili93xx_delay(), ili93xx_device_type_identify(), ILI93XX_LCD_HEIGHT, ILI93XX_LCD_WIDTH, ili93xx_set_cursor_position(), ili93xx_set_foreground_color(), ili93xx_set_window(), ili93xx_write_register(), ili93xx_write_register_word(), ili93xx_opt_t::ul_height, and ili93xx_opt_t::ul_width.

Referenced by gfx_ili93xx_init(), main(), and run_test_init().

ili93xx_color_t ili93xx_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.

Return values
ili93xx_color_tThe read color pixel

Write Data to GRAM (R22h)

two dummy read

data upper byte

data lower byte

Convert RGB565 to RGB888

For BGR format

Write Data to GRAM (R2Eh)

dummy read

the highest byte - R byte

the middle byte - G byte

the lowest byte - B byte

combine R, G, B byte to a color value

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, and ILI9341_CMD_MEMORY_READ.

Referenced by gfx_ili93xx_get_pixel().

static uint32_t ili93xx_read_ram ( void  )
static

Read data to LCD GRAM for ili93xx.

Note
For ili9325, because pixel data LCD GRAM is 18-bits, so convertion to RGB 24-bits will cause low color bit lose.
Returns
color 24-bits RGB color.

dummy read

data upper byte

data lower byte

Convert RGB565 to RGB888

For BGR format

dummy read

the highest byte - R byte

the middle byte - G byte

the lowest byte - B byte

combine R, G, B byte to a color value

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, and g_uc_device_type.

Referenced by ili93xx_get_pixel().

static void ili93xx_read_ram_prepare ( void  )
static

Prepare to read GRAM data for ili93xx.

Write Data to GRAM (R22h)

Write Data to GRAM (R2Eh)

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, and ILI9341_CMD_MEMORY_READ.

Referenced by ili93xx_get_pixel().

static void ili93xx_read_register ( uint8_t  uc_reg,
uint8_t *  p_data,
uint8_t  uc_datacnt 
)
static

Read data from LCD Register.

Parameters
uc_regregister address.
p_datathe pointer to the read data.
uc_datacntthe number of the read data

Referenced by ili93xx_device_type_identify().

void ili93xx_scroll ( int32_t  ul_lines)

Scroll up/down for the number of specified lines.

Parameters
ul_linesnumber of lines to scroll.

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_VERTICAL_SCROLL_CTRL, ILI9341_CMD_VERT_SCROLL_START_ADDRESS, ili93xx_write_register(), and ili93xx_write_register_word().

static void ili93xx_send_draw_limits ( const bool  send_end_limits)
inlinestatic

Helper function to send the drawing limits (boundaries) to the display.

This function is used to send the currently set upper-left and lower-right drawing limits to the display, as set through the various limit functions.

Parameters
send_end_limitsTrue to also send the lower-right drawing limits

Set Horizontal Address Start Position

Set Horizontal Address End Position

Set Vertical Address Start Position

Set Vertical Address End Position

GRAM Horizontal/Vertical Address Set (R20h, R21h)

Set Column Address Position

Set Page Address Position

Set Horizontal Address Start Position

Set Vertical Address Start Position

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_HORIZONTAL_ADDR_END, ILI9325_HORIZONTAL_ADDR_START, ILI9325_HORIZONTAL_GRAM_ADDR_SET, ILI9325_VERTICAL_ADDR_END, ILI9325_VERTICAL_ADDR_START, ILI9325_VERTICAL_GRAM_ADDR_SET, ILI9341_CMD_COLUMN_ADDRESS_SET, ILI9341_CMD_PAGE_ADDRESS_SET, ili93xx_write_register(), ili93xx_write_register_word(), limit_end_x, limit_end_y, limit_start_x, and limit_start_y.

Referenced by ili93xx_set_bottom_right_limit(), ili93xx_set_limits(), and ili93xx_set_top_left_limit().

void ili93xx_set_bottom_right_limit ( ili93xx_coord_t  x,
ili93xx_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 ili93xx_send_draw_limits(), limit_end_x, and limit_end_y.

void ili93xx_set_cursor_position ( uint16_t  us_x,
uint16_t  us_y 
)

Set cursor of LCD screen.

Parameters
us_xX coordinate of upper-left corner on LCD.
us_yY coordinate of upper-left corner on LCD.

GRAM Horizontal/Vertical Address Set (R20h, R21h)

There is no corresponding operation for ILI9341.

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_HORIZONTAL_GRAM_ADDR_SET, ILI9325_VERTICAL_GRAM_ADDR_SET, and ili93xx_write_register_word().

Referenced by gfx_draw_bmpfile(), gfx_task(), ili93xx_draw_filled_rectangle(), ili93xx_draw_pixel(), ili93xx_draw_pixmap(), ili93xx_fill(), ili93xx_get_pixel(), ili93xx_init(), and main().

void ili93xx_set_foreground_color ( ili93xx_color_t  ul_color)

Set foreground color.

Parameters
ul_colorforeground color.

Fill the cache with selected color

References g_ul_pixel_cache, and LCD_DATA_CACHE_SIZE.

Referenced by gfx_task(), ili93xx_init(), main(), run_test_data_read_write(), and run_test_init().

void ili93xx_set_limits ( ili93xx_coord_t  start_x,
ili93xx_coord_t  start_y,
ili93xx_coord_t  end_x,
ili93xx_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 ili93xx_send_draw_limits(), limit_end_x, limit_end_y, limit_start_x, and limit_start_y.

void ili93xx_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 ILI93XX_FLIP_X, ILI93XX_FLIP_Y and ILI93XX_SWITCH_XY.

References DEVICE_TYPE_ILI9325, g_uc_device_type, ILI9325_ENTRY_MODE, ILI9325_ENTRY_MODE_AM, ILI9325_ENTRY_MODE_BGR, ILI9325_ENTRY_MODE_DFM, ILI9325_ENTRY_MODE_ID, ILI9325_ENTRY_MODE_TRI, ILI9341_CMD_MEMORY_ACCESS_CONTROL, ILI93XX_FLIP_X, ILI93XX_FLIP_Y, ILI93XX_SWITCH_XY, ili93xx_write_register(), and ili93xx_write_register_word().

Referenced by gfx_ili93xx_set_orientation().

void ili93xx_set_top_left_limit ( ili93xx_coord_t  x,
ili93xx_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 ili93xx_send_draw_limits(), limit_start_x, and limit_start_y.

void ili93xx_set_window ( uint32_t  ul_x,
uint32_t  ul_y,
uint32_t  ul_width,
uint32_t  ul_height 
)

Set display window.

Parameters
ul_xHorizontal address start position
ul_yVertical address start position
ul_widthThe width of the window.
ul_heightThe height of the window.

Set Horizontal Address Start Position

Set Horizontal Address End Position

Set Vertical Address Start Position

Set Vertical Address End Position

Set Column Address Position

Set Page Address Position

References Assert, DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, g_ul_lcd_x_length, g_ul_lcd_y_length, ILI9325_HORIZONTAL_ADDR_END, ILI9325_HORIZONTAL_ADDR_START, ILI9325_VERTICAL_ADDR_END, ILI9325_VERTICAL_ADDR_START, ILI9341_CMD_COLUMN_ADDRESS_SET, ILI9341_CMD_PAGE_ADDRESS_SET, ili93xx_write_register(), and ili93xx_write_register_word().

Referenced by gfx_draw_bmpfile(), ili93xx_draw_filled_rectangle(), ili93xx_draw_pixel(), ili93xx_draw_pixmap(), ili93xx_fill(), ili93xx_get_pixel(), and ili93xx_init().

void ili93xx_vscroll_area_define ( uint16_t  us_tfa,
uint16_t  us_vsa,
uint16_t  us_bfa 
)

Vertical Scroll area definition for ili9341.

Parameters
us_tfathe top fixed area (the No. of lines)
us_vsathe height of the vetical scrolling area
us_bfathe bottom fixed area (the No. of lines)

References DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9341_CMD_VERT_SCROLL_DEFINITION, and ili93xx_write_register().

void ili93xx_write_gram ( ili93xx_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.

Parameters
colorThe color pixel to write to the screen

Write Data to GRAM (R22h)

memory write command (R2Ch)

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, and ILI9341_CMD_WRITE_MEMORY_CONTINUE.

Referenced by gfx_ili93xx_draw_line_pixel(), and gfx_ili93xx_draw_pixel().

static void ili93xx_write_ram ( ili93xx_color_t  ul_color)
static

Write data to LCD GRAM.

Parameters
ul_color24-bits RGB color.

Referenced by ili93xx_draw_pixel(), ili93xx_fill(), and ili93xx_write_ram_buffer().

static void ili93xx_write_ram_buffer ( const ili93xx_color_t p_ul_buf,
uint32_t  ul_size 
)
static

Write multiple data in buffer to LCD controller for ili93xx.

Parameters
p_ul_bufdata buffer.
ul_sizesize in pixels.

References ili93xx_write_ram().

Referenced by ili93xx_draw_filled_rectangle(), and ili93xx_draw_pixmap().

static void ili93xx_write_ram_prepare ( void  )
static

Prepare to write GRAM data for ili93xx.

Write Data to GRAM (R22h)

memory write command (R2Ch)

References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, g_uc_device_type, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, and ILI9341_CMD_WRITE_MEMORY_CONTINUE.

Referenced by ili93xx_draw_filled_rectangle(), ili93xx_draw_pixel(), ili93xx_draw_pixmap(), and ili93xx_fill().

static void ili93xx_write_register ( uint8_t  uc_reg,
uint8_t *  p_data,
uint8_t  uc_datacnt 
)
static
static void ili93xx_write_register_word ( uint8_t  uc_reg,
uint16_t  us_data 
)
static

struct ili93xx_font gfont = {10, 14}

Global variable describing the font size used by the driver.

const uint8_t p_uc_charset10x14[]

Character set table for font 10x14 Coding format: Char height is 14 bits, which is coded using 2 bytes per column (2 unused bits).

Char width is 10 bits.