cybtldr_api2.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*******************************************************************************
  2. * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved.
  3. * You may use this file only in accordance with the license, terms, conditions,
  4. * disclaimers, and limitations in the end user license agreement accompanying
  5. * the software package with which this file was provided.
  6. ********************************************************************************/
  7. #ifndef __CYBTLDR_API2_H__
  8. #define __CYBTLDR_API2_H__
  9. #include "cybtldr_utils.h"
  10. /*
  11. * This enum defines the different operations that can be performed
  12. * by the bootloader host.
  13. */
  14. typedef enum
  15. {
  16. /* Perform a Program operation*/
  17. PROGRAM,
  18. /* Perform an Erase operation */
  19. ERASE,
  20. /* Perform a Verify operation */
  21. VERIFY,
  22. } CyBtldr_Action;
  23. /* Function used to notify caller that a row was finished */
  24. typedef void CyBtldr_ProgressUpdate(unsigned char arrayId, unsigned short rowNum);
  25. /*******************************************************************************
  26. * Function Name: CyBtldr_RunAction
  27. ********************************************************************************
  28. * Summary:
  29. *
  30. *
  31. * Parameters:
  32. * action - The action to execute
  33. * file – The full canonical path to the *.cyacd file to open
  34. * comm – Communication struct used for communicating with the target device
  35. * update - Optional function pointer to use to notify of progress updates
  36. *
  37. * Returns:
  38. * CYRET_SUCCESS - The device was programmed successfully
  39. * CYRET_ERR_DEVICE - The detected device does not match the desired device
  40. * CYRET_ERR_VERSION - The detected bootloader version is not compatible
  41. * CYRET_ERR_LENGTH - The result packet does not have enough data
  42. * CYRET_ERR_DATA - The result packet does not contain valid data
  43. * CYRET_ERR_ARRAY - The array is not valid for programming
  44. * CYRET_ERR_ROW - The array/row number is not valid for programming
  45. * CYRET_ERR_CHECKSUM - The checksum does not match the expected value
  46. * CYRET_ERR_BTLDR - The bootloader experienced an error
  47. * CYRET_ERR_COMM - There was a communication error talking to the device
  48. * CYRET_ABORT - The operation was aborted
  49. *
  50. *******************************************************************************/
  51. int CyBtldr_RunAction(CyBtldr_Action action, const char* file,
  52. CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update);
  53. /*******************************************************************************
  54. * Function Name: CyBtldr_Program
  55. ********************************************************************************
  56. * Summary:
  57. * This function reprograms the bootloadable portion of the PSoC’s flash with
  58. * the contents of the provided *.cyacd file.
  59. *
  60. * Parameters:
  61. * file – The full canonical path to the *.cyacd file to open
  62. * comm – Communication struct used for communicating with the target device
  63. * update - Optional function pointer to use to notify of progress updates
  64. *
  65. * Returns:
  66. * CYRET_SUCCESS - The device was programmed successfully
  67. * CYRET_ERR_DEVICE - The detected device does not match the desired device
  68. * CYRET_ERR_VERSION - The detected bootloader version is not compatible
  69. * CYRET_ERR_LENGTH - The result packet does not have enough data
  70. * CYRET_ERR_DATA - The result packet does not contain valid data
  71. * CYRET_ERR_ARRAY - The array is not valid for programming
  72. * CYRET_ERR_ROW - The array/row number is not valid for programming
  73. * CYRET_ERR_BTLDR - The bootloader experienced an error
  74. * CYRET_ERR_COMM - There was a communication error talking to the device
  75. * CYRET_ABORT - The operation was aborted
  76. *
  77. *******************************************************************************/
  78. EXTERN int CyBtldr_Program(const char* file, CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update);
  79. /*******************************************************************************
  80. * Function Name: CyBtldr_Erase
  81. ********************************************************************************
  82. * Summary:
  83. * This function erases the bootloadable portion of the PSoC’s flash contained
  84. * within the specified *.cyacd file.
  85. *
  86. *
  87. * Parameters:
  88. * file – The full canonical path to the *.cyacd file to open
  89. * comm – Communication struct used for communicating with the target device
  90. * update - Optional function pointer to use to notify of progress updates
  91. *
  92. * Returns:
  93. * CYRET_SUCCESS - The device was erased successfully
  94. * CYRET_ERR_DEVICE - The detected device does not match the desired device
  95. * CYRET_ERR_VERSION - The detected bootloader version is not compatible
  96. * CYRET_ERR_LENGTH - The result packet does not have enough data
  97. * CYRET_ERR_DATA - The result packet does not contain valid data
  98. * CYRET_ERR_ARRAY - The array is not valid for programming
  99. * CYRET_ERR_ROW - The array/row number is not valid for programming
  100. * CYRET_ERR_BTLDR - The bootloader experienced an error
  101. * CYRET_ERR_COMM - There was a communication error talking to the device
  102. * CYRET_ABORT - The operation was aborted
  103. *
  104. *******************************************************************************/
  105. EXTERN int CyBtldr_Erase(const char* file, CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update);
  106. /*******************************************************************************
  107. * Function Name: CyBtldr_Verify
  108. ********************************************************************************
  109. * Summary:
  110. * This function verifies the contents of bootloadable portion of the PSoC’s
  111. * flash with the contents of the provided *.cyacd file.
  112. *
  113. * Parameters:
  114. * file – The full canonical path to the *.cyacd file to open
  115. * comm – Communication struct used for communicating with the target device
  116. * update - Optional function pointer to use to notify of progress updates
  117. *
  118. * Returns:
  119. * CYRET_SUCCESS - The device’s flash image was verified successfully
  120. * CYRET_ERR_DEVICE - The detected device does not match the desired device
  121. * CYRET_ERR_VERSION - The detected bootloader version is not compatible
  122. * CYRET_ERR_LENGTH - The result packet does not have enough data
  123. * CYRET_ERR_DATA - The result packet does not contain valid data
  124. * CYRET_ERR_ARRAY - The array is not valid for programming
  125. * CYRET_ERR_ROW - The array/row number is not valid for programming
  126. * CYRET_ERR_CHECKSUM - The checksum does not match the expected value
  127. * CYRET_ERR_BTLDR - The bootloader experienced an error
  128. * CYRET_ERR_COMM - There was a communication error talking to the device
  129. * CYRET_ABORT - The operation was aborted
  130. *
  131. *******************************************************************************/
  132. EXTERN int CyBtldr_Verify(const char* file, CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update);
  133. /*******************************************************************************
  134. * Function Name: CyBtldr_Abort
  135. ********************************************************************************
  136. * Summary:
  137. * This function aborts the current operation, whether it be Programming,
  138. * Erasing, or Verifying. This is done by setting a global flag that the
  139. * Program, Erase & Verify operations check at the end of each row operation.
  140. * Since all calls are blocking, this will need to be called from a different
  141. * execution thread.
  142. *
  143. * Parameters:
  144. * void.
  145. *
  146. * Returns:
  147. * CYRET_SUCCESS - The abort was sent successfully
  148. *
  149. *******************************************************************************/
  150. EXTERN int CyBtldr_Abort(void);
  151. #endif