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

Contents of /trunk/docs/MCHPStack2.20/Source/mpfs.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: 10962 byte(s)
Removed tcpip stack 4.02 and added tcpip stack 2.20.
1 /*********************************************************************
2 *
3 * Microchip File System on PIC18
4 *
5 *********************************************************************
6 * FileName: MPFS.h
7 * Dependencies: StackTsk.H
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 * This file provides Microchip File System access calls.
34 *
35 * Author Date Comment
36 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 * Nilesh Rajbharti 8/14/01 Original (Rev. 1.0)
38 * Nilesh Rajbharti 2/9/02 Cleanup
39 * Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail)
40 ********************************************************************/
41
42 #ifndef MPFS_H
43 #define MPFS_H
44
45 #include "stacktsk.h"
46
47 #if defined(MPFS_USE_PGRM)
48 typedef ROM BYTE* MPFS;
49 #define MPFS_INVALID (MPFS)(0xffffff)
50 typedef WORD MPFS_OFFSET;
51
52 #else
53 typedef WORD MPFS;
54 #define MPFS_INVALID (0xffff)
55 typedef WORD MPFS_OFFSET;
56
57 #endif
58
59 #define MPFS_NOT_AVAILABLE (0x0)
60
61 #if defined(MPFS_USE_EEPROM)
62 #define MPFS_WRITE_PAGE_SIZE (64)
63 #elif defined(MPFS_USE_PRGMR)
64 #define MPFS_WRITE_PAGE_SIZE (8)
65 #endif
66
67
68
69 /*********************************************************************
70 * Function: BOOL MPFSInit(void)
71 *
72 * PreCondition: None
73 *
74 * Input: None
75 *
76 * Output: TRUE, if MPFS Storage access is initialized and
77 * MPFS is is ready to be used.
78 * FALSE otherwise
79 *
80 * Side Effects: None
81 *
82 * Overview: None
83 *
84 * Note: None
85 ********************************************************************/
86 BOOL MPFSInit(void);
87
88
89 /*********************************************************************
90 * Function: MPFS MPFSOpen(BYTE* name)
91 *
92 * PreCondition: None
93 *
94 * Input: name - NULL terminate file name.
95 *
96 * Output: MPFS_INVALID if not found
97 * != MPFS_INVALID if found ok.
98 *
99 * Side Effects: None
100 *
101 * Overview: None
102 *
103 * Note: None
104 ********************************************************************/
105 MPFS MPFSOpen(BYTE* name);
106
107
108
109 /*********************************************************************
110 * Function: void MPFSClose(void)
111 *
112 * PreCondition: None
113 *
114 * Input: handle - File handle to be closed
115 *
116 * Output: None
117 *
118 * Side Effects: None
119 *
120 * Overview: None
121 *
122 * Note: None
123 ********************************************************************/
124 void MPFSClose(void);
125
126
127 /*********************************************************************
128 * Function: BOOL MPFSGetBegin(MPFS handle)
129 *
130 * PreCondition: MPFSOpen() != MPFS_INVALID &&
131 *
132 * Input: handle - handle of file that is to be read
133 *
134 * Output: TRUE if successful
135 * !TRUE otherwise
136 *
137 * Side Effects: None
138 *
139 * Overview: Prepares MPFS storage media for subsequent reads.
140 *
141 * Note: None
142 ********************************************************************/
143 #if defined(MPFS_USE_EEPROM)
144 BOOL MPFSGetBegin(MPFS handle);
145 #else
146 #define MPFSGetBegin(handle) (_currentHandle = handle)
147 #endif
148
149
150 /*********************************************************************
151 * Function: BYTE MPFSGet(void)
152 *
153 * PreCondition: MPFSOpen() != MPFS_INVALID &&
154 * MPFSGetBegin() == TRUE
155 *
156 * Input: None
157 *
158 * Output: Data byte from current address.
159 *
160 * Side Effects: None
161 *
162 * Overview: Reads a byte from current address.
163 *
164 * Note: Caller must call MPFSIsEOF() to check for end of
165 * file condition
166 ********************************************************************/
167 BYTE MPFSGet(void);
168
169
170 /*********************************************************************
171 * Function: MPFS MPFSGetEnd(void)
172 *
173 * PreCondition: MPFSOpen() != MPFS_INVALID &&
174 * MPFSGetBegin() = TRUE
175 *
176 * Input: None
177 *
178 * Output: Current mpfs handle.
179 *
180 * Side Effects: None
181 *
182 * Overview: Ends on-going read cycle.
183 * MPFS handle that is returned must be used
184 * for subsequent begin gets..
185 *
186 * Note: None
187 ********************************************************************/
188 #if defined(MPFS_USE_EEPROM)
189 MPFS MPFSGetEnd(void);
190 #else
191 #define MPFSGetEnd() _currentHandle
192 #endif
193
194
195 /*********************************************************************
196 * Macro: BOOL MPFSIsEOF(void)
197 *
198 * PreCondition: MPFSGetBegin() must be called.
199 *
200 * Input: None
201 *
202 * Output: TRUE if current file read has reached end of file.
203 * FALSE if otherwise.
204 *
205 * Side Effects: None
206 *
207 * Overview: None
208 *
209 * Note: None
210 ********************************************************************/
211 #define MPFSIsEOF() (_currentHandle == MPFS_INVALID)
212
213
214 /*********************************************************************
215 * Function: MPFS MPFSFormat(void)
216 *
217 * PreCondition: None
218 *
219 * Input: None
220 *
221 * Output: A valid MPFS handle that can be used for MPFSPut
222 *
223 * Side Effects: None
224 *
225 * Overview: Prepares MPFS image to get re-written
226 * Declares MPFS as in use.
227 *
228 * Note: MPFS will be unaccessible until MPFSClose is
229 * called.
230 ********************************************************************/
231 MPFS MPFSFormat(void);
232
233
234
235 /*********************************************************************
236 * Function: BOOL MPFSPutBegin(MPFS handle)
237 *
238 * PreCondition: MPFSInit() and MPFSFormat() are already called.
239 *
240 * Input: handle - handle to where put to begin
241 *
242 * Output: TRUE if successful
243 * !TRUE otherwise
244 *
245 * Side Effects: None
246 *
247 * Overview: Prepares MPFS image to get re-written
248 *
249 * Note: MPFS will be unaccessible until MPFSClose is
250 * called.
251 ********************************************************************/
252 #if defined(MPFS_USE_EEPROM)
253 BOOL MPFSPutBegin(MPFS handle);
254 #else
255 #define MPFSPutBegin(handle) (_currentHandle = handle)
256 #endif
257
258
259 /*********************************************************************
260 * Function: BOOL MPFSPut(BYTE b)
261 *
262 * PreCondition: MPFSFormat() or MPFSCreate() must be called
263 *
264 * Input: b - byte to be written
265 *
266 * Output: TRUE if successful
267 * !TRUE if otherwise
268 *
269 * Side Effects: MPFS handle is updated.
270 *
271 * Overview: None
272 *
273 * Note: Since this function updates internal MPFS handle
274 * caller must call MPFSPutEnd() to obtain
275 * up-to-date handle.
276 ********************************************************************/
277 BOOL MPFSPut(BYTE b);
278
279
280 /*********************************************************************
281 * Function: MPFS MPFSPutEnd(void)
282 *
283 * PreCondition: MPFSPutBegin() is already called.
284 *
285 * Input: None
286 *
287 * Output: Up-to-date MPFS handle
288 *
289 * Side Effects: Original MPFS handle is no longer valid.
290 * Updated MPFS handle must be obtained by calling
291 * MPFSPutEnd().
292 *
293 * Overview: None
294 *
295 * Note: Actual write may not get started until internal
296 * write page is full. To ensure that previously
297 * data gets written, caller must call MPFSPutEnd()
298 * after last call to MPFSPut().
299 ********************************************************************/
300 MPFS MPFSPutEnd(void);
301
302
303 /*********************************************************************
304 * Macro: BYTE MPFSInUse(void)
305 *
306 * PreCondition: None
307 *
308 * Input: None
309 *
310 * Output: No. of file currently open.
311 * If == 0, MPFS is not in use.
312 *
313 * Side Effects: None
314 *
315 * Overview: None
316 *
317 * Note: None
318 ********************************************************************/
319 #if !defined(THIS_IS_MPFS)
320 extern BYTE mpfsOpenCount;
321 #endif
322
323 /*********************************************************************
324 * Function: MPFS MPFSSeek(MPFS_OFFSET offset)
325 *
326 * PreCondition: MPFSGetBegin() is already called.
327 *
328 * Input: offset - Offset from current pointer
329 *
330 * Output: New MPFS handle located to given offset
331 *
332 * Side Effects: None.
333 *
334 * Overview: None
335 *
336 * Note: None.
337 ********************************************************************/
338 MPFS MPFSSeek(MPFS_OFFSET offset);
339
340
341 /*********************************************************************
342 * Function: MPFS MPFSTell(void)
343 *
344 * PreCondition: MPFSOpen() is already called.
345 *
346 * Input: None
347 *
348 * Output: current MPFS file pointer
349 *
350 * Side Effects: None.
351 *
352 * Overview: None
353 *
354 * Note: None.
355 ********************************************************************/
356 #define MPFSTell() (_currentHandle)
357
358
359 #define MPFSIsInUse() (mpfsOpenCount)
360
361 #if !defined(THIS_IS_MPFS)
362 extern MPFS _currentHandle;
363 extern BYTE _currentCount;
364 #endif
365
366
367 #endif

  ViewVC Help
Powered by ViewVC 1.1.20