BayEOS-Arduino  1.8.0_0.0.4
HW_SAM3X8E.h
1 // *** Hardwarespecific functions ***
3 {
4 #ifdef EHOUSE_DUE_SHIELD
5  pinMode(24, OUTPUT); digitalWrite(24, HIGH); // Set the TFT_RD pin permanently HIGH as it is not supported by UTFT
6 #endif
7 }
8 
9 void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)
10 {
11  switch (mode)
12  {
13  case 1:
14  if (display_serial_mode==SERIAL_4PIN)
15  {
16  if (VH==1)
17  sbi(P_SDA, B_SDA);
18  else
19  cbi(P_SDA, B_SDA);
20  pulse_low(P_SCL, B_SCL);
21  }
22  else
23  {
24  if (VH==1)
25  sbi(P_RS, B_RS);
26  else
27  cbi(P_RS, B_RS);
28  }
29 
30  if (VL & 0x80)
31  sbi(P_SDA, B_SDA);
32  else
33  cbi(P_SDA, B_SDA);
34  pulse_low(P_SCL, B_SCL);
35  if (VL & 0x40)
36  sbi(P_SDA, B_SDA);
37  else
38  cbi(P_SDA, B_SDA);
39  pulse_low(P_SCL, B_SCL);
40  if (VL & 0x20)
41  sbi(P_SDA, B_SDA);
42  else
43  cbi(P_SDA, B_SDA);
44  pulse_low(P_SCL, B_SCL);
45  if (VL & 0x10)
46  sbi(P_SDA, B_SDA);
47  else
48  cbi(P_SDA, B_SDA);
49  pulse_low(P_SCL, B_SCL);
50  if (VL & 0x08)
51  sbi(P_SDA, B_SDA);
52  else
53  cbi(P_SDA, B_SDA);
54  pulse_low(P_SCL, B_SCL);
55  if (VL & 0x04)
56  sbi(P_SDA, B_SDA);
57  else
58  cbi(P_SDA, B_SDA);
59  pulse_low(P_SCL, B_SCL);
60  if (VL & 0x02)
61  sbi(P_SDA, B_SDA);
62  else
63  cbi(P_SDA, B_SDA);
64  pulse_low(P_SCL, B_SCL);
65  if (VL & 0x01)
66  sbi(P_SDA, B_SDA);
67  else
68  cbi(P_SDA, B_SDA);
69  pulse_low(P_SCL, B_SCL);
70  break;
71  case 8:
72 #if defined(CTE_DUE_SHIELD) || defined(EHOUSE_DUE_SHIELD)
73  REG_PIOC_CODR=0xFF000;
74  REG_PIOC_SODR=(VH<<12) & 0xFF000;
75  pulse_low(P_WR, B_WR);
76  REG_PIOC_CODR=0xFF000;
77  REG_PIOC_SODR=(VL<<12) & 0xFF000;
78  pulse_low(P_WR, B_WR);
79 #else
80  REG_PIOA_CODR=0x0000C000;
81  REG_PIOD_CODR=0x0000064F;
82  REG_PIOA_SODR=(VH & 0x06)<<13;
83  (VH & 0x01) ? REG_PIOB_SODR = 0x4000000 : REG_PIOB_CODR = 0x4000000;
84  REG_PIOD_SODR=((VH & 0x78)>>3) | ((VH & 0x80)>>1);
85  pulse_low(P_WR, B_WR);
86 
87  REG_PIOA_CODR=0x0000C000;
88  REG_PIOD_CODR=0x0000064F;
89  REG_PIOA_SODR=(VL & 0x06)<<13;
90  (VL & 0x01) ? REG_PIOB_SODR = 0x4000000 : REG_PIOB_CODR = 0x4000000;
91  REG_PIOD_SODR=((VL & 0x78)>>3) | ((VL & 0x80)>>1);
92  pulse_low(P_WR, B_WR);
93 #endif
94  break;
95  case 16:
96 #if defined(CTE_DUE_SHIELD)
97  REG_PIOC_CODR=0xFF1FE;
98  REG_PIOC_SODR=(VL<<1) & 0x1FE;
99  REG_PIOC_SODR=(VH<<12) & 0xFF000;
100 #elif defined(EHOUSE_DUE_SHIELD)
101  PIOC->PIO_ODSR = ((PIOC->PIO_ODSR&(~0x000FF3FC)) | ((((uint32_t)VL)<<2) | (((uint32_t)VH)<<12)));
102 #else
103  REG_PIOA_CODR=0x0000C080;
104  REG_PIOC_CODR=0x0000003E;
105  REG_PIOD_CODR=0x0000064F;
106  REG_PIOA_SODR=((VH & 0x06)<<13) | ((VL & 0x40)<<1);
107  (VH & 0x01) ? REG_PIOB_SODR = 0x4000000 : REG_PIOB_CODR = 0x4000000;
108  REG_PIOC_SODR=((VL & 0x01)<<5) | ((VL & 0x02)<<3) | ((VL & 0x04)<<1) | ((VL & 0x08)>>1) | ((VL & 0x10)>>3);
109  REG_PIOD_SODR=((VH & 0x78)>>3) | ((VH & 0x80)>>1) | ((VL & 0x20)<<5) | ((VL & 0x80)<<2);
110 #endif
111  pulse_low(P_WR, B_WR);
112  break;
113  case LATCHED_16:
114  asm("nop"); // Mode is unsupported
115  break;
116  }
117 }
118 
119 void UTFT::_set_direction_registers(byte mode)
120 {
121  if (mode!=LATCHED_16)
122  {
123 #if defined(CTE_DUE_SHIELD)
124  if (mode==16)
125  {
126  REG_PIOC_OER=0x000FF1FE;
127  }
128  else
129  REG_PIOC_OER=0x000FF000;
130 #elif defined(EHOUSE_DUE_SHIELD)
131  if (mode==16)
132  {
133  REG_PIOC_OER=0x000FF3FC;
134  REG_PIOC_OWER=0x000FF3FC;
135  }
136  else
137  REG_PIOC_OER=0x000FF000;
138 #else
139  REG_PIOA_OER=0x0000c000; //PA14,PA15 enable
140  REG_PIOB_OER=0x04000000; //PB26 enable
141  REG_PIOD_OER=0x0000064f; //PD0-3,PD6,PD9-10 enable
142  if (mode==16)
143  {
144  REG_PIOA_OER=0x00000080; //PA7 enable
145  REG_PIOC_OER=0x0000003e; //PC1 - PC5 enable
146  }
147 #endif
148  }
149  else
150  {
151  asm("nop"); // Mode is unsupported
152  }
153 }
154 
155 void UTFT::_fast_fill_16(int ch, int cl, long pix)
156 {
157  long blocks;
158 
159 #if defined(CTE_DUE_SHIELD)
160  REG_PIOC_CODR=0xFF1FE;
161  REG_PIOC_SODR=(cl<<1) & 0x1FE;
162  REG_PIOC_SODR=(ch<<12) & 0xFF000;
163 #elif defined(EHOUSE_DUE_SHIELD)
164  PIOC->PIO_ODSR = ((PIOC->PIO_ODSR&(~0x000FF3FC)) | ((((uint32_t)cl)<<2) | (((uint32_t)ch)<<12)));
165 #else
166  REG_PIOA_CODR=0x0000C080;
167  REG_PIOC_CODR=0x0000003E;
168  REG_PIOD_CODR=0x0000064F;
169  REG_PIOA_SODR=((ch & 0x06)<<13) | ((cl & 0x40)<<1);
170  (ch & 0x01) ? REG_PIOB_SODR = 0x4000000 : REG_PIOB_CODR = 0x4000000;
171  REG_PIOC_SODR=((cl & 0x01)<<5) | ((cl & 0x02)<<3) | ((cl & 0x04)<<1) | ((cl & 0x08)>>1) | ((cl & 0x10)>>3);
172  REG_PIOD_SODR=((ch & 0x78)>>3) | ((ch & 0x80)>>1) | ((cl & 0x20)<<5) | ((cl & 0x80)<<2);
173 #endif
174 
175  blocks = pix/16;
176  for (int i=0; i<blocks; i++)
177  {
178  pulse_low(P_WR, B_WR);
179  pulse_low(P_WR, B_WR);
180  pulse_low(P_WR, B_WR);
181  pulse_low(P_WR, B_WR);
182  pulse_low(P_WR, B_WR);
183  pulse_low(P_WR, B_WR);
184  pulse_low(P_WR, B_WR);
185  pulse_low(P_WR, B_WR);
186  pulse_low(P_WR, B_WR);
187  pulse_low(P_WR, B_WR);
188  pulse_low(P_WR, B_WR);
189  pulse_low(P_WR, B_WR);
190  pulse_low(P_WR, B_WR);
191  pulse_low(P_WR, B_WR);
192  pulse_low(P_WR, B_WR);
193  pulse_low(P_WR, B_WR);
194  }
195  if ((pix % 16) != 0)
196  for (int i=0; i<(pix % 16)+1; i++)
197  {
198  pulse_low(P_WR, B_WR);
199  }
200 }
201 
202 void UTFT::_fast_fill_8(int ch, long pix)
203 {
204  long blocks;
205 
206 #if defined(CTE_DUE_SHIELD) || defined(EHOUSE_DUE_SHIELD)
207  REG_PIOC_CODR=0xFF000;
208  REG_PIOC_SODR=(ch<<12) & 0xFF000;
209 #else
210  REG_PIOA_CODR=0x0000C000;
211  REG_PIOD_CODR=0x0000064F;
212  REG_PIOA_SODR=(ch & 0x06)<<13;
213  (ch & 0x01) ? REG_PIOB_SODR = 0x4000000 : REG_PIOB_CODR = 0x4000000;
214  REG_PIOD_SODR=((ch & 0x78)>>3) | ((ch & 0x80)>>1);
215 #endif
216 
217  blocks = pix/16;
218  for (int i=0; i<blocks; i++)
219  {
220  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
221  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
222  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
223  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
224  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
225  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
226  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
227  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
228  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
229  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
230  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
231  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
232  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
233  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
234  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
235  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
236  }
237  if ((pix % 16) != 0)
238  for (int i=0; i<(pix % 16)+1; i++)
239  {
240  pulse_low(P_WR, B_WR);pulse_low(P_WR, B_WR);
241  }
242 }
void _hw_special_init()
Definition: HW_CC3200.h:2