这个是个驱动彩色显示屏ili93XX_LCD的例程。
这个例程使用了一个高难的东东----SMC
至于SMC是什么东东,数据手册上有说明。这个我想在以后好好研究一下。
从字面上看应是静态存贮控制
以下是运行效果:
这个程序先是初使化静态存贮,然后通过静态存贮控制显示屏。
程序如下:
#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_clock.h"
#include "smc.h"
/** Chip select number to be set */
#define ILI93XX_LCD_CS 1
struct ili93xx_opt_t g_ili93xx_display_opt;
/**
* Configure UART console.
*/
static void configure_console(void)
{
const usart_serial_options_t uart_serial_options = {
.baudrate = CONF_UART_BAUDRATE,
.paritytype = CONF_UART_PARITY
};
/** Configure console UART. */
sysclk_enable_peripheral_clock(CONSOLE_UART_ID);
stdio_serial_init(CONF_UART, &uart_serial_options);
}
/**
* \brief Application entry point for smc_lcd example.
*
* \return Unused (ANSI-C compatibility).
*/
int main(void)
{
sysclk_init();
board_init();
/** Initialize debug console */
configure_console();
/** Enable peripheral clock */
pmc_enable_periph_clk(ID_SMC);
/** Configure SMC interface for Lcd */
smc_set_setup_timing(SMC, ILI93XX_LCD_CS, SMC_SETUP_NWE_SETUP(2)
| SMC_SETUP_NCS_WR_SETUP(2)
| SMC_SETUP_NRD_SETUP(2)
| SMC_SETUP_NCS_RD_SETUP(2));
smc_set_pulse_timing(SMC, ILI93XX_LCD_CS, SMC_PULSE_NWE_PULSE(4)
| SMC_PULSE_NCS_WR_PULSE(4)
| SMC_PULSE_NRD_PULSE(10)
| SMC_PULSE_NCS_RD_PULSE(10));
smc_set_cycle_timing(SMC, ILI93XX_LCD_CS, SMC_CYCLE_NWE_CYCLE(10)
| SMC_CYCLE_NRD_CYCLE(22));
#if ((!defined(SAM4S)) && (!defined(SAM4E)))
smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
| SMC_MODE_WRITE_MODE
| SMC_MODE_DBW_8_BIT);
#else
smc_set_mode(SMC, ILI93XX_LCD_CS, SMC_MODE_READ_MODE
| SMC_MODE_WRITE_MODE);
#endif
/** Initialize display parameter */
g_ili93xx_display_opt.ul_width = ILI93XX_LCD_WIDTH;
g_ili93xx_display_opt.ul_height = ILI93XX_LCD_HEIGHT;
g_ili93xx_display_opt.foreground_color = COLOR_BLACK;
g_ili93xx_display_opt.background_color = COLOR_WHITE;
/** Switch off backlight */
aat31xx_disable_backlight();
/** Initialize LCD */
ili93xx_init(&g_ili93xx_display_opt);
/** Set backlight level */
aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL);
ili93xx_set_foreground_color(COLOR_WHITE);
ili93xx_draw_filled_rectangle(0, 0, ILI93XX_LCD_WIDTH,
ILI93XX_LCD_HEIGHT);
/** Turn on LCD */
ili93xx_display_on();
ili93xx_set_cursor_position(0, 0);
/** Draw text, image and basic shapes on the LCD */
ili93xx_set_foreground_color(COLOR_BLACK);
ili93xx_draw_string(10, 20, (uint8_t *)"ili93xx_lcd example");
ili93xx_set_foreground_color(COLOR_RED);
ili93xx_draw_circle(60, 160, 40);
ili93xx_set_foreground_color(COLOR_GREEN);
ili93xx_draw_circle(120, 160, 40);
ili93xx_set_foreground_color(COLOR_BLUE);
ili93xx_draw_circle(180, 160, 40);
ili93xx_set_foreground_color(COLOR_VIOLET);
ili93xx_draw_line(0, 0, 240, 320);
while (1) {
}
}
至于SMC的具体分析下一帖说明。
|