/[H8]/trunk/docs/MCHPStack2.20/Source/xeeprom.h
ViewVC logotype

Contents of /trunk/docs/MCHPStack2.20/Source/xeeprom.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (show annotations) (download)
Tue May 1 08:17:39 2007 UTC (17 years, 2 months ago) by hedin
File MIME type: text/plain
File size: 10738 byte(s)
Removed tcpip stack 4.02 and added tcpip stack 2.20.
1 /*********************************************************************
2 *
3 * External serial data EEPROM Access Defs.
4 *
5 *********************************************************************
6 * FileName: xeeprom.h
7 * Dependencies: None
8 * Processor: PIC18
9 * Complier: MCC18 v1.00.50 or higher
10 * HITECH PICC-18 V8.10PL1 or higher
11 * Company: Microchip Technology, Inc.
12 *
13 * Software License Agreement
14 *
15 * The software supplied herewith by Microchip Technology Incorporated
16 * (the “Company”) for its PICmicro® Microcontroller is intended and
17 * supplied to you, the Company’s customer, for use solely and
18 * exclusively on Microchip PICmicro Microcontroller products. The
19 * software is owned by the Company and/or its supplier, and is
20 * protected under applicable copyright laws. All rights are reserved.
21 * Any use in violation of the foregoing restrictions may subject the
22 * user to criminal sanctions under applicable laws, as well as to
23 * civil liability for the breach of the terms and conditions of this
24 * license.
25 *
26 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
27 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
28 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
29 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
30 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
31 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
32 *
33 *
34 * Author Date Comment
35 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 * Nilesh Rajbharti 5/20/02 Original (Rev. 1.0)
37 ********************************************************************/
38 #ifndef XEEPROM_H
39 #define XEEPROM_H
40
41 #define EE_BAUD(CLOCK, BAUD) ( ((CLOCK / BAUD) / 4) - 1 )
42
43
44 typedef enum _XEE_RESULT
45 {
46 XEE_SUCCESS = 0,
47 XEE_READY = 0,
48 XEE_BUS_COLLISION,
49 XEE_NAK,
50 XEE_VERIFY_ERR,
51 XEE_BUSY
52 } XEE_RESULT;
53
54 typedef unsigned short int XEE_ADDR;
55
56
57 /*********************************************************************
58 * Function: void XEEInit(unsigned char baud)
59 *
60 * PreCondition: None
61 *
62 * Input: baud - SSPADD value for bit rate.
63 *
64 * Output: None
65 *
66 * Side Effects: None
67 *
68 * Overview: Initialize I2C module to communicate to serial
69 * EEPROM.
70 *
71 * Note: None
72 ********************************************************************/
73 void XEEInit(unsigned char baud);
74
75
76
77 /*********************************************************************
78 * Function: XEE_RESULT XEESetAddr(unsigned char control,
79 * XEE_ADDR address)
80 *
81 * PreCondition: XEEInit() is already called.
82 *
83 * Input: control - data EEPROM control code
84 * address - address to be set
85 *
86 * Output: XEE_SUCCESS if successful
87 * other value if failed.
88 *
89 * Side Effects: None
90 *
91 * Overview: Modifies internal address counter of EEPROM.
92 *
93 * Note: This function does not release the I2C bus.
94 * User must close XEEClose() after this function
95 * is called.
96 ********************************************************************/
97 XEE_RESULT XEESetAddr(unsigned char control, XEE_ADDR address);
98
99
100
101 /*********************************************************************
102 * Macro: XEE_RESULT XEEBeginWrite(unsigned char control,
103 * XEE_ADDR address)
104 *
105 * PreCondition: XEEInit() is already called.
106 *
107 * Input: control - data EEPROM control code
108 * address - address to where to write
109 *
110 * Output: XEE_SUCCESS if successful
111 * other value if failed.
112 *
113 * Side Effects: None
114 *
115 * Overview: Sets up internal address counter of EEPROM.
116 *
117 * Note: This function does not release the I2C bus.
118 * User must close XEEEndWrite() after this function
119 * is called to relase the I2C bus.
120 ********************************************************************/
121 #define XEEBeginWrite(control, address) XEESetAddr(control, address)
122
123
124
125 /*********************************************************************
126 * Function: XEE_RESULT XEEWrite(unsigned char val)
127 *
128 * PreCondition: XEEInit() && XEEBeginWrite() are already called.
129 *
130 * Input: val to be written
131 *
132 * Output: XEE_SUCCESS if successful
133 * other value if failed.
134 *
135 * Side Effects: None
136 *
137 * Overview: Writes given value 'val' at current address.
138 * Current address is set by XEEBeginWrite()
139 * and is incremented by every XEEWrite().
140 *
141 * Note: This function does not initiate the write cycle;
142 * it simply loads given value into internal page buffer.
143 * This function does not release the I2C bus.
144 * User must close XEEEndWrite() after this function
145 * is called to relase the I2C bus.
146 ********************************************************************/
147 XEE_RESULT XEEWrite(unsigned char val);
148
149
150
151 /*********************************************************************
152 * Function: XEE_RESULT XEEEndWrite(void)
153 *
154 * PreCondition: XEEInit() && XEEBeginWrite() are already called.
155 *
156 * Input: None
157 *
158 * Output: XEE_SUCCESS if successful
159 * other value if failed.
160 *
161 * Side Effects: None
162 *
163 * Overview: Instructs EEPROM to begin write cycle.
164 *
165 * Note: Call this function after either page full of bytes
166 * written or no more bytes are left to load.
167 * This function initiates the write cycle.
168 * User must call for XEEWait() to ensure that write
169 * cycle is finished before calling any other
170 * routine.
171 ********************************************************************/
172 XEE_RESULT XEEEndWrite(void);
173
174
175 /*********************************************************************
176 * Function: XEE_RESULT XEEBeginRead(unsigned char control,
177 * XEE_ADDR address)
178 *
179 * PreCondition: XEEInit() is already called.
180 *
181 * Input: control - EEPROM control and address code.
182 * address - Address at which read is to be performed.
183 *
184 * Output: XEE_SUCCESS if successful
185 * other value if failed.
186 *
187 * Side Effects: None
188 *
189 * Overview: Sets internal address counter to given address.
190 * Puts EEPROM in sequential read mode.
191 *
192 * Note: This function does not release I2C bus.
193 * User must call XEEEndRead() when read is not longer
194 * needed; I2C bus will released after XEEEndRead()
195 * is called.
196 ********************************************************************/
197 XEE_RESULT XEEBeginRead(unsigned char control, XEE_ADDR address);
198
199
200
201 /*********************************************************************
202 * Function: XEE_RESULT XEERead(void)
203 *
204 * PreCondition: XEEInit() && XEEBeginRead() are already called.
205 *
206 * Input: None
207 *
208 * Output: XEE_SUCCESS if successful
209 * other value if failed.
210 *
211 * Side Effects: None
212 *
213 * Overview: Reads next byte from EEPROM; internal address
214 * is incremented by one.
215 *
216 * Note: This function does not release I2C bus.
217 * User must call XEEEndRead() when read is not longer
218 * needed; I2C bus will released after XEEEndRead()
219 * is called.
220 ********************************************************************/
221 unsigned char XEERead(void);
222
223
224 /*********************************************************************
225 * Function: XEE_RESULT XEEEndRead(void)
226 *
227 * PreCondition: XEEInit() && XEEBeginRead() are already called.
228 *
229 * Input: None
230 *
231 * Output: XEE_SUCCESS if successful
232 * other value if failed.
233 *
234 * Side Effects: None
235 *
236 * Overview: Ends sequential read cycle.
237 *
238 * Note: This function ends seuential cycle that was in
239 * progress. It releases I2C bus.
240 ********************************************************************/
241 XEE_RESULT XEEEndRead(void);
242
243
244 /*********************************************************************
245 * Function: XEE_RESULT XEEReadArray(unsigned char control,
246 * XEE_ADDR address,
247 * unsigned char *buffer,
248 * unsigned char length)
249 *
250 * PreCondition: XEEInit() is already called.
251 *
252 * Input: control - EEPROM control and address code.
253 * address - Address from where array is to be read
254 * buffer - Caller supplied buffer to hold the data
255 * length - Number of bytes to read.
256 *
257 * Output: XEE_SUCCESS if successful
258 * other value if failed.
259 *
260 * Side Effects: None
261 *
262 * Overview: Reads desired number of bytes in sequential mode.
263 * This function performs all necessary steps
264 * and releases the bus when finished.
265 *
266 * Note: None
267 ********************************************************************/
268 XEE_RESULT XEEReadArray(unsigned char control,
269 XEE_ADDR address,
270 unsigned char *buffer,
271 unsigned char length);
272
273
274
275 /*********************************************************************
276 * Function: XEE_RESULT XEEIsBusy(unsigned char control)
277 *
278 * PreCondition: XEEInit() is already called.
279 *
280 * Input: control - EEPROM control and address code.
281 *
282 * Output: XEE_READY if EEPROM is not busy
283 * XEE_BUSY if EEPROM is busy
284 * other value if failed.
285 *
286 * Side Effects: None
287 *
288 * Overview: Requests ack from EEPROM.
289 *
290 * Note: None
291 ********************************************************************/
292 XEE_RESULT XEEIsBusy(unsigned char control);
293
294
295
296 #endif

  ViewVC Help
Powered by ViewVC 1.1.20