📄 lcd.c
字号:
#include <stdio.h>
#include <stdarg.h>
#include "LCD.h"
static void Delay(void)
{
int i;
for(i = 0; i < 0x180; i++);
}
void LCD_Init(void)
{
static const u8 LCD_InitCmd[4]= {0x38, 0x0C, 0x06, 0x01};
int i;
GPIO_Config(GPIO2, 0x000F, GPIO_AF_PP);
EMI_Config(3, EMI_ENABLE | EMI_WAITSTATE(15) | EMI_SIZE_8);
for(i = 0; i < 4; i++)
{
*(vu16*)&LCD_CMD_PORT = LCD_InitCmd[i] << 8 | LCD_InitCmd[i];
Delay();
}
for(i = 0; i < 40; i++)
Delay();
}
void LCD_Goto(int line, int col)
{
unsigned cmd = 0x80 | line << 6 | col;
*(vu16*)&LCD_CMD_PORT = cmd << 8 | cmd;
Delay();
}
void LCD_Putc(char c)
{
*(vu16*)&LCD_DAT_PORT = (u8)c << 8 | (u8)c;
Delay();
}
void LCD_Puts(const char *s)
{
while(*s)
{
*(vu16*)&LCD_DAT_PORT = *s << 8 | *s;
s++;
Delay();
}
}
void LCD_Printf(const char *format, ...)
{
static char buf[256];
va_list args;
va_start(args, format);
vsprintf(buf, format, args);
va_end(args);
LCD_Puts(buf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -