lcd.bak
来自「此源码是用的NEC公司的MCU78F0396」· BAK 代码 · 共 435 行 · 第 1/2 页
BAK
435 行
LcdDrvClkOut();
//-- Checks parameters
if(( size == 0 )||( addr > 0x03 )||(( 0x03+1 - addr ) < size )){
result = CLDR_ERR_PARA;
}
buf[0] = addr;
for (uc = 0; uc < size; uc++) {
buf[uc+1] = src[uc];
}
status = IIC0_MasterStartAndSend( CSLV_ID_LCDCTL, buf, size + 1 );
if (status != MD_OK)
result = CLDR_ERR_NACK;*/
return ( result );
}
/********************************************************************
; Writes LCD driver segment data
;--------------------------------------------------------------------
; [I N] src : Address of segment data to be written
; addr : Data address for start of write operation
; size : Number of bytes to be transmitted (maximum: 20 bytes)
; [OUT] 0= Setting OK, 1 = NACK received, 2 = Busy, 3 = Parameter error
;--------------------------------------------------------------------
; ** Smooths data before transmitting segment data.
;
; <Received data>
; bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
; +----+
; 1st byte (00H)|COM3|COM2|COM1|COM0|COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; |<- segment:S1 ->|<- segment:S0 ->|
;
; +----+----+----+----+----+----+----+----+
; 2nd byte (01H)|COM3|COM2|COM1|COM0|COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; :
; : :
; +----+----+----+----+----+----+----+----+
; 19th byte (12H)|COM3|COM2|COM1|COM0|COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; +----+----+----+----+----+----+----+----+
; 20th byte (13H)|COM3|COM2|COM1|COM0|COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; |<- segment:S39 ->|<- segment:S38 ->|
;
; <Sent data>
; bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
; +----+----+----+----+----+----+----+----+
; 1st byte(00H)| 0 | 0 | 0 | 0 |COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; |<- segment:S0 ->|
; Address:00H |
;
; +----+----+----+----+----+----+----+----+
; 2nd byte (01H)| 0 | 0 | 0 | 0 |COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; :
; :
; +----+----+----+----+----+----+----+----+
; 39th byte (26H)| 0 | 0 | 0 | 0 |COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; +----+----+----+----+----+----+----+----+
; 40th byte (27H)| 0 | 0 | 0 | 0 |COM3|COM2|COM1|COM0|
; +----+----+----+----+----+----+----+----+
; |<- segment:S39 ->|
; | Address:27H |
;
;*******************************************************************/
unsigned char LcdDrvSegWrite( unsigned char *src,
unsigned char addr, unsigned char size )
{
register unsigned char result = CLDR_ERR_NONE;
/* register unsigned char cnt;
unsigned short status;
unsigned char buf[41];
unsigned char uci,ucd;
//-- Enables clock output to LCD chip
LcdDrvClkOut();
//-- Checks parameters
if(( size == 0 )||( addr > 0x13 )||(( 0x13+1 - addr ) < size )){
result = CLDR_ERR_PARA;
}
buf[0] = addr*2;
for (uci = 0, ucd = 1; uci < size; uci++, ucd = ucd + 2) {
buf[ucd] = src[uci] & 0x0f ;
buf[ucd+1] = (src[uci] >> 4) & 0x0f;
}
status = IIC0_MasterStartAndSend( CSLV_ID_LCDSEG, buf, (size * 2) + 1 );
if (status != MD_OK)
result = CLDR_ERR_NACK; */
return ( result );
}
/********************************************************************
; Clears LCD driver segment data
;--------------------------------------------------------------------
; [I N] -
; [OUT] 0= Setting OK, 1 = NACK received, 2 = Busy
;*******************************************************************/
unsigned char LcdDrvSegClr( void )
{
register unsigned char result = CLDR_ERR_NONE;
unsigned short status;
unsigned char buf[41];
unsigned char uc;
/*-- Enables clock output to LCD chip --*/
LcdDrvClkOut();
buf[0] = 0; // start at location zero
for (uc = 1; uc < 41; uc++) {
buf[uc] = 0;
}
status = IIC0_MasterStartAndSend( CSLV_ID_LCDSEG, buf, 41 );
if (status != MD_OK)
result = CLDR_ERR_NACK;
return ( result );
}
/********************************************************************
; Writes to LCD driver control register (1 byte setting)
;--------------------------------------------------------------------
; [I N] addr : control register address value
; data : control register data
; [OUT] 0= Setting OK, 1 = NACK received, 2 = Busy, 3 = Parameter error
;*******************************************************************/
unsigned char LcdDrvCtrWrite1Byte( unsigned char addr, unsigned char data )
{
register unsigned char result = CLDR_ERR_NONE;
unsigned short status;
unsigned char buf[2];
unsigned char uc;
/*-- Enables clock output to LCD chip --*/
LcdDrvClkOut();
buf[0] = addr;
buf[1] = data;
status = IIC0_MasterStartAndSend( CSLV_ID_LCDCTL, buf, 2 );
if (status != MD_OK)
result = CLDR_ERR_NACK;
return ( result );
}
/********************************************************************
; Writes LCD driver segment data (1 byte setting)
;--------------------------------------------------------------------
; [I N] addr : Control register address value
; data : control register data
; [OUT] 0= Setting OK, 1 = NACK received, 2 = Busy, 3 = Parameter error
;*******************************************************************/
unsigned char LcdDrvSegWrite1Byte( unsigned char addr, unsigned char data )
{
register unsigned char result = CLDR_ERR_NONE;
register unsigned char work;
unsigned short status;
unsigned char buf[5];
unsigned char uc;
/*-- Enables clock output to LCD chip --*/
LcdDrvClkOut();
buf[0] = addr;
buf[1] = data & 0x0f;
buf[2] = ( data >>4 ) & 0x0f;
status = IIC0_MasterStartAndSend( CSLV_ID_LCDSEG, buf, 3 );
if (status != MD_OK)
result = CLDR_ERR_NACK;
return ( result );
}
/********************************************************************
; Enables clock and power output to LCD chip
;--------------------------------------------------------------------
; [I N] -
; [OUT] -
;*******************************************************************/
static void LcdDrvClkOut( void )
{
//
PM_LDR_OUT = 0;
LDR_CKS_CLOE = 1;
#if (CLDR_LCDMD==CLDR_LCDMD_VOL)
PO_VLC0_HL = 0; /* Low output (power is supplied to VLC0)*/
#else /*!(CLDR_LCDMD==CLDR_LCDMD_VOL)*/
PO_VLC0_HL = 1; /* High output (power is not supplied to VLC0)*/
#endif/*(CLDR_LCDMD)*/
}
/********************************************************************
; Disables clock and power output to LCD chip
;--------------------------------------------------------------------
; [I N] -
; [OUT] -
;*******************************************************************/
static void LcdDrvClkStop( void )
{
LDR_CKS_CLOE = 0;
PM_LDR_OUT = 1;
PO_VLC0_HL = 0; /*[050701]*/
}
//======================================================================
void SEGNuberDisplay(unsigned char Addr,unsigned char ucData )
{
unsigned char SEGDataBuf[41];
SEGDataBuf[g_pcSEG7AddrMap[Addr]] = g_pcSEG7NumMap[ucData & 0xf0];
SEGDataBuf[g_pcSEG7AddrMap[Addr] + 1] = g_pcSEG7NumMap[(ucData << 4)&0x0f];
}
//======================================================================
//======================================================================
//======================================================================
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?