FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
flashWrite.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2008-2009 Fred Cooke
4  *
5  * This file is part of the FreeEMS project.
6  *
7  * FreeEMS software is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FreeEMS software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
19  *
20  * We ask that if you make any changes to this file you email them upstream to
21  * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22  *
23  * Thank you for choosing FreeEMS to run your engine!
24  */
25 
26 
27 /** @file
28  *
29  * @ingroup allHeaders
30  *
31  * @author Sean Keys
32  */
33 
34 
35 /* Header file multiple inclusion protection courtesy eclipse Header Template */
36 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
37 #ifndef FILE_FLASHWRITE_H_SEEN
38 #define FILE_FLASHWRITE_H_SEEN
39 
40 
41 #ifdef EXTERN
42 #warning "EXTERN already defined by another header, please sort it out!"
43 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
44 #endif
45 
46 
47 #ifdef FLASHWRITE_C
48 #define EXTERN
49 #else
50 #define EXTERN extern
51 #endif
52 
53 
54 /// @todo TODO add mass erase function and replace ?? with the real value
55 #define MASS_ERASE 0x?? /* Used to erase 128k flash blocks */
56 #define WORD_PROGRAM 0x20 /* Word = 2 bytes, this is the minimum write size, 64K of these per block, 512 per sector */
57 #define SECTOR_ERASE 0x40 /* Sector = 1024 bytes, there are 128 sectors to a block, and 4 blocks to the chip */
58 /// @todo TODO CBEIF mask hash define - is this still needed?
59 
60 
61 /* The following code must run from unpaged space for obvious reasons. Location explicitly set to text. */
62 unsigned short writeWord(unsigned short*, unsigned short) TEXT;
63 unsigned short eraseSector(unsigned char, unsigned short*) TEXT;
64 unsigned short writeSector(unsigned char, unsigned short*, unsigned char, unsigned short*) TEXT;
65 unsigned short writeBlock(blockDetails*, void*) TEXT;
66 
67 
68 #undef EXTERN
69 
70 
71 #else
72  /* let us know ifunsigned short writeBlock(unsigned short* flashAddr, unsigned short* RAMAddr, unsigned short size){
73  * we are being untidy with headers */
74  #warning "Header file FLASHWRITE_H seen before, sort it out!"
75 /* end of the wrapper ifdef from the very top */
76 #endif