]> rtime.felk.cvut.cz Git - sysless.git/blob - arch/arm/mach-lpc17cmsis/tools/lpc21isp/lpcprog.h
Added flash loading tool lpc21isp for LPC17xx
[sysless.git] / arch / arm / mach-lpc17cmsis / tools / lpc21isp / lpcprog.h
1 /******************************************************************************
2
3 Project:           Portable command line ISP for Philips LPC2000 family
4                    and Analog Devices ADUC70xx
5
6 Filename:          lpcprog.h
7
8 Compiler:          Microsoft VC 6/7, GCC Cygwin, GCC Linux, GCC ARM ELF
9
10 Author:            Martin Maurer (Martin.Maurer@clibb.de)
11
12 Copyright:         (c) Martin Maurer 2003-2010, All rights reserved
13 Portions Copyright (c) by Aeolus Development 2004 http://www.aeolusdevelopment.com
14
15     This file is part of lpc21isp.
16
17     lpc21isp is free software: you can redistribute it and/or modify
18     it under the terms of the GNU Lesser General Public License as published by
19     the Free Software Foundation, either version 3 of the License, or
20     any later version.
21
22     lpc21isp is distributed in the hope that it will be useful,
23     but WITHOUT ANY WARRANTY; without even the implied warranty of
24     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25     GNU Lesser General Public License for more details.
26
27     You should have received a copy of the GNU Lesser General Public License
28     and GNU General Public License along with lpc21isp.
29     If not, see <http://www.gnu.org/licenses/>.
30 */
31
32 /* LPC_RAMSTART, LPC_RAMBASE
33 *
34 * Used in PhilipsDownload() to decide whether to Flash code or just place in in RAM
35 * (works for .hex files only)
36 *
37 * LPC_RAMSTART - the Physical start address of the SRAM
38 * LPC_RAMBASE  - the base address where downloading starts.
39 *                Note that any code in the .hex file that resides in 0x4000,0000 ~ 0x4000,0200
40 *                will _not_ be written to the LPCs SRAM.
41 *                This is due to the fact that 0x4000,0040 - 0x4000,0200 is used by the bootrom.
42 *                Any interrupt vectors must be copied to 0x4000,0000 and remapped to 0x0000,0000
43 *                by the startup code.
44 */
45 #define LPC_RAMSTART_LPC2XXX    0x40000000L
46 #define LPC_RAMBASE_LPC2XXX     0x40000200L
47
48 #define LPC_RAMSTART_LPC17XX    0x10000000L
49 #define LPC_RAMBASE_LPC17XX     0x10000200L
50
51 #define LPC_RAMSTART_LPC13XX    0x10000000L
52 #define LPC_RAMBASE_LPC13XX     0x10000300L
53
54 #define LPC_RAMSTART_LPC11XX    0x10000000L
55 #define LPC_RAMBASE_LPC11XX     0x10000300L
56
57 /* Return values used by PhilipsDownload(): reserving all values from 0x1000 to 0x1FFF */
58
59 #define NO_ANSWER_WDT       0x1000
60 #define NO_ANSWER_QM        0x1001
61 #define NO_ANSWER_SYNC      0x1002
62 #define NO_ANSWER_OSC       0x1003
63 #define NO_ANSWER_RBV       0x1004
64 #define NO_ANSWER_RPID      0x1005
65 #define ERROR_WRITE_DATA    0x1006
66 #define ERROR_WRITE_CRC     0x1007
67 #define ERROR_WRITE_CRC2    0x1008
68 #define PROGRAM_TOO_LARGE   0x1009
69
70 #define USER_ABORT_SYNC     0x100A   /* User aborted synchronisation process */
71
72 #define UNLOCK_ERROR        0x1100   /* return value is 0x1100 + philips ISP returned value (0 to 255) */
73 #define WRONG_ANSWER_PREP   0x1200   /* return value is 0x1200 + philips ISP returned value (0 to 255) */
74 #define WRONG_ANSWER_ERAS   0x1300   /* return value is 0x1300 + philips ISP returned value (0 to 255) */
75 #define WRONG_ANSWER_WRIT   0x1400   /* return value is 0x1400 + philips ISP returned value (0 to 255) */
76 #define WRONG_ANSWER_PREP2  0x1500   /* return value is 0x1500 + philips ISP returned value (0 to 255) */
77 #define WRONG_ANSWER_COPY   0x1600   /* return value is 0x1600 + philips ISP returned value (0 to 255) */
78 #define FAILED_RUN          0x1700   /* return value is 0x1700 + philips ISP returned value (0 to 255) */
79
80 #if defined COMPILE_FOR_LPC21
81 #ifndef WIN32
82 #define LPC_BSL_PIN         13
83 #define LPC_RESET_PIN       47
84 #define LPC_RESET(in)       NAsetGPIOpin(LPC_RESET_PIN, (in))
85 #define LPC_BSL(in)         NAsetGPIOpin(LPC_BSL_PIN,   (in))
86 #endif // WIN32
87 #endif // COMPILE_FOR_LPC21
88
89
90 /* LPC_FLASHMASK
91 *
92 * LPC_FLASHMASK - bitmask to define the maximum size of the Filesize to download.
93 *                 LoadFile() will check any new segment address record (03) or extended linear
94 *                 address record (04) to see if the addressed 64 kByte data block still falls
95 *                 in the max. flash size.
96 *                 LoadFile() will not load any files that are larger than this size.
97 */
98 #define LPC_FLASHMASK  0xFFC00000 /* 22 bits = 4 MB */
99
100 typedef enum
101   {
102   CHIP_VARIANT_LPC2XXX,
103   CHIP_VARIANT_LPC17XX,
104   CHIP_VARIANT_LPC13XX,
105   CHIP_VARIANT_LPC11XX
106   } CHIP_VARIANT;
107
108 typedef struct
109 {
110     const unsigned long  id;
111     const char *Product;
112     const unsigned int   FlashSize;     /* in kiB, for informational purposes only */
113     const unsigned int   RAMSize;       /* in kiB, for informational purposes only */
114           unsigned int   FlashSectors;  /* total number of sectors */
115           unsigned int   MaxCopySize;   /* maximum size that can be copied to Flash in a single command */
116     const unsigned int  *SectorTable;   /* pointer to a sector table with constant the sector sizes */
117     const CHIP_VARIANT   ChipVariant;
118 } LPC_DEVICE_TYPE;
119
120 int PhilipsDownload(ISP_ENVIRONMENT *IspEnvironment);
121
122 unsigned long ReturnValueLpcRamStart(ISP_ENVIRONMENT *IspEnvironment);
123
124 unsigned long ReturnValueLpcRamBase(ISP_ENVIRONMENT *IspEnvironment);
125