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