#include "stm32f10x_lib.h" #include <stdio.h> #include <sys.h> #include <math.h> #define BTin GPIOC->CRL=0xc3333333 #define BTout GPIOC->CRL=0x33333333 #define BT (GPIOC->IDR&0x80) #define RS_1 GPIOC->BSRR=0x0100 #define RS_0 GPIOC->BRR=0x0100 #define RW_1 GPIOC->BSRR=0x0200 #define RW_0 GPIOC->BRR=0x0200 #define E_1 GPIOC->BSRR=0x0400 #define E_0 GPIOC->BRR=0x0400 #define Datain(x) GPIOC->ODR=(GPIOC->IDR&0xff00)+x u8 busytest(void) { u8 a; RS_0; RW_1; E_1; BTin; ysu(50); a=BT; E_0; BTout; return (a); } void Wcom(u8 com) { while(busytest()); ysm(1); RS_0; RW_0; E_0; ysu(5); Datain(com); ysu(5); E_1; ysu(5); E_0; } void Wdata(u8 data) { while(busytest()); RS_1; RW_0; E_0; Datain(data); ysu(5); E_1; ysu(5); E_0; } void adxy(u8 x,u8 y) { if(x==0) Wcom(0x80|y); else Wcom(0xc0|y); } void putstr(u8 *str) { while(*str!='\0') { Wdata(*str); str++; } } void lcdinit(void) { GPIOC->CRL=0x33333333; GPIOC->CRH&=0xfffff000; GPIOC->CRH|=0x333; Wcom(0x38); ysm(5); Wcom(0x38); ysm(5); Wcom(0x38); ysm(5); Wcom(0x0c); ysm(5); Wcom(0x06); ysm(5); Wcom(0x01); ysm(5); } void putnum(s32 num) //输出整数 { u32 lt=1; if(num<0) { num=fabs(num); Wdata('-'); } do { lt*=10; } while (num/lt); lt/=10; do { Wdata(num/lt+48); num%=lt; lt/=10; } while(lt); } void clear(u8 n) { while(n--) Wdata(' '); }
收藏1 举报
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
人才类勋章
时间类勋章
发帖类勋章
等级类勋章
24
302
8
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号