summaryrefslogtreecommitdiff
path: root/libraries/MultiLCD/hardware/avr/HW_ATmega328P.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/MultiLCD/hardware/avr/HW_ATmega328P.h')
-rw-r--r--libraries/MultiLCD/hardware/avr/HW_ATmega328P.h171
1 files changed, 171 insertions, 0 deletions
diff --git a/libraries/MultiLCD/hardware/avr/HW_ATmega328P.h b/libraries/MultiLCD/hardware/avr/HW_ATmega328P.h
new file mode 100644
index 0000000..bb0cdfd
--- /dev/null
+++ b/libraries/MultiLCD/hardware/avr/HW_ATmega328P.h
@@ -0,0 +1,171 @@
+// *** 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:
+ PORTD = VH;
+ pulse_low(P_WR, B_WR);
+ PORTD = VL;
+ pulse_low(P_WR, B_WR);
+ break;
+ case 16:
+ PORTD = VH;
+ cport(PORTC, 0xFC);
+ sport(PORTC, (VL>>6) & 0x03);
+ PORTB = VL & 0x3F;
+ pulse_low(P_WR, B_WR);
+ break;
+ case LATCHED_16:
+ PORTD = VH;
+ cbi(P_ALE, B_ALE);
+ pulse_high(P_ALE, B_ALE);
+ cbi(P_CS, B_CS);
+ PORTD = VL;
+ pulse_low(P_WR, B_WR);
+ sbi(P_CS, B_CS);
+ break;
+ }
+}
+
+void UTFT::_set_direction_registers(byte mode)
+{
+ DDRD = 0xFF;
+ if (mode==16)
+ {
+ DDRB |= 0x3F;
+ DDRC |= 0x03;
+ }
+
+}
+
+void UTFT::_fast_fill_16(int ch, int cl, long pix)
+{
+ long blocks;
+
+ PORTD = ch;
+ cport(PORTC, 0xFC);
+ sport(PORTC, (cl>>6) & 0x03);
+ PORTB = cl & 0x3F;
+
+ 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;
+
+ PORTD = 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);
+ }
+}