?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*****************************************************************************
2 * Module for Microchip Graphics Library
3 * EPMP driver
4 *****************************************************************************
5 * FileName: gfxepmp.h
6 * Dependencies: Graphics.h
7 * Processor: PIC24, PIC32
8 * Compiler: MPLAB C30, MPLAB C32
9 * Linker: MPLAB LINK30, MPLAB LINK32
10 * Company: Microchip Technology Incorporated
11 *
12 * Software License Agreement
13 *
14 * Copyright © 2010 Microchip Technology Inc. All rights reserved.
15 * Microchip licenses to you the right to use, modify, copy and distribute
16 * Software only when embedded on a Microchip microcontroller or digital
17 * signal controller, which is integrated into your product or third party
18 * product (pursuant to the sublicense terms in the accompanying license
19 * agreement).
20 *
21 * You should refer to the license agreement accompanying this Software
22 * for additional information regarding your rights and obligations.
23 *
24 * SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY
25 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
26 * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
27 * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
28 * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
29 * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
30 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
31 * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
32 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
33 * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
34 * OR OTHER SIMILAR COSTS.
35 *
36 * Author Date Comment
37 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 * Anton Alkhimenok 01/12/10
39 *****************************************************************************/
40 #ifndef _GFX_EPMP_H_FILE
41 #define _GFX_EPMP_H_FILE
42  
43 #include "Graphics\Graphics.h"
44 #include "Compiler.h"
45  
46 #ifdef USE_GFX_EPMP
47  
48 #ifdef USE_16BIT_PMP
49 extern volatile __eds__ WORD __attribute__((space(eds),address(0x00020000ul),noload)) pmp_data;
50 #else
51 extern volatile __eds__ BYTE __attribute__((space(eds),address(0x00020000ul),noload)) pmp_data;
52 #endif
53  
54 /*********************************************************************
55 * Macros: PMPWaitBusy()
56 *
57 * Overview: waits for PMP cycle end.
58 *
59 * PreCondition: none
60 *
61 * Input: none
62 *
63 * Output: none
64 *
65 * Side Effects: none
66 *
67 ********************************************************************/
68 #define PMPWaitBusy() while(PMCON2bits.BUSY);
69  
70 /*********************************************************************
71 * Function: void DeviceSetCommand()
72 *
73 * Overview: set RS line to access a control register space
74 *
75 * PreCondition: none
76 *
77 * Input: none
78 *
79 * Output: none
80 *
81 * Side Effects: none
82 *
83 ********************************************************************/
84 extern inline void __attribute__ ((always_inline)) DeviceSetCommand(){
85 RS_LAT_BIT = 0;
86 }
87  
88 /*********************************************************************
89 * Function: void DeviceSetData()
90 *
91 * Overview: set RS line to access a data space
92 *
93 * PreCondition: none
94 *
95 * Input: none
96 *
97 * Output: none
98 *
99 * Side Effects: none
100 *
101 ********************************************************************/
102 extern inline void __attribute__ ((always_inline)) DeviceSetData(){
103 RS_LAT_BIT = 1;
104 }
105  
106 /*********************************************************************
107 * Function: void DeviceSelect()
108 *
109 * Overview: asserts the chip select line
110 *
111 * PreCondition: none
112 *
113 * Input: none
114 *
115 * Output: none
116 *
117 * Side Effects: none
118 *
119 ********************************************************************/
120 extern inline void __attribute__ ((always_inline)) DeviceSelect(){
121 CS_LAT_BIT = 0;
122 }
123  
124 /*********************************************************************
125 * Function: void DeviceDeselect()
126 *
127 * Overview: puts the chip select line in inactive state
128 *
129 * PreCondition: none
130 *
131 * Input: none
132 *
133 * Output: none
134 *
135 * Side Effects: none
136 *
137 ********************************************************************/
138 extern inline void __attribute__ ((always_inline)) DeviceDeselect(){
139 CS_LAT_BIT = 1;
140 }
141  
142 /*********************************************************************
143 * Macros: DeviceWrite(data)
144 *
145 * PreCondition: none
146 *
147 * Input: data - value to be written to RAM
148 *
149 * Output: none
150 *
151 * Side Effects: none
152 *
153 * Overview: writes data into controller's RAM
154 *
155 * Note: chip select should be enabled
156 *
157 ********************************************************************/
158 #ifdef USE_16BIT_PMP
159  
160 extern inline void __attribute__ ((always_inline)) DeviceWrite(WORD data)
161 {
162 pmp_data = data;
163 PMPWaitBusy();
164 }
165  
166 #else
167  
168 extern inline void __attribute__ ((always_inline)) DeviceWrite(BYTE data)
169 {
170 pmp_data = data;
171 PMPWaitBusy();
172 }
173  
174 #endif
175  
176 /*********************************************************************
177 * Macros: DeviceRead()
178 *
179 * PreCondition: none
180 *
181 * Input: none
182 *
183 * Output: data read
184 *
185 * Side Effects: none
186 *
187 * Overview: reads data from controller's RAM
188 *
189 * Note: chip select should be enabled
190 *
191 ********************************************************************/
192 #ifdef USE_16BIT_PMP
193  
194 extern inline WORD __attribute__ ((always_inline)) DeviceRead()
195 {
196 WORD value;
197 value = pmp_data;
198 PMPWaitBusy();
199 return PMDIN1;
200 }
201  
202 #else
203  
204  
205 extern inline BYTE __attribute__ ((always_inline)) DeviceRead(){
206 BYTE value;
207 value = pmp_data;
208 PMPWaitBusy();
209 return PMDIN1;
210 }
211  
212 #endif
213  
214  
215 /*********************************************************************
216 * Function: DeviceInit()
217 *
218 * PreCondition: none
219 *
220 * Input: none
221 *
222 * Output: none
223 *
224 * Side Effects: none
225 *
226 * Overview: initializes the device
227 *
228 * Note: none
229 *
230 ********************************************************************/
231  
232 extern inline void __attribute__ ((always_inline)) DeviceInit(void)
233 {
234 RST_LAT_BIT = 0; // hold in reset by default
235 RST_TRIS_BIT = 0; // enable RESET line
236 RS_TRIS_BIT = 0; // enable RS line
237 CS_LAT_BIT = 1; // not selected by default
238 CS_TRIS_BIT = 0; // enable chip select line
239  
240 ANSDbits.ANSD7 = 0; // PMD15
241 ANSDbits.ANSD6 = 0; // PMD14
242 ANSFbits.ANSF0 = 0; // PMD11
243  
244 ANSBbits.ANSB15 = 0; // PMA0
245 ANSBbits.ANSB14 = 0; // PMA1
246 ANSGbits.ANSG9 = 0; // PMA2
247 ANSBbits.ANSB13 = 0; // PMA10
248 ANSBbits.ANSB12 = 0; // PMA11
249 ANSBbits.ANSB11 = 0; // PMA12
250 ANSBbits.ANSB10 = 0; // PMA13
251 ANSAbits.ANSA7 = 0; // PMA17
252 ANSGbits.ANSG6 = 0; // PMA18
253  
254 PMCON1bits.ADRMUX = 0; // address is not multiplexed
255 PMCON1bits.MODE = 3; // master mode
256 PMCON1bits.CSF = 0; // PMCS1 pin used for chip select 1, PMCS2 pin used for chip select 2
257 PMCON1bits.ALP = 0; // set address latch strobes to high active level (for sn74lvc16373)
258 PMCON1bits.ALMODE = 0; // "smart" address strobes are not used
259 PMCON1bits.BUSKEEP = 1; // bus keeper is used
260  
261 PMCS1BS = 0x0200; // CS1 start address
262 PMCS2BS = 0xff00; // set CS1 end address and CS2 start address
263 PMCON2bits.RADDR = 0xff; // set CS2 end address
264  
265 PMCON4 = 0; // PMA0 - PMA15 address lines are disabled
266 PMCON3 |= 0; // PMA16 - PMA17 address line is disabled
267  
268 PMCS2CFbits.CSDIS = 1; // disable CS2 functionality
269  
270 PMCS1CFbits.CSDIS = 0; // enable CS
271 PMCS1CFbits.CSP = 0; // CS active low
272 PMCS1CFbits.CSPTEN = 0; // disable CS port
273 PMCS1CFbits.BEP = 0; // byte enable active low
274 PMCS1CFbits.WRSP = 0; // write strobe active low
275 PMCS1CFbits.RDSP = 0; // read strobe active low
276 PMCS1CFbits.SM = 0; // read and write strobes on separate lines
277  
278 #ifdef USE_16BIT_PMP
279 PMCS1CFbits.PTSZ = 2; // data bus width is 16-bit
280 #else
281 PMCS1CFbits.PTSZ = 0; // data bus width is 8-bit
282 #endif
283  
284 PMCS1MDbits.ACKM = 0; // PMACK is not used
285 PMCS1MDbits.DWAITB = 0;
286 PMCS1MDbits.DWAITM = 2;
287 PMCS1MDbits.DWAITE = 0;
288  
289 PMCON3bits.PTWREN = 1; // enable write strobe port
290 PMCON3bits.PTRDEN = 1; // enable read strobe port
291 PMCON3bits.PTBE0EN = 0; // disable byte enable port
292 PMCON3bits.PTBE1EN = 0; // disable byte enable port
293 PMCON3bits.AWAITM = 0; // don't care
294 PMCON3bits.AWAITE = 0; // don't care
295  
296 PMCON1bits.PMPEN = 1;
297  
298 DelayMs(40);
299 RST_LAT_BIT = 1; // release from reset
300 DelayMs(40);
301 }
302  
303 #endif // USE_GFX_EPMP
304 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3