BayEOS-Arduino  1.8.0_0.0.4
HW_ATmega32U4.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  cport(PORTC, 0xBF);
70  cport(PORTD, 0x60);
71  cport(PORTE, 0xBF);
72  PORTC += ((VH & 0x20)<<1);
73  PORTD += ((VH & 0x40)<<1) + (VH & 0x10) + ((VH & 0x08)>>3) + ((VH & 0x04)>>1) + ((VH & 0x03)<<2);
74  PORTE += ((VH & 0x80)>>1);
75  pulse_low(P_WR, B_WR);
76 
77  cport(PORTC, 0xBF);
78  cport(PORTD, 0x60);
79  cport(PORTE, 0xBF);
80  PORTC += ((VL & 0x20)<<1);
81  PORTD += ((VL & 0x40)<<1) + (VL & 0x10) + ((VL & 0x08)>>3) + ((VL & 0x04)>>1) + ((VL & 0x03)<<2);
82  PORTE += ((VL & 0x80)>>1);
83  pulse_low(P_WR, B_WR);
84  break;
85  case 16:
86  cport(PORTB, 0x0F);
87  cport(PORTC, 0x3F);
88  cport(PORTD, 0x20);
89  cport(PORTE, 0xBF);
90  cport(PORTF, 0x3F);
91 
92  PORTB |= ((VL & 0x0F)<<4);
93  PORTC |= ((VL & 0x20)<<2) + ((VH & 0x20)<<1);
94  PORTD |= ((VH & 0x40)<<1) + (VH & 0x10) + ((VH & 0x08)>>3) + ((VH & 0x04)>>1) + ((VH & 0x03)<<2) + ((VL & 0x10)<<2);
95  PORTE |= ((VH & 0x80)>>1);
96  PORTF |= ((VL & 0x80)>>1) + ((VL & 0x40)<<1);
97 
98  pulse_low(P_WR, B_WR);
99  break;
100  case LATCHED_16:
101  cport(PORTC, 0xBF);
102  cport(PORTD, 0x60);
103  cport(PORTE, 0xBF);
104  PORTC += ((VH & 0x20)<<1);
105  PORTD += ((VH & 0x40)<<1) + (VH & 0x10) + ((VH & 0x08)>>3) + ((VH & 0x04)>>1) + ((VH & 0x03)<<2);
106  PORTE += ((VH & 0x80)>>1);
107  cbi(P_ALE, B_ALE);
108  pulse_high(P_ALE, B_ALE);
109  cbi(P_CS, B_CS);
110  cport(PORTC, 0xBF);
111  cport(PORTD, 0x60);
112  cport(PORTE, 0xBF);
113  PORTC += ((VL & 0x20)<<1);
114  PORTD += ((VL & 0x40)<<1) + (VL & 0x10) + ((VL & 0x08)>>3) + ((VL & 0x04)>>1) + ((VL & 0x03)<<2);
115  PORTE += ((VL & 0x80)>>1);
116  pulse_low(P_WR, B_WR);
117  sbi(P_CS, B_CS);
118  break;
119  }
120 }
121 
122 void UTFT::_set_direction_registers(byte mode)
123 {
124  switch (mode)
125  {
126  case 8:
127  case LATCHED_16:
128  DDRC |= 0x40;
129  DDRD |= 0x9F;
130  DDRE |= 0x40;
131  break;
132  case 16:
133  DDRB |= 0xF0;
134  DDRC |= 0xC0;
135  DDRD |= 0xDF;
136  DDRE |= 0x40;
137  DDRF |= 0xC0;
138  break;
139  }
140 }
141 
142 void UTFT::_fast_fill_16(int ch, int cl, long pix)
143 {
144  long blocks;
145 
146  cport(PORTB, 0x0F);
147  cport(PORTC, 0x3F);
148  cport(PORTD, 0x20);
149  cport(PORTE, 0xBF);
150  cport(PORTF, 0x3F);
151 
152  PORTB |= ((cl & 0x0F)<<4);
153  PORTC |= ((cl & 0x20)<<2) + ((ch & 0x20)<<1);
154  PORTD |= ((ch & 0x40)<<1) + (ch & 0x10) + ((ch & 0x08)>>3) + ((ch & 0x04)>>1) + ((ch & 0x03)<<2) + ((cl & 0x10)<<2);
155  PORTE |= ((ch & 0x80)>>1);
156  PORTF |= ((cl & 0x80)>>1) + ((cl & 0x40)<<1);
157 
158  blocks = pix/16;
159  for (int i=0; i<blocks; i++)
160  {
161  pulse_low(P_WR, B_WR);
162  pulse_low(P_WR, B_WR);
163  pulse_low(P_WR, B_WR);
164  pulse_low(P_WR, B_WR);
165  pulse_low(P_WR, B_WR);
166  pulse_low(P_WR, B_WR);
167  pulse_low(P_WR, B_WR);
168  pulse_low(P_WR, B_WR);
169  pulse_low(P_WR, B_WR);
170  pulse_low(P_WR, B_WR);
171  pulse_low(P_WR, B_WR);
172  pulse_low(P_WR, B_WR);
173  pulse_low(P_WR, B_WR);
174  pulse_low(P_WR, B_WR);
175  pulse_low(P_WR, B_WR);
176  pulse_low(P_WR, B_WR);
177  }
178  if ((pix % 16) != 0)
179  for (int i=0; i<(pix % 16)+1; i++)
180  {
181  pulse_low(P_WR, B_WR);
182  }
183 }
184 
185 void UTFT::_fast_fill_8(int ch, long pix)
186 {
187  long blocks;
188 
189  cport(PORTC, 0xBF);
190  cport(PORTD, 0x60);
191  cport(PORTE, 0xBF);
192 
193  PORTC |= ((ch & 0x20)<<1);
194  PORTD |= ((ch & 0x40)<<1) + (ch & 0x10) + ((ch & 0x08)>>3) + ((ch & 0x04)>>1) + ((ch & 0x03)<<2);
195  PORTE |= ((ch & 0x80)>>1);
196 
197  blocks = pix/16;
198  for (int i=0; i<blocks; i++)
199  {
200  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
201  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
202  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
203  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
204  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
205  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
206  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
207  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
208  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
209  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
210  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
211  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
212  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
213  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
214  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
215  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
216  }
217  if ((pix % 16) != 0)
218  for (int i=0; i<(pix % 16)+1; i++)
219  {
220  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
221  }
222 }
void _hw_special_init()
Definition: HW_CC3200.h:2