📄 zlg7290.c
字号:
#include "config.h"int fd;uint16 zlg7290_getkey(void){ uint8 temp[2]; temp[0] = 1; temp[1] = 0; write(fd, temp, 1); read(fd, temp, 2); return (temp[0] + (temp[1] * 256));}void zlg7290_sndcmd(uint8 dat1, uint8 dat2){ uint8 temp[3]; temp[0] = 0x07; temp[1] = dat1; temp[2] = dat2; write(fd, temp, 3);}void zlg7290_disp(uint8 *buf, uint8 num){ uint8 i; uint8 temp[3]; for(i=0; i<num; i++) { temp[0] = 0x07; temp[1] = 0x60+i; temp[2] = *buf; buf++; write(fd, temp, 3); }}int main(){ uint32 i; int32 key; uint8 buf[8]; uint32 fpclk,fi2c; fpclk = 11059200; fi2c = 30000; // 30k fd = open("/dev/zlg7290", O_RDWR); if(fd == -1) { printf("\nDon't open this file!\n"); return -1; } ioctl(fd, I2C_SET_CLH, ((fpclk / fi2c) + 1) / 2); ioctl(fd, I2C_SET_CLL, (fpclk / fi2c) / 2); printf("Hello ZLG7290!\n"); // LPC2290F // buf[7] = 0x14; buf[6] = 0x16; buf[5] = 0x0C; buf[4] = 0x02; buf[3] = 0x02; buf[2] = 0x09; buf[1] = 0x00; buf[0] = 0x0F; zlg7290_disp(buf, 8); for (;;) { key = zlg7290_getkey(); zlg7290_sndcmd(0x70, 1<<(key-1)); //sleep(1); } close(fd); return 0;}/********************************************************************************* End Of File*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -