IO初始化
#define Bsp_Cs1628Clk(sta) CS1628_CLK = sta
#define Bsp_Cs1628Dio(sta) CS1628_DIO = sta
#define Bsp_Cs1628CS(sta) CS1628_CS = sta
void Bsp_DspIOIint(void)
{
P5CON |= BIT1;
P5PH &= ~(BIT1);
P5CON |= BIT0;
P5PH &= ~(BIT0);
P1CON |= BIT1;
P1PH &= ~(BIT1);
P1CON |= BIT6;
P1PH &= ~(BIT6);
}
LCD驱动初始化
#define SYSDIS 0x00
#define SYSEN 0x02
#define LCDOFF 0x04
#define LCDON 0x06
#define RC 0x30
#define BIAS 0x52
void tm1621_command(INT8U cmd)
{
Bsp_Cs1628CS(0);
tm1621_write_byte(0x80,4);
tm1621_write_byte(cmd,8);
Bsp_Cs1628CS(1);
}
void Led_Init(void)
{
Bsp_DspIOIint();
tm1621_command(BIAS);
tm1621_command(RC);
tm1621_command(SYSDIS);
tm1621_command(SYSEN);
tm1621_command(LCDON);
}
显存通讯
void tm1621_write_byte(INT8U dat,INT8U cnt)
{
INT8U i;
for(i=0;i<cnt;i++)
{
Bsp_Cs1628Clk(0);
Sys_DlyUs(5);
Bsp_Cs1628Dio((dat&BIT7)?1:0);
Sys_DlyUs(5);
Bsp_Cs1628Clk(1);
dat<<=1;
}
}
void CS1628_Dsp(INT16U *buff)
{
INT8U i;
Bsp_Cs1628CS(0);
tm1621_write_byte(0xa0,3);
tm1621_write_byte(9<<2,6);
for(i=0;i<LED_COM_NUM;i++)
{
tm1621_write_byte((INT8U)buff[i],8);
}
Bsp_Cs1628CS(1);
}
void Led_Display(void)
{
INT16U xdata tmp[16] = {0};
INT16U t_seg = 1;
tmp[3] = 0;
tmp[2] = Left_LedStr.buff[3];
tmp[2] = Left_LedStr.buff[3];
tmp[4] |= Left_LedStr.buff[2]&0xf0;
tmp[0] |= Left_LedStr.buff[2]<<4;
tmp[4] |= (Left_LedStr.buff[1]&0xf0) >> 4;
tmp[5] |= Left_LedStr.buff[1]<<4;
tmp[5] |= Left_LedStr.buff[0]>>4;
tmp[6] |= Left_LedStr.buff[0]<<4;
tmp[0] |= Right_LedStr.buff[0]&0x0f;
tmp[1] |= Right_LedStr.buff[1]<<4;
tmp[1] |= Right_LedStr.buff[2]&0x0f;
tmp[6] |= Right_LedStr.buff[3]&0x0f;
tmp[2] |= (Mid_LedStr.buff[3]&0x80)>>4;
tmp[0] |= Mid_LedStr.buff[2]&0x80;
tmp[6] |= (Mid_LedStr.buff[1]&0x80);
tmp[5] |= (Mid_LedStr.buff[0]&0x80);
CS1628_Dsp(tmp);
}