STM8 SPI驱动LCD12864
<tbody></tbody>
利用STM8内部的SPI通讯总线来驱动LCD12864。 | |
---|---|
<tbody></tbody>
| |
<tbody></tbody>
/********************************************************************* 微 雪 电 子 WaveShare <a class="Blue_2_12px_" href="https://wiki.diustou.com/" style="color: rgb(7, 66, 184);">http://www.waveShare.net 目标系统: 基于STM8单片机 应用软件: Cosmic CxSTM8 说 明: 若用于商业用途,请保留此段文字或注明代码来源 深 圳 市 微 雪 电 子 有 限 公 司 保 留 所 有 的 版 权
void st7920LcdInit(void) { u8 i; SPI_Init(); delay_ms(100); PE_DDR|=0x20; PE_CR1|=0x20; PE_CR2|=0x20; sendCodeST7920(0x0c);//整体显示 sendCodeST7920(0x01);//清屏 sendCodeST7920(0x02); for(i=0;i<64;i++) lcd_buffer[i]=' '; //memset(lcd_buffer,' ',sizeof(lcd_buffer)); } void sendCodeST7920(u8 Lcd_cmd) { E_CLK LCD_DELAY() E_SET SPI_sendchar(0xF8); SPI_sendchar(Lcd_cmd & 0xF0); SPI_sendchar(Lcd_cmd << 4); LCD_DELAY() E_CLK LCD_DELAY() } void sendDataST7920(u8 Lcd_data) { E_CLK LCD_DELAY() E_SET SPI_sendchar(0xFA); SPI_sendchar(Lcd_data & 0xF0); SPI_sendchar(Lcd_data << 4); LCD_DELAY() E_CLK LCD_DELAY() } |