You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
3.8 KiB
179 lines
3.8 KiB
// *** Hardwarespecific functions *** |
|
void UTFT::_hw_special_init() |
|
{ |
|
} |
|
|
|
void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode) |
|
{ |
|
switch (mode) |
|
{ |
|
case 1: |
|
if (display_serial_mode==SERIAL_4PIN) |
|
{ |
|
if (VH==1) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
} |
|
else |
|
{ |
|
if (VH==1) |
|
sbi(P_RS, B_RS); |
|
else |
|
cbi(P_RS, B_RS); |
|
} |
|
|
|
if (VL & 0x80) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x40) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x20) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x10) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x08) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x04) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x02) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
if (VL & 0x01) |
|
sbi(P_SDA, B_SDA); |
|
else |
|
cbi(P_SDA, B_SDA); |
|
pulse_low(P_SCL, B_SCL); |
|
break; |
|
case 8: |
|
HWREG(GPIOA0_BASE + 0x03FC) = VH; |
|
pulse_low(P_WR, B_WR); |
|
HWREG(GPIOA0_BASE + 0x03FC) = VL; |
|
pulse_low(P_WR, B_WR); |
|
break; |
|
case 16: |
|
HWREG(GPIOA0_BASE + 0x03FC) = VH; |
|
HWREG(GPIOA1_BASE + 0x03FC) = VL; |
|
pulse_low(P_WR, B_WR); |
|
break; |
|
case LATCHED_16: |
|
asm("nop"); // Mode is unsupported |
|
break; |
|
} |
|
} |
|
|
|
void UTFT::LCD_Write_Bus_8(char VL) |
|
{ |
|
HWREG(GPIOA0_BASE + 0x03FC) = VL; |
|
pulse_low(P_WR, B_WR); |
|
} |
|
|
|
void UTFT::_set_direction_registers(byte mode) |
|
{ |
|
if (mode!=LATCHED_16) |
|
{ |
|
HWREG(GPIOA0_BASE + 0x0400) = 0xFF; |
|
for (int i = 0xA0; i <= 0xBC; i+=4) |
|
HWREG(0x4402E000 + i) = ((HWREG(0x4402E000 + i) & 0xFFFFFFF0) & ~(3<<10)); |
|
if (mode==16) |
|
{ |
|
HWREG(GPIOA1_BASE + 0x0400) = 0xFF; |
|
for (int i = 0xC0; i <= 0xDC; i+=4) |
|
HWREG(0x4402E000 + i) = ((HWREG(0x4402E000 + i) & 0xFFFFFFF0) & ~(3<<10)); |
|
} |
|
} |
|
else |
|
{ |
|
asm("nop"); // Mode is unsupported |
|
} |
|
} |
|
|
|
void UTFT::_fast_fill_16(int ch, int cl, long pix) |
|
{ |
|
long blocks; |
|
|
|
HWREG(GPIOA0_BASE + 0x03FC) = ch; |
|
HWREG(GPIOA1_BASE + 0x03FC) = cl; |
|
blocks = pix/16; |
|
for (int i=0; i<blocks; i++) |
|
{ |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR); |
|
} |
|
if ((pix % 16) != 0) |
|
for (int i=0; i<(pix % 16)+1; i++) |
|
{ |
|
pulse_low(P_WR, B_WR); |
|
} |
|
} |
|
|
|
void UTFT::_fast_fill_8(int ch, long pix) |
|
{ |
|
long blocks; |
|
|
|
HWREG(GPIOA0_BASE + 0x03FC) = ch; |
|
blocks = pix/16; |
|
for (int i=0; i<blocks; i++) |
|
{ |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
} |
|
if ((pix % 16) != 0) |
|
for (int i=0; i<(pix % 16)+1; i++) |
|
{ |
|
pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR); |
|
} |
|
} |
|
|
|
volatile uint32_t* UTFT::portOutputRegister(int value) |
|
{ |
|
return portBASERegister(value); |
|
} |