📄 t6963.c
字号:
//=============================================================================
// File: T6963.C - V1.00
// Rem.: The ACPRD Project Page on the Web -> http://hc12web.de/acprd
//=============================================================================
//-- Includes -----------------------------------------------------------------
#include "datatypes.h"
#include "hcs12dp256.h"
#include "t6963.h"
//-- Defines ------------------------------------------------------------------
// Status bits
#define T6963_STA0 0x01 // T6963 Status Bit STA0
#define T6963_STA1 0x02 // T6963 Status Bit STA1
#define T6963_STA2 0x04 // T6963 Status Bit STA2
#define T6963_STA3 0x08 // T6963 Status Bit STA3
//-- Static Vars --------------------------------------------------------------
//-- Code ---------------------------------------------------------------------
UINT8 _statT6963(void) {
UINT8 status;
T6963_DDDR = 0x00; // data lines all input
T6963_CPORT &= ~(T6963_RD | T6963_CE);
// tACC min 150ns
NOP();
NOP();
NOP();
status = T6963_DPORT;
T6963_CPORT |= T6963_RD | T6963_CE;
T6963_DDDR = 0xff; // back to output
return status;
}
//-----------------------------------------------------------------------------
void _cmdT6963(UINT8 cmd) {
// status check - no loop time limit!!
while(~_statT6963() & (T6963_STA0 | T6963_STA1)) ;
//
T6963_DPORT = cmd;
T6963_CPORT &= ~(T6963_WR | T6963_CE);
// tCE min 80ns
T6963_CPORT |= T6963_WR | T6963_CE;
}
//-----------------------------------------------------------------------------
void _datT6963(UINT8 dat) {
// status check - no loop time limit!!
while(~_statT6963() & (T6963_STA0 | T6963_STA1)) ;
//
T6963_DPORT = dat;
T6963_CPORT &= ~T6963_CD;
T6963_CPORT &= ~(T6963_WR | T6963_CE);
// tCE min 80ns
T6963_CPORT |= T6963_WR | T6963_CE;
// tCDH min 10ns
T6963_CPORT |= T6963_CD;
}
//-----------------------------------------------------------------------------
void _writeBlockT6963(const UINT8 *src, UINT16 mode, UINT16 addr, UINT16 size) {
UINT16 i;
UINT8 c, sta3;
// Address Pointer Set
_datT6963(addr & 0xff);
_datT6963(addr >> 8);
_cmdT6963(0x24);
// Data Auto Write Set
_cmdT6963(0xb0);
// Transfer screen buffer
i = size;
do {
// status check - no loop time limit!!
T6963_DDDR = 0x00; // data lines all input
do {
T6963_CPORT &= ~(T6963_RD | T6963_CE);
// tACC min 150ns
NOP();
NOP();
NOP();
sta3 = T6963_DPORT & T6963_STA3;
T6963_CPORT |= T6963_RD | T6963_CE;
} while(sta3 == 0);
T6963_DDDR = 0xff; // back to output
//
switch(mode) {
case T6963_TEXTMODE:
src++;
c = *src;
if(c < 0x80) c -= 0x20;
T6963_DPORT = c;
break;
case T6963_ATTRMODE:
T6963_DPORT = *src;
src++;
break;
default: // T6963_RAWMODE
T6963_DPORT = *src;
break;
}
T6963_CPORT &= ~(T6963_CD | T6963_WR | T6963_CE);
// tCD min 120ns, tCE min 80ns
src++;
T6963_CPORT |= T6963_WR | T6963_CE;
// tCDH min 10ns
T6963_CPORT |= T6963_CD;
} while(--i);
// Auto Reset
// status check - no loop time limit!!
while(~_statT6963() & T6963_STA3) ;
T6963_DPORT = 0xb2;
T6963_CPORT &= ~(T6963_WR | T6963_CE);
// tCE min 80ns
T6963_CPORT |= T6963_WR | T6963_CE;
}
//-----------------------------------------------------------------------------
void initT6963(const UINT8 *font) {
T6963_CPORT |= T6963_WR | T6963_RD | T6963_CE | T6963_CD;
T6963_CDDR |= T6963_WR | T6963_RD | T6963_CE | T6963_CD;
T6963_DPORT = 0x00;
T6963_DDDR = 0xff;
// Text Home Address Set
_datT6963(T6963_TBASE & 0xff);
_datT6963(T6963_TBASE >> 8);
_cmdT6963(0x40);
// Text Area Set (Bytes per Display Line)
_datT6963(T6963_TCOLS & 0xff);
_datT6963(T6963_TCOLS >> 8);
_cmdT6963(0x41);
// Graphic Home Address Set
_datT6963(T6963_GBASE & 0xff);
_datT6963(T6963_GBASE >> 8);
_cmdT6963(0x42);
// Graphic Area Set (Bytes per Display Line)
// _datT6963(T6963_GCOLS & 0xff);
// _datT6963(T6963_GCOLS >> 8);
// Text Attribute Area Set (Bytes per Display Line)
_datT6963(T6963_TCOLS & 0xff);
_datT6963(T6963_TCOLS >> 8);
_cmdT6963(0x43);
// Mode Set (EXOR, int.CG)
// _cmdT6963(0x81);
// Mode Set (Text attribute mode, int.CG)
_cmdT6963(0x84);
// Display Mode (Text=1 Graph=0 Curs=0)
// _cmdT6963(0x94);
// Display Mode (Text=1 Graph=1 Curs=0)
_cmdT6963(0x9c);
// install user supplied font (upper half only)
if(font) {
// Offset Register Set
_datT6963(T6963_CGBASE >> 11);
_datT6963(0x00);
_cmdT6963(0x22);
_writeBlockT6963(font, T6963_RAWMODE, T6963_CGBASE + 0x0400, T6963_CGSIZE / 2);
}
}
//-----------------------------------------------------------------------------
void refreshT6963c(void *tbuf) {
_writeBlockT6963((UINT8 *)tbuf, T6963_TEXTMODE, T6963_TBASE, T6963_TSIZE);
}
void refreshT6963a(void *tbuf) {
_writeBlockT6963((UINT8 *)tbuf, T6963_ATTRMODE, T6963_GBASE, T6963_TSIZE);
}
//=============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -