BayEOS-Arduino  1.8.0_0.0.4
HW_ATmega1284P.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 (PORTD, 0xF0);
70  sport (PORTD, (VH & 0x0F));
71  cport (PORTB, 0xF0);
72  sport (PORTB, (VH & 0xF0)>>4);
73  pulse_low(P_WR, B_WR);
74  cport (PORTD, 0xF0);
75  sport (PORTD, (VL & 0x0F));
76  cport (PORTB, 0xF0);
77  sport (PORTB, (VL & 0xF0)>>4);
78  pulse_low(P_WR, B_WR);
79  break;
80  case 16:
81  cport (PORTD, 0x90);
82  sport (PORTD, (VH & 0x0F) | ((VL & 0x03)<<5));
83  PORTB = ((VH & 0xF0)>>4) | ((VL & 0x3C)<<2);
84  cport (PORTA, 0x3F);
85  sport (PORTA, ((VL & 0x40)<<1) | ((VL & 0x80)>>1));
86  pulse_low(P_WR, B_WR);
87  break;
88  case LATCHED_16:
89  cport (PORTD, 0xF0);
90  sport (PORTD, (VH & 0x0F));
91  cport (PORTB, 0xF0);
92  sport (PORTB, (VH & 0xF0)>>4);
93  cbi(P_ALE, B_ALE);
94  pulse_high(P_ALE, B_ALE);
95  cbi(P_CS, B_CS);
96  cport (PORTD, 0xF0);
97  sport (PORTD, (VL & 0x0F));
98  cport (PORTB, 0xF0);
99  sport (PORTB, (VL & 0xF0)>>4);
100  pulse_low(P_WR, B_WR);
101  sbi(P_CS, B_CS);
102  break;
103  }
104 }
105 
106 void UTFT::_set_direction_registers(byte mode)
107 {
108  DDRB |= 0x0F;
109  DDRD |= 0x0F;
110  if (mode==16)
111  {
112  DDRB = 0xFF;
113  DDRD |= 0x6F;
114  DDRA |= 0xC0;
115  }
116 
117 }
118 
119 void UTFT::_fast_fill_16(int ch, int cl, long pix)
120 {
121  long blocks;
122 
123  cport (PORTD, 0x90);
124  sport (PORTD, (ch & 0x0F) | ((cl & 0x03)<<5));
125  PORTB = ((ch & 0xF0)>>4) | ((cl & 0x3C)<<2);
126  cport (PORTA, 0x3F);
127  sport (PORTA, ((cl & 0x40)<<1) | ((cl & 0x80)>>1));
128 
129  blocks = pix/16;
130  for (int i=0; i<blocks; i++)
131  {
132  pulse_low(P_WR, B_WR);
133  pulse_low(P_WR, B_WR);
134  pulse_low(P_WR, B_WR);
135  pulse_low(P_WR, B_WR);
136  pulse_low(P_WR, B_WR);
137  pulse_low(P_WR, B_WR);
138  pulse_low(P_WR, B_WR);
139  pulse_low(P_WR, B_WR);
140  pulse_low(P_WR, B_WR);
141  pulse_low(P_WR, B_WR);
142  pulse_low(P_WR, B_WR);
143  pulse_low(P_WR, B_WR);
144  pulse_low(P_WR, B_WR);
145  pulse_low(P_WR, B_WR);
146  pulse_low(P_WR, B_WR);
147  pulse_low(P_WR, B_WR);
148  }
149  if ((pix % 16) != 0)
150  for (int i=0; i<(pix % 16)+1; i++)
151  {
152  pulse_low(P_WR, B_WR);
153  }
154 }
155 
156 void UTFT::_fast_fill_8(int ch, long pix)
157 {
158  long blocks;
159 
160  cport (PORTD, 0xF0);
161  sport (PORTD, (ch & 0x0F));
162  cport (PORTB, 0xF0);
163  sport (PORTB, (ch & 0xF0)>>4);
164 
165  blocks = pix/16;
166  for (int i=0; i<blocks; i++)
167  {
168  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
169  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
170  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
171  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
172  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
173  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
174  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
175  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
176  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
177  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
178  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
179  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
180  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
181  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
182  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
183  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
184  }
185  if ((pix % 16) != 0)
186  for (int i=0; i<(pix % 16)+1; i++)
187  {
188  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
189  }
190 }
void _hw_special_init()
Definition: HW_CC3200.h:2