00001 /* flashWrite.h 00002 00003 Copyright 2008 Sean Keys 00004 00005 This file is part of the FreeEMS project. 00006 00007 FreeEMS software is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 FreeEMS software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with any FreeEMS software. If not, see <http://www.gnu.org/licenses/>. 00019 00020 We ask that if you make any changes to this file you send them upstream to us at admin@diyefi.org 00021 00022 Thank you for choosing FreeEMS to run your engine! */ 00023 00024 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00025 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00026 #ifndef FILE_FLASHWRITE_H_SEEN 00027 #define FILE_FLASHWRITE_H_SEEN 00028 00029 #ifdef FLASHWRITE_C 00030 #define EXTERN 00031 #else 00032 #define EXTERN extern 00033 #endif 00034 00035 // TODO : 00036 // #define CBEIF mask 00037 #define ERASE_CMD 0x40 //TODO add more info 00038 #define WORD_PROGRAM 0x20 /* Word = 2 bytes, this is the minimum write size, 64K of these per block, 512 per sector */ 00039 #define SECTOR_ERASE 0x40 /* Sector = 1024 bytes, there are 128 sectors to a block, and 4 blocks to the chip */ 00040 00041 00042 /* The following code must run from unpaged space for obvious reasons. Location explicitly set to text. */ 00043 EXTERN unsigned short writeWord(unsigned short*, unsigned short) TEXT; 00044 EXTERN unsigned short eraseSector(unsigned char, unsigned short*) TEXT; 00045 EXTERN unsigned short writeSector(unsigned char, unsigned short*, unsigned char, unsigned short*) TEXT; 00046 EXTERN unsigned short writeBlock(unsigned char, unsigned short*, unsigned char, unsigned short*, unsigned short) TEXT; 00047 00048 //TODO source flash page, source ram page, dest flash page grab the code from FF C000 and burn it from E0 up 00049 #undef EXTERN 00050 00051 #else 00052 /* let us know ifunsigned short writeBlock(unsigned short* flashAddr, unsigned short* RAMAddr, unsigned short size){ 00053 * we are being untidy with headers */ 00054 #warning "Header file FLASHWRITE_H seen before, sort it out!" 00055 /* end of the wrapper ifdef from the very top */ 00056 #endif