BayEOS-Arduino  1.8.0_0.0.4
HW_ATmega328P.h
1 // *** Hardwarespecific functions ***
3 {
4 }
5 
6 void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)
7 {
8  switch (mode)
9  {
10  case 1:
11  if (display_serial_mode==SERIAL_4PIN)
12  {
13  if (VH==1)
14  sbi(P_SDA, B_SDA);
15  else
16  cbi(P_SDA, B_SDA);
17  pulse_low(P_SCL, B_SCL);
18  }
19  else
20  {
21  if (VH==1)
22  sbi(P_RS, B_RS);
23  else
24  cbi(P_RS, B_RS);
25  }
26 
27  if (VL & 0x80)
28  sbi(P_SDA, B_SDA);
29  else
30  cbi(P_SDA, B_SDA);
31  pulse_low(P_SCL, B_SCL);
32  if (VL & 0x40)
33  sbi(P_SDA, B_SDA);
34  else
35  cbi(P_SDA, B_SDA);
36  pulse_low(P_SCL, B_SCL);
37  if (VL & 0x20)
38  sbi(P_SDA, B_SDA);
39  else
40  cbi(P_SDA, B_SDA);
41  pulse_low(P_SCL, B_SCL);
42  if (VL & 0x10)
43  sbi(P_SDA, B_SDA);
44  else
45  cbi(P_SDA, B_SDA);
46  pulse_low(P_SCL, B_SCL);
47  if (VL & 0x08)
48  sbi(P_SDA, B_SDA);
49  else
50  cbi(P_SDA, B_SDA);
51  pulse_low(P_SCL, B_SCL);
52  if (VL & 0x04)
53  sbi(P_SDA, B_SDA);
54  else
55  cbi(P_SDA, B_SDA);
56  pulse_low(P_SCL, B_SCL);
57  if (VL & 0x02)
58  sbi(P_SDA, B_SDA);
59  else
60  cbi(P_SDA, B_SDA);
61  pulse_low(P_SCL, B_SCL);
62  if (VL & 0x01)
63  sbi(P_SDA, B_SDA);
64  else
65  cbi(P_SDA, B_SDA);
66  pulse_low(P_SCL, B_SCL);
67  break;
68  case 8:
69  PORTD = VH;
70  pulse_low(P_WR, B_WR);
71  PORTD = VL;
72  pulse_low(P_WR, B_WR);
73  break;
74  case 16:
75  PORTD = VH;
76  cport(PORTC, 0xFC);
77  sport(PORTC, (VL>>6) & 0x03);
78  PORTB = VL & 0x3F;
79  pulse_low(P_WR, B_WR);
80  break;
81  case LATCHED_16:
82  PORTD = VH;
83  cbi(P_ALE, B_ALE);
84  pulse_high(P_ALE, B_ALE);
85  cbi(P_CS, B_CS);
86  PORTD = VL;
87  pulse_low(P_WR, B_WR);
88  sbi(P_CS, B_CS);
89  break;
90  }
91 }
92 
93 void UTFT::_set_direction_registers(byte mode)
94 {
95  DDRD = 0xFF;
96  if (mode==16)
97  {
98  DDRB |= 0x3F;
99  DDRC |= 0x03;
100  }
101 
102 }
103 
104 void UTFT::_fast_fill_16(int ch, int cl, long pix)
105 {
106  long blocks;
107 
108  PORTD = ch;
109  cport(PORTC, 0xFC);
110  sport(PORTC, (cl>>6) & 0x03);
111  PORTB = cl & 0x3F;
112 
113  blocks = pix/16;
114  for (int i=0; i<blocks; i++)
115  {
116  pulse_low(P_WR, B_WR);
117  pulse_low(P_WR, B_WR);
118  pulse_low(P_WR, B_WR);
119  pulse_low(P_WR, B_WR);
120  pulse_low(P_WR, B_WR);
121  pulse_low(P_WR, B_WR);
122  pulse_low(P_WR, B_WR);
123  pulse_low(P_WR, B_WR);
124  pulse_low(P_WR, B_WR);
125  pulse_low(P_WR, B_WR);
126  pulse_low(P_WR, B_WR);
127  pulse_low(P_WR, B_WR);
128  pulse_low(P_WR, B_WR);
129  pulse_low(P_WR, B_WR);
130  pulse_low(P_WR, B_WR);
131  pulse_low(P_WR, B_WR);
132  }
133  if ((pix % 16) != 0)
134  for (int i=0; i<(pix % 16)+1; i++)
135  {
136  pulse_low(P_WR, B_WR);
137  }
138 }
139 
140 void UTFT::_fast_fill_8(int ch, long pix)
141 {
142  long blocks;
143 
144  PORTD = ch;
145 
146  blocks = pix/16;
147  for (int i=0; i<blocks; i++)
148  {
149  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
150  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
151  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
152  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
153  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
154  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
155  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
156  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
157  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
158  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
159  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
160  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
161  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
162  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
163  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
164  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
165  }
166  if ((pix % 16) != 0)
167  for (int i=0; i<(pix % 16)+1; i++)
168  {
169  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
170  }
171 }
void _hw_special_init()
Definition: HW_CC3200.h:2