Low-level driver for the ILI9225 LCD controller.
This driver provides access to the main features of the ILI9225 controller.
Macros | |
#define | ILI9225_SPI_BAUDRATE 12500000 |
#define | LCD_DATA_CACHE_SIZE ILI9225_LCD_WIDTH |
Functions | |
static void | ili9225_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... | |
static void | ili9225_delay (uint32_t ul_ms) |
Delay function. More... | |
void | ili9225_disable_scroll (void) |
Disable the scrolling feature. More... | |
void | ili9225_display_off (void) |
Turn off the LCD. More... | |
void | ili9225_display_on (void) |
Turn on the LCD. More... | |
static void | ili9225_draw_char (uint32_t ul_x, uint32_t ul_y, uint8_t uc_c) |
Draw an ASCII character on LCD. More... | |
uint32_t | ili9225_draw_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r) |
Draw a circle on LCD. More... | |
uint32_t | ili9225_draw_filled_circle (uint32_t ul_x, uint32_t ul_y, uint32_t ul_r) |
Draw a filled circle on LCD. More... | |
void | ili9225_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 | ili9225_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 | ili9225_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 | ili9225_draw_pixel (uint32_t ul_x, uint32_t ul_y) |
Draw a pixel on LCD. More... | |
void | ili9225_draw_pixmap (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height, const ili9225_color_t *p_ul_pixmap) |
Draw a pixmap on LCD. More... | |
void | ili9225_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 | ili9225_draw_string (uint32_t ul_x, uint32_t ul_y, const uint8_t *p_str) |
Draw a string on LCD. More... | |
void | ili9225_enable_scroll (uint8_t uc_linenum) |
void | ili9225_fill (ili9225_color_t us_color) |
Fill the LCD buffer with the specified color. More... | |
uint32_t | ili9225_init (struct ili9225_opt_t *p_opt) |
Initialize the ILI9225 lcd driver. More... | |
void | ili9225_scroll (uint8_t uc_startline, uint8_t uc_endline) |
Scroll up/down for the number of specified lines. More... | |
void | ili9225_set_cursor_position (uint16_t ul_x, uint16_t ul_y) |
Set cursor of LCD screen. More... | |
void | ili9225_set_display_direction (enum ili9225_display_direction e_dd, enum ili9225_shift_direction e_shd, enum ili9225_scan_direction e_scd) |
Set display direction. More... | |
void | ili9225_set_foreground_color (uint32_t ul_rgb24bits) |
Set foreground color. More... | |
void | ili9225_set_window (uint32_t ul_x, uint32_t ul_y, uint32_t ul_width, uint32_t ul_height) |
Set display window. More... | |
void | ili9225_spi_handler (void) |
The SPI_Handler must be called by the SPI Interrupt Service Routine with the corresponding SPI instance to enable ILI9225 driver support. More... | |
static void | ili9225_write_cmd (uint8_t uc_cmd) |
Send command to LCD controller. More... | |
static void | ili9225_write_ram (uint16_t us_data) |
Write data to LCD GRAM. More... | |
static void | ili9225_write_ram_buffer (const ili9225_color_t *p_us_buf, uint32_t ul_size) |
Write multiple data in buffer to LCD controller. More... | |
static void | ili9225_write_ram_prepare (void) |
Prepare to write GRAM data. More... | |
static void | ili9225_write_register (uint8_t uc_reg, ili9225_color_t us_data) |
Write data to LCD Register. More... | |
Variables | |
static volatile uint8_t | g_by_transfend_flag = 0 |
End transfer flag. More... | |
static ili9225_color_t | g_ul_pixel_cache [LCD_DATA_CACHE_SIZE] |
struct ili9225_font | gfont = {10, 14} |
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 ILI9225_SPI_BAUDRATE 12500000 |
Referenced by ili9225_init().
#define LCD_DATA_CACHE_SIZE ILI9225_LCD_WIDTH |
Referenced by ili9225_draw_filled_rectangle(), and ili9225_set_foreground_color().
|
static |
Check box coordinates.
p_ul_x1 | X coordinate of upper-left corner on LCD. |
p_ul_y1 | Y coordinate of upper-left corner on LCD. |
p_ul_x2 | X coordinate of lower-right corner on LCD. |
p_ul_y2 | Y coordinate of lower-right corner on LCD. |
References ILI9225_LCD_HEIGHT, and ILI9225_LCD_WIDTH.
Referenced by ili9225_draw_filled_rectangle(), ili9225_draw_pixmap(), and ili9225_draw_rectangle().
|
static |
Delay function.
Referenced by ili9225_init().
void ili9225_disable_scroll | ( | void | ) |
Disable the scrolling feature.
References ILI9225_VERTICAL_SCROLL_CTRL3, and ili9225_write_register().
void ili9225_display_off | ( | void | ) |
Turn off the LCD.
References ILI9225_DISP_CTRL1, and ili9225_write_register().
Referenced by ili9225_init().
void ili9225_display_on | ( | void | ) |
Turn on the LCD.
References ILI9225_DISP_CTRL1, ILI9225_DISP_CTRL1_D, ILI9225_DISP_CTRL1_GON, ILI9225_DISP_CTRL1_REV, ILI9225_DISP_CTRL1_TEMON, and ili9225_write_register().
|
static |
Draw an ASCII character on LCD.
ul_x | X coordinate of character upper-left corner. |
ul_y | Y coordinate of character upper-left corner. |
uc_c | character to print. |
References ili9225_draw_pixel().
Referenced by ili9225_draw_string().
uint32_t ili9225_draw_circle | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_r | ||
) |
Draw a circle on LCD.
ul_x | X coordinate of circle center. |
ul_y | Y coordinate of circle center. |
ul_r | circle radius. |
References ili9225_draw_pixel().
uint32_t ili9225_draw_filled_circle | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_r | ||
) |
Draw a filled circle on LCD.
ul_x | X coordinate of circle center. |
ul_y | Y coordinate of circle center. |
ul_r | circle radius. |
References ili9225_draw_filled_rectangle().
void ili9225_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.
ul_x1 | X coordinate of upper-left corner on LCD. |
ul_y1 | Y coordinate of upper-left corner on LCD. |
ul_x2 | X coordinate of lower-right corner on LCD. |
ul_y2 | Y coordinate of lower-right corner on LCD. |
References ili9225_check_box_coordinates(), ILI9225_LCD_HEIGHT, ILI9225_LCD_WIDTH, ili9225_set_cursor_position(), ili9225_set_window(), ili9225_write_ram_buffer(), ili9225_write_ram_prepare(), and LCD_DATA_CACHE_SIZE.
Referenced by ili9225_draw_filled_circle(), ili9225_draw_line(), and ili9225_draw_rectangle().
void ili9225_draw_line | ( | uint32_t | ul_x1, |
uint32_t | ul_y1, | ||
uint32_t | ul_x2, | ||
uint32_t | ul_y2 | ||
) |
Draw a line on LCD.
ul_x1 | X coordinate of line start. |
ul_y1 | Y coordinate of line start. |
ul_x2 | X coordinate of line end. |
ul_y2 | Y coordinate of line end. |
References ili9225_draw_filled_rectangle(), and ili9225_draw_line_bresenham().
|
static |
Draw a line on LCD, which is not horizontal or vertical.
ul_x1 | X coordinate of line start. |
ul_y1 | Y coordinate of line start. |
ul_x2 | X coordinate of line end. |
ul_y2 | Y coordinate of line endl. |
References ili9225_draw_pixel().
Referenced by ili9225_draw_line().
uint32_t ili9225_draw_pixel | ( | uint32_t | ul_x, |
uint32_t | ul_y | ||
) |
Draw a pixel on LCD.
ul_x | X coordinate of pixel. |
ul_y | Y coordinate of pixel. |
References ILI9225_LCD_HEIGHT, ILI9225_LCD_WIDTH, ili9225_set_cursor_position(), ili9225_write_ram(), and ili9225_write_ram_prepare().
Referenced by ili9225_draw_char(), ili9225_draw_circle(), and ili9225_draw_line_bresenham().
void ili9225_draw_pixmap | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_width, | ||
uint32_t | ul_height, | ||
const ili9225_color_t * | p_ul_pixmap | ||
) |
Draw a pixmap on LCD.
ul_x | X coordinate of upper-left corner on LCD. |
ul_y | Y coordinate of upper-left corner on LCD. |
ul_width | width of the picture. |
ul_height | height of the picture. |
p_ul_pixmap | pixmap of the image. |
References ili9225_check_box_coordinates(), ILI9225_LCD_HEIGHT, ILI9225_LCD_WIDTH, ili9225_set_cursor_position(), ili9225_set_window(), ili9225_write_ram_buffer(), and ili9225_write_ram_prepare().
void ili9225_draw_rectangle | ( | uint32_t | ul_x1, |
uint32_t | ul_y1, | ||
uint32_t | ul_x2, | ||
uint32_t | ul_y2 | ||
) |
Draw a rectangle on LCD.
ul_x1 | X coordinate of upper-left corner on LCD. |
ul_y1 | Y coordinate of upper-left corner on LCD. |
ul_x2 | X coordinate of lower-right corner on LCD. |
ul_y2 | Y coordinate of lower-right corner on LCD. |
References ili9225_check_box_coordinates(), and ili9225_draw_filled_rectangle().
void ili9225_draw_string | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
const uint8_t * | p_str | ||
) |
Draw a string on LCD.
ul_x | X coordinate of string top-left corner. |
ul_y | Y coordinate of string top-left corner. |
p_str | String to display. |
References ili9225_font::height, ili9225_draw_char(), and ili9225_font::width.
void ili9225_enable_scroll | ( | uint8_t | uc_linenum | ) |
void ili9225_fill | ( | ili9225_color_t | us_color | ) |
Fill the LCD buffer with the specified color.
us_color | fill color. |
References ILI9225_LCD_HEIGHT, ILI9225_LCD_WIDTH, ili9225_set_cursor_position(), ili9225_write_ram(), and ili9225_write_ram_prepare().
uint32_t ili9225_init | ( | struct ili9225_opt_t * | p_opt | ) |
Initialize the ILI9225 lcd driver.
p_opt | pointer to ILI9225 option structure. |
References ili9225_opt_t::foreground_color, gpio_set_pin_high, gpio_set_pin_low, spi_device::id, ILI9225_BLANK_PERIOD_CTRL1, ILI9225_BLANK_PERIOD_CTRL1_BP, ILI9225_BLANK_PERIOD_CTRL1_FP, ili9225_delay(), ili9225_display_off(), ILI9225_DRIVER_OUTPUT_CTRL, ILI9225_DRIVER_OUTPUT_CTRL_NL, ILI9225_DRIVER_OUTPUT_CTRL_SS, ILI9225_ENTRY_MODE, ILI9225_ENTRY_MODE_BGR, ILI9225_ENTRY_MODE_ID, ILI9225_GAMMA_CTRL1, ILI9225_GAMMA_CTRL10, ILI9225_GAMMA_CTRL2, ILI9225_GAMMA_CTRL2_KP2, ILI9225_GAMMA_CTRL2_KP3, ILI9225_GAMMA_CTRL3, ILI9225_GAMMA_CTRL3_KP4, ILI9225_GAMMA_CTRL3_KP5, ILI9225_GAMMA_CTRL4, ILI9225_GAMMA_CTRL4_RP0, ILI9225_GAMMA_CTRL4_RP1, ILI9225_GAMMA_CTRL5, ILI9225_GAMMA_CTRL5_KN0, ILI9225_GAMMA_CTRL5_KN1, ILI9225_GAMMA_CTRL6, ILI9225_GAMMA_CTRL6_KN2, ILI9225_GAMMA_CTRL6_KN3, ILI9225_GAMMA_CTRL7, ILI9225_GAMMA_CTRL8, ILI9225_GAMMA_CTRL8_RN0, ILI9225_GAMMA_CTRL8_RN1, ILI9225_GAMMA_CTRL9, ILI9225_GATE_SCAN_CTRL, ILI9225_HORIZONTAL_WINDOW_ADDR1, ILI9225_HORIZONTAL_WINDOW_ADDR1_HEA, ILI9225_HORIZONTAL_WINDOW_ADDR2, ILI9225_INTERFACE_CTRL, ILI9225_INTERFACE_CTRL_RIM, ILI9225_LCD_AC_DRIVING_CTRL, ILI9225_LCD_AC_DRIVING_CTRL_INV, ILI9225_LCD_HEIGHT, ILI9225_LCD_WIDTH, ILI9225_OSC_CTRL, ILI9225_OSC_CTRL_FOSC, ILI9225_OSC_CTRL_ON, ILI9225_PARTIAL_DRIVING_POS1, ILI9225_PARTIAL_DRIVING_POS1_SE1, ILI9225_PARTIAL_DRIVING_POS2, ILI9225_POWER_CTRL1, ILI9225_POWER_CTRL1_SAP, ILI9225_POWER_CTRL2, ILI9225_POWER_CTRL2_AON, ILI9225_POWER_CTRL2_APON, ILI9225_POWER_CTRL2_VC, ILI9225_POWER_CTRL2_VCI1, ILI9225_POWER_CTRL3, ILI9225_POWER_CTRL3_BT, ILI9225_POWER_CTRL3_DC1, ILI9225_POWER_CTRL3_DC2, ILI9225_POWER_CTRL3_DC3, ILI9225_POWER_CTRL4, ILI9225_POWER_CTRL4_GVD, ILI9225_POWER_CTRL5, ILI9225_POWER_CTRL5_VCM, ILI9225_POWER_CTRL5_VML, ILI9225_RAM_ADDR_SET1, ILI9225_RAM_ADDR_SET1_AD, ILI9225_RAM_ADDR_SET2, ILI9225_RAM_ADDR_SET2_AD, ili9225_set_cursor_position(), ili9225_set_foreground_color(), ili9225_set_window(), ILI9225_SPI_BAUDRATE, ILI9225_VERTICAL_SCROLL_CTRL1, ILI9225_VERTICAL_SCROLL_CTRL1_SEA, ILI9225_VERTICAL_SCROLL_CTRL2, ILI9225_VERTICAL_SCROLL_CTRL3, ILI9225_VERTICAL_WINDOW_ADDR1, ILI9225_VERTICAL_WINDOW_ADDR1_VEA, ILI9225_VERTICAL_WINDOW_ADDR2, ili9225_write_register(), spi_disable(), spi_enable(), spi_enable_interrupt(), spi_master_init(), spi_master_setup_device(), SPI_MODE_0, spi_reset(), spi_select_device(), spi_set_lastxfer(), ili9225_opt_t::ul_height, and ili9225_opt_t::ul_width.
void ili9225_scroll | ( | uint8_t | uc_startline, |
uint8_t | uc_endline | ||
) |
Scroll up/down for the number of specified lines.
uc_startline | start scrolling from uc_startline address. |
uc_endline | stop scrolling at uc_endline address. |
References ILI9225_VERTICAL_SCROLL_CTRL1, ILI9225_VERTICAL_SCROLL_CTRL1_SEA, ILI9225_VERTICAL_SCROLL_CTRL2, ILI9225_VERTICAL_SCROLL_CTRL2_SSA, and ili9225_write_register().
void ili9225_set_cursor_position | ( | uint16_t | ul_x, |
uint16_t | ul_y | ||
) |
Set cursor of LCD screen.
ul_x | X coordinate of upper-left corner on LCD. |
ul_y | Y coordinate of upper-left corner on LCD. |
References ILI9225_RAM_ADDR_SET1, ILI9225_RAM_ADDR_SET1_AD, ILI9225_RAM_ADDR_SET2, ILI9225_RAM_ADDR_SET2_AD, and ili9225_write_register().
Referenced by ili9225_draw_filled_rectangle(), ili9225_draw_pixel(), ili9225_draw_pixmap(), ili9225_fill(), and ili9225_init().
void ili9225_set_display_direction | ( | enum ili9225_display_direction | e_dd, |
enum ili9225_shift_direction | e_shd, | ||
enum ili9225_scan_direction | e_scd | ||
) |
Set display direction.
dd | 0: horizontal direction, 1: vertical direction |
shd | horizontal increase(1) or decrease(0) |
scd | vertical increase(1) or decrease(0) |
References H_INCREASE, ILI9225_DRIVER_OUTPUT_CTRL, ILI9225_DRIVER_OUTPUT_CTRL_GS, ILI9225_DRIVER_OUTPUT_CTRL_SS, ILI9225_ENTRY_MODE, ILI9225_ENTRY_MODE_AM, ili9225_write_register(), LANDSCAPE, and V_INCREASE.
void ili9225_set_foreground_color | ( | uint32_t | ul_rgb24bits | ) |
Set foreground color.
ul_rgb24bits | foreground color. |
References LCD_DATA_CACHE_SIZE.
Referenced by ili9225_init().
void ili9225_set_window | ( | uint32_t | ul_x, |
uint32_t | ul_y, | ||
uint32_t | ul_width, | ||
uint32_t | ul_height | ||
) |
Set display window.
ul_x | Horizontal address start position |
ul_y | Vertical address start position |
ul_width | The width of the window. |
ul_height | The height of the window. |
References Assert, ILI9225_HORIZONTAL_WINDOW_ADDR1, ILI9225_HORIZONTAL_WINDOW_ADDR1_HEA, ILI9225_HORIZONTAL_WINDOW_ADDR2, ILI9225_HORIZONTAL_WINDOW_ADDR2_HSA, ILI9225_VERTICAL_WINDOW_ADDR1, ILI9225_VERTICAL_WINDOW_ADDR1_VEA, ILI9225_VERTICAL_WINDOW_ADDR2, ILI9225_VERTICAL_WINDOW_ADDR2_VSA, and ili9225_write_register().
Referenced by ili9225_draw_filled_rectangle(), ili9225_draw_pixmap(), and ili9225_init().
void ili9225_spi_handler | ( | void | ) |
The SPI_Handler must be called by the SPI Interrupt Service Routine with the corresponding SPI instance to enable ILI9225 driver support.
References spi_disable_interrupt(), and spi_read_interrupt_mask().
|
static |
Send command to LCD controller.
uc_cmd | command. |
References gpio_set_pin_low, spi_disable(), spi_enable(), spi_set_bits_per_transfer(), and spi_write().
Referenced by ili9225_write_ram_prepare(), and ili9225_write_register().
|
static |
Write data to LCD GRAM.
us_data | data. |
References gpio_set_pin_high, spi_disable(), spi_enable(), and spi_write().
Referenced by ili9225_draw_pixel(), ili9225_fill(), and ili9225_write_register().
|
static |
Write multiple data in buffer to LCD controller.
p_us_buf | data buffer. |
ul_size | size in pixels. |
References gpio_set_pin_high, spi_disable(), spi_enable(), and spi_write().
Referenced by ili9225_draw_filled_rectangle(), and ili9225_draw_pixmap().
|
static |
Prepare to write GRAM data.
References ILI9225_GRAM_DATA_REG, and ili9225_write_cmd().
Referenced by ili9225_draw_filled_rectangle(), ili9225_draw_pixel(), ili9225_draw_pixmap(), and ili9225_fill().
|
static |
Write data to LCD Register.
uc_reg | register address. |
us_data | data to be written. |
References ili9225_write_cmd(), and ili9225_write_ram().
Referenced by ili9225_disable_scroll(), ili9225_display_off(), ili9225_display_on(), ili9225_enable_scroll(), ili9225_init(), ili9225_scroll(), ili9225_set_cursor_position(), ili9225_set_display_direction(), and ili9225_set_window().
|
static |
End transfer flag.
|
static |
struct ili9225_font gfont = {10, 14} |
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.