1
0

lpcprog.h 5.1 KB

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