📄 mb90092.c
字号:
/*
THIS SUBROUTINE IS FOR
MB90092 READ/WRITE
Descripton : the routine read/write the IC MB90092,use I2C communication line.
in the special address, save the "no any message" ,and " confirm to delete
the message " , and "key respectative "message
*/
/*------------------------------------------------*/
/*----------------------------------*/
#include "externh.h"
#include "defineh.h"
#include "Sbitdef.h"
/*-----------------------------------*/
//extern void disp_num(uchar row,uchar col,uchar addr,uchar bc,uchar cc);
extern void Page_Read_Op();
extern uchar check_pagedown_command();
/*----------------------------------------*/
void disp_num(uchar row,uchar col,uint addr,uchar bc,uchar cc);
/*-------------------------------------------*/
/*
全屏清屏
*/
/*-------------------------------------*/
void Clr_Display(void)
{
uchar data i,j;
for(j=0;j<12;j++)
{
for(i=0;i<24;i++)
{
disp_num(j,i,0x20,0,0);
}
}
}
/*-----------------------------------*/
/*
延时程序
*/
void delay()
{
uchar data i;
for(i=0;i<0xff;i++)
{
_nop_();
}
}
/*---------------------------------*/
/*
程序名:send_byte()
参 数:I_data
返回值:无
功 能:将I_data值送至MB90092
*/
/*------------------------------------------------*/
/*
发送字节到90092
I_data:待发送的数
*/
void send_byte(uchar I_data)
{
uchar data i,temp;
MbCE=0x00;
for(i=0;i<8;i++)
{
MBSCLK=0x00;
temp = 0x01 & I_data;
if(temp == 0x00)
MBSIM= 0x00;
else
MBSIM= 0x01;
I_data=I_data >> 1;
MBSCLK=0x01;
}
MbCE=0x01;
}
/*----------------------------------------
row:行地址
在指定行显示反白
*/
void disp_color(uchar row)
{
uchar data temp1,temp2;
temp1=row;
temp1=((temp1>>2)&0x3)+0x84;
temp2=row;
temp2=((temp2<<5)&0x60)+1;
send_byte(temp1); //command 0
send_byte(temp2);
send_byte(0x88); //command 1-1 or 1-2
send_byte(0x0);
send_byte(0x90); //command2-1
send_byte(0x0);
}
/*------------------------------------------------*/
/* row:行,col:列,addr:地址,bc:背景颜色,cc:前景颜色,*/
void disp_num(uchar row,uchar col,uint addr,uchar bc,uchar cc)
{
uchar data temp1,temp2,color;
temp1=row;
temp1=((temp1>>2)&0x03)+0x80;
send_byte(temp1); //command 0
temp1=row;
temp1=((temp1<<5)&0x60)+col;
send_byte(temp1);
send_byte(0xb0+2); //command 6
send_byte(0x20+row);
color=((cc<<4)&0x70)+bc; //bc=1
if(addr<0xb0a1)
{
addr=addr-0x20;
}
else
{
temp2=((addr&0xff00)>>8)&0x00ff;
addr=(temp2-0xb0)*94+((addr&0x00ff)-0xa1)+0x60;
}
temp1=(addr/128)&0X18; //00011000
temp2=temp1&0x10;
temp2=temp2>>3;
temp2=temp2&0x02;
temp1=temp1&0x08;
temp1=(temp1>>1)&0x04; //addr <0x1fff must
temp1=temp1+temp2;
send_byte(0x88+temp1);
temp1=(addr/128)&0X20;
temp1=temp1>>2; //addr <0x1fff must
temp1=temp1&0x80;
send_byte(color+temp1); //command1-1
temp1=(addr/128)&0X07;
send_byte(0x90+temp1); //command2-1
send_byte((addr%128)&0x7f);
}
/*----------------------------------------------*/
/*芯片初始化程序*/
void Init_MB90092(void)
{
// uchar i;
MbCE=0;
delay();
MbCE =1;
delay();
MbCE=0;
delay();
MbCE=1;
delay();
MbCE =0;
delay();
MbCE=1;
delay();
MbCE=0;
delay();
MbCE=1;
send_byte(0x98);/*--------command 3----------*/
send_byte(0); /*FIL 位,此命令可以不动 */
send_byte(0xaa);/*--------command 5----------*/
send_byte(0x10);/*;KID=0;APC与颜色有关;GYZ=0;W3--W0为行间距;10101 KID APC GYZ0 BH2 BH1 BH0 W3 W2 W1 W0*/
send_byte(0xbd);/*--------command 7 10111101-bd,change to 10111101-b9---------*/
send_byte(0x27);/*垂直位置设定
;10111 EC LP FO
;00 Y5 Y4 Y3 Y2 Y1 Y0
;EC:同步信号选择 EC=0 只用行同步信号 EC=1 行场共用
;LP:LP=0 正常操作
;LP=1 NTSC/PAL 格式
;FO:颜色信号输出控制
;Y5---Y0垂直位置设定*/
send_byte(0xc1);/*--------command 8 11000100-c4,change to 11000001-c1-----------*/
send_byte(0x02);/*水平位置设定*/
send_byte(0xc8);/*--------command 9---------*/
send_byte(0x00);
/*------背景设置1-------*/
send_byte(0xd1);//*--------command 10----------
send_byte(0x06);
/*1101000 RB
0 BK CC BC UC UG UR UB
RB:背影(solid-fill)选择
BK:闪烁;
CC:彩色/黑白选择
BC:背景颜色
UC:屏幕颜色
UG,UR,UB 颜色选择*/
send_byte(0xa2);/*-------command 4----------*/
send_byte(0x1b);//(0x2b); //change to 1,noncolor
/*1010 0 IE IN EB
0 EO CM ZM NP P2 P0 DC:
EO:field control
CM:color display control
ZM:zoom in control
NP: NTSC/PAL control
P2/0: backgrond pattern control
DC:
*/
/*
for(i=0;i<12;i++)
{
disp_color(i);
}
*/
Clr_Display();
}
/*------------------------------------------*/
/* No Message Guide Display
Desription: when check all address, no message belong to the user,
display this guide frame to user ,under is :
"您目前暂无信息"
*/
/*--------------------------------------------*/
void No_Message_Guide(void)
{
uchar data i;
send_byte(0xa2); //command 5
send_byte(0x29);
disp_num(4,5,0xc4fa,1,1);
disp_num(4,6,0xc4bf,1,1);
disp_num(4,7,0xc7b0,1,1);
disp_num(4,8,0xd4dd,1,1);
disp_num(4,9,0xcede,1,1);
disp_num(4,10,0xd0c5,1,1);
disp_num(4,11,0xcfa2,1,1);
for(i=0;i<100;i++)
{
delay();
}
}
/*---------------------------------------------*/
/* 取消提示
描述: 出现字体 "请确认退出"
*/
/*-----------------------------------------------*/
void Inqire_Frame()
{
uchar data i;
send_byte(0xa2); //command 5
send_byte(0x29);
disp_num(4,4,0xc7eb,1,1);
disp_num(4,5,0xc8b7,1,1);
disp_num(4,6,0xc8cf,1,1);
disp_num(4,7,0xc8a1,1,1);
disp_num(4,8,0xcffb,1,1);
disp_num(4,9,0xb2d9,1,1);
disp_num(4,10,0xd7f7,1,1);
for(i=0;i<100;i++)
{
delay();
}
}
/*------------------------------------------*/
/* 字体显示
Description:
显示字在相应的位置,共显示如下:
XX-XX-XX____(信息标题)
使用的寄存器:READ_BLOCK, message_group[18]
*/
/*----------------------------------------*/
void Config_Word(uchar line)
{
uchar data i,j,y;
uint data n;
i=line;
Page_Read_Op(); //used read_block!!!
for(y=1;y<9;y++)
{
if(y<5)
{
j=message_group[2*y];
n=(uint)(j);
// n=n-0x0020; //TEST
disp_num(i,(2*y), n, 1, 1);
j=message_group[2*y+1];
n=(uint)(j);
// n=n-0x0020; //TEST
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -