My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lpc17xx_iap.h 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**********************************************************************
  2. * $Id$ lpc17xx_iap.h 2012-04-18
  3. *//**
  4. * @file lpc17xx_iap.h
  5. * @brief Contains all functions support for IAP
  6. * on lpc17xx
  7. * @version 1.0
  8. * @date 18. April. 2012
  9. * @author NXP MCU SW Application Team
  10. *
  11. * Copyright(C) 2011, NXP Semiconductor
  12. * All rights reserved.
  13. *
  14. ***********************************************************************
  15. * Software that is described herein is for illustrative purposes only
  16. * which provides customers with programming information regarding the
  17. * products. This software is supplied "AS IS" without any warranties.
  18. * NXP Semiconductors assumes no responsibility or liability for the
  19. * use of the software, conveys no license or title under any patent,
  20. * copyright, or mask work right to the product. NXP Semiconductors
  21. * reserves the right to make changes in the software without
  22. * notification. NXP Semiconductors also make no representation or
  23. * warranty that such application will be suitable for the specified
  24. * use without further testing or modification.
  25. * Permission to use, copy, modify, and distribute this software and its
  26. * documentation is hereby granted, under NXP Semiconductors'
  27. * relevant copyright in the software, without fee, provided that it
  28. * is used in conjunction with NXP Semiconductors microcontrollers. This
  29. * copyright, permission, and disclaimer notice must appear in all copies of
  30. * this code.
  31. **********************************************************************/
  32. #ifndef _LPC17xx_IAP_H
  33. #define _LPC17xx_IAP_H
  34. #include "lpc_types.h"
  35. /** @defgroup IAP IAP (In Application Programming)
  36. * @ingroup LPC1700CMSIS_FwLib_Drivers
  37. * @{
  38. */
  39. /** @defgroup IAP_Public_Macros IAP Public Macros
  40. * @{
  41. */
  42. /** IAP entry location */
  43. #define IAP_LOCATION (0x1FFF1FF1UL)
  44. /**
  45. * @}
  46. */
  47. /** @defgroup IAP_Public_Types IAP Public Types
  48. * @{
  49. */
  50. /**
  51. * @brief IAP command code definitions
  52. */
  53. typedef enum
  54. {
  55. IAP_PREPARE = 50, // Prepare sector(s) for write operation
  56. IAP_COPY_RAM2FLASH = 51, // Copy RAM to Flash
  57. IAP_ERASE = 52, // Erase sector(s)
  58. IAP_BLANK_CHECK = 53, // Blank check sector(s)
  59. IAP_READ_PART_ID = 54, // Read chip part ID
  60. IAP_READ_BOOT_VER = 55, // Read chip boot code version
  61. IAP_COMPARE = 56, // Compare memory areas
  62. IAP_REINVOKE_ISP = 57, // Reinvoke ISP
  63. IAP_READ_SERIAL_NUMBER = 58, // Read serial number
  64. } IAP_COMMAND_CODE;
  65. /**
  66. * @brief IAP status code definitions
  67. */
  68. typedef enum
  69. {
  70. CMD_SUCCESS, // Command is executed successfully.
  71. INVALID_COMMAND, // Invalid command.
  72. SRC_ADDR_ERROR, // Source address is not on a word boundary.
  73. DST_ADDR_ERROR, // Destination address is not on a correct boundary.
  74. SRC_ADDR_NOT_MAPPED, // Source address is not mapped in the memory map.
  75. DST_ADDR_NOT_MAPPED, // Destination address is not mapped in the memory map.
  76. COUNT_ERROR, // Byte count is not multiple of 4 or is not a permitted value.
  77. INVALID_SECTOR, // Sector number is invalid.
  78. SECTOR_NOT_BLANK, // Sector is not blank.
  79. SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION, // Command to prepare sector for write operation was not executed.
  80. COMPARE_ERROR, // Source and destination data is not same.
  81. BUSY, // Flash programming hardware interface is busy.
  82. } IAP_STATUS_CODE;
  83. /**
  84. * @brief IAP write length definitions
  85. */
  86. typedef enum {
  87. IAP_WRITE_256 = 256,
  88. IAP_WRITE_512 = 512,
  89. IAP_WRITE_1024 = 1024,
  90. IAP_WRITE_4096 = 4096,
  91. } IAP_WRITE_SIZE;
  92. /**
  93. * @brief IAP command structure
  94. */
  95. typedef struct {
  96. uint32_t cmd; // Command
  97. uint32_t param[4]; // Parameters
  98. uint32_t status; // status code
  99. uint32_t result[4]; // Result
  100. } IAP_COMMAND_Type;
  101. /**
  102. * @}
  103. */
  104. /* Public Functions ----------------------------------------------------------- */
  105. /** @defgroup IAP_Public_Functions IAP Public Functions
  106. * @{
  107. */
  108. /** Get sector number of an address */
  109. uint32_t GetSecNum (uint32_t adr);
  110. /** Prepare sector(s) for write operation */
  111. IAP_STATUS_CODE PrepareSector(uint32_t start_sec, uint32_t end_sec);
  112. /** Copy RAM to Flash */
  113. IAP_STATUS_CODE CopyRAM2Flash(uint8_t * dest, uint8_t* source, IAP_WRITE_SIZE size);
  114. /** Prepare sector(s) for write operation */
  115. IAP_STATUS_CODE EraseSector(uint32_t start_sec, uint32_t end_sec);
  116. /** Blank check sectors */
  117. IAP_STATUS_CODE BlankCheckSector(uint32_t start_sec, uint32_t end_sec,
  118. uint32_t *first_nblank_loc,
  119. uint32_t *first_nblank_val);
  120. /** Read part identification number */
  121. IAP_STATUS_CODE ReadPartID(uint32_t *partID);
  122. /** Read boot code version */
  123. IAP_STATUS_CODE ReadBootCodeVer(uint8_t *major, uint8_t* minor);
  124. /** Read Device serial number */
  125. IAP_STATUS_CODE ReadDeviceSerialNum(uint32_t *uid);
  126. /** Compare memory */
  127. IAP_STATUS_CODE Compare(uint8_t *addr1, uint8_t *addr2, uint32_t size);
  128. /** Invoke ISP */
  129. void InvokeISP(void);
  130. /**
  131. * @}
  132. */
  133. /**
  134. * @}
  135. */
  136. #endif /*_LPC17xx_IAP_H*/