| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /********************************************************************* |
| 2 | * |
||
| 3 | * Microchip File System |
||
| 4 | * |
||
| 5 | ********************************************************************* |
||
| 6 | * FileName: MPFS.h |
||
| 7 | * Dependencies: StackTsk.H |
||
| 8 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 9 | * Compiler: Microchip C32 v1.05 or higher |
||
| 10 | * Microchip C30 v3.12 or higher |
||
| 11 | * Microchip C18 v3.30 or higher |
||
| 12 | * HI-TECH PICC-18 PRO 9.63PL2 or higher |
||
| 13 | * Company: Microchip Technology, Inc. |
||
| 14 | * |
||
| 15 | * Software License Agreement |
||
| 16 | * |
||
| 17 | * Copyright (C) 2002-2009 Microchip Technology Inc. All rights |
||
| 18 | * reserved. |
||
| 19 | * |
||
| 20 | * Microchip licenses to you the right to use, modify, copy, and |
||
| 21 | * distribute: |
||
| 22 | * (i) the Software when embedded on a Microchip microcontroller or |
||
| 23 | * digital signal controller product ("Device") which is |
||
| 24 | * integrated into Licensee's product; or |
||
| 25 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 26 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
| 27 | * used in conjunction with a Microchip ethernet controller for |
||
| 28 | * the sole purpose of interfacing with the ethernet controller. |
||
| 29 | * |
||
| 30 | * You should refer to the license agreement accompanying this |
||
| 31 | * Software for additional information regarding your rights and |
||
| 32 | * obligations. |
||
| 33 | * |
||
| 34 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
| 35 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
| 36 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
| 37 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
| 38 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
| 39 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
| 40 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
| 41 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
| 42 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
| 43 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
| 44 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
| 45 | * |
||
| 46 | * |
||
| 47 | * Author Date Comment |
||
| 48 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 49 | * Nilesh Rajbharti 8/14/01 Original (Rev. 1.0) |
||
| 50 | * Nilesh Rajbharti 2/9/02 Cleanup |
||
| 51 | * Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail) |
||
| 52 | * Howard Schlunder 5/31/06 Changed EEPROM addressing to 32 bits |
||
| 53 | ********************************************************************/ |
||
| 54 | #ifndef __MPFS_H |
||
| 55 | #define __MPFS_H |
||
| 56 | |||
| 57 | #if defined(MPFS_USE_EEPROM) || defined(MPFS_USE_SPI_FLASH) |
||
| 58 | typedef DWORD MPFS; // For default 32 bit addressing (use /ll option with MPFS.exe) |
||
| 59 | #define MPFS_INVALID (0xffffffffu) // For default 32 bit addressing (use /ll option with MPFS.exe) |
||
| 60 | // typedef WORD MPFS; // For old short 16 bit addressing (use /b option with MPFS.exe) |
||
| 61 | // #define MPFS_INVALID (0xffff) // For old short 16 bit addressing (use /b option with MPFS.exe) |
||
| 62 | #else |
||
| 63 | #if defined(__C30__) |
||
| 64 | typedef DWORD MPFS; |
||
| 65 | #define MPFS_INVALID (MPFS)(0xffffffffu) |
||
| 66 | #else |
||
| 67 | typedef ROM BYTE* MPFS; |
||
| 68 | #define MPFS_INVALID (MPFS)(0xffffffu) |
||
| 69 | #endif |
||
| 70 | #endif |
||
| 71 | |||
| 72 | #define MPFS_NOT_AVAILABLE (0x0u) |
||
| 73 | |||
| 74 | #if defined(MPFS_USE_EEPROM) |
||
| 75 | #if defined(USE_EEPROM_25LC1024) |
||
| 76 | #define MPFS_WRITE_PAGE_SIZE (256u) |
||
| 77 | #else |
||
| 78 | #define MPFS_WRITE_PAGE_SIZE (64u) |
||
| 79 | #endif |
||
| 80 | #endif |
||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | BOOL MPFSInit(void); |
||
| 85 | MPFS MPFSOpen(BYTE* name); |
||
| 86 | MPFS MPFSOpenROM(ROM BYTE* name); |
||
| 87 | BYTE MPFSGet(void); |
||
| 88 | void MPFSClose(void); |
||
| 89 | MPFS MPFSFormat(void); |
||
| 90 | BOOL MPFSPut(BYTE b); |
||
| 91 | MPFS MPFSPutEnd(void); |
||
| 92 | MPFS MPFSSeek(MPFS offset); |
||
| 93 | BOOL MPFSGetLong(DWORD *ul); |
||
| 94 | |||
| 95 | #if !defined(__MPFS_C) |
||
| 96 | extern BYTE mpfsOpenCount; |
||
| 97 | extern MPFS _currentHandle; |
||
| 98 | extern BYTE _currentCount; |
||
| 99 | #endif |
||
| 100 | |||
| 101 | |||
| 102 | /********************************************************************* |
||
| 103 | * Function: BOOL MPFSGetBegin(MPFS handle) |
||
| 104 | * |
||
| 105 | * PreCondition: MPFSOpen() != MPFS_INVALID && |
||
| 106 | * |
||
| 107 | * Input: handle - handle of file that is to be read |
||
| 108 | * |
||
| 109 | * Output: TRUE if successful |
||
| 110 | * !TRUE otherwise |
||
| 111 | * |
||
| 112 | * Side Effects: None |
||
| 113 | * |
||
| 114 | * Overview: Prepares MPFS storage media for subsequent reads. |
||
| 115 | * |
||
| 116 | * Note: None |
||
| 117 | ********************************************************************/ |
||
| 118 | #if defined(MPFS_USE_EEPROM) |
||
| 119 | BOOL MPFSGetBegin(MPFS handle); |
||
| 120 | #else |
||
| 121 | #define MPFSGetBegin(handle) (_currentHandle = handle) |
||
| 122 | #endif |
||
| 123 | |||
| 124 | |||
| 125 | /********************************************************************* |
||
| 126 | * Function: MPFS MPFSGetEnd(void) |
||
| 127 | * |
||
| 128 | * PreCondition: MPFSOpen() != MPFS_INVALID && |
||
| 129 | * MPFSGetBegin() = TRUE |
||
| 130 | * |
||
| 131 | * Input: None |
||
| 132 | * |
||
| 133 | * Output: Current mpfs handle. |
||
| 134 | * |
||
| 135 | * Side Effects: None |
||
| 136 | * |
||
| 137 | * Overview: Ends on-going read cycle. |
||
| 138 | * MPFS handle that is returned must be used |
||
| 139 | * for subsequent begin gets.. |
||
| 140 | * |
||
| 141 | * Note: None |
||
| 142 | ********************************************************************/ |
||
| 143 | #if defined(MPFS_USE_EEPROM) |
||
| 144 | MPFS MPFSGetEnd(void); |
||
| 145 | #else |
||
| 146 | #define MPFSGetEnd() _currentHandle |
||
| 147 | #endif |
||
| 148 | |||
| 149 | |||
| 150 | /********************************************************************* |
||
| 151 | * Macro: BOOL MPFSIsEOF(void) |
||
| 152 | * |
||
| 153 | * PreCondition: MPFSGetBegin() must be called. |
||
| 154 | * |
||
| 155 | * Input: None |
||
| 156 | * |
||
| 157 | * Output: TRUE if current file read has reached end of file. |
||
| 158 | * FALSE if otherwise. |
||
| 159 | * |
||
| 160 | * Side Effects: None |
||
| 161 | * |
||
| 162 | * Overview: None |
||
| 163 | * |
||
| 164 | * Note: None |
||
| 165 | ********************************************************************/ |
||
| 166 | #define MPFSIsEOF() (_currentHandle == MPFS_INVALID) |
||
| 167 | |||
| 168 | |||
| 169 | /********************************************************************* |
||
| 170 | * Function: BOOL MPFSPutBegin(MPFS handle) |
||
| 171 | * |
||
| 172 | * PreCondition: MPFSInit() and MPFSFormat() are already called. |
||
| 173 | * |
||
| 174 | * Input: handle - handle to where put to begin |
||
| 175 | * |
||
| 176 | * Output: TRUE if successful |
||
| 177 | * !TRUE otherwise |
||
| 178 | * |
||
| 179 | * Side Effects: None |
||
| 180 | * |
||
| 181 | * Overview: Prepares MPFS image to get re-written |
||
| 182 | * |
||
| 183 | * Note: MPFS will be unaccessible until MPFSClose is |
||
| 184 | * called. |
||
| 185 | ********************************************************************/ |
||
| 186 | #if defined(MPFS_USE_EEPROM) |
||
| 187 | BOOL MPFSPutBegin(MPFS handle); |
||
| 188 | #else |
||
| 189 | #define MPFSPutBegin(handle) (_currentHandle = handle) |
||
| 190 | #endif |
||
| 191 | |||
| 192 | /********************************************************************* |
||
| 193 | * Function: MPFS MPFSTell(void) |
||
| 194 | * |
||
| 195 | * PreCondition: MPFSOpen() is already called. |
||
| 196 | * |
||
| 197 | * Input: None |
||
| 198 | * |
||
| 199 | * Output: current MPFS file pointer |
||
| 200 | * |
||
| 201 | * Side Effects: None. |
||
| 202 | * |
||
| 203 | * Overview: None |
||
| 204 | * |
||
| 205 | * Note: None. |
||
| 206 | ********************************************************************/ |
||
| 207 | #define MPFSTell() (_currentHandle) |
||
| 208 | |||
| 209 | |||
| 210 | /********************************************************************* |
||
| 211 | * Macro: BYTE MPFSInUse(void) |
||
| 212 | * |
||
| 213 | * PreCondition: None |
||
| 214 | * |
||
| 215 | * Input: None |
||
| 216 | * |
||
| 217 | * Output: No. of file currently open. |
||
| 218 | * If == 0, MPFS is not in use. |
||
| 219 | * |
||
| 220 | * Side Effects: None |
||
| 221 | * |
||
| 222 | * Overview: None |
||
| 223 | * |
||
| 224 | * Note: None |
||
| 225 | ********************************************************************/ |
||
| 226 | #define MPFSIsInUse() (mpfsOpenCount) |
||
| 227 | |||
| 228 | #endif |
Powered by WebSVN v2.8.3