LCD.c
资源名称:str711USB.rar [点击查看]
上传用户:yyyd609
上传日期:2022-07-18
资源大小:183k
文件大小:1k
源码类别:
微处理器开发
开发平台:
C/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);
- }