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.
 
 
 
 

189 line
7.2 KiB

  1. /*******************************************************************************
  2. WINC Flash Interface.
  3. File Name:
  4. m2m_flash.h
  5. Summary:
  6. WINC Flash Interface
  7. Description:
  8. WINC Flash Interface
  9. *******************************************************************************/
  10. //DOM-IGNORE-BEGIN
  11. /*******************************************************************************
  12. * Copyright (C) 2021 Microchip Technology Inc. and its subsidiaries.
  13. *
  14. * Subject to your compliance with these terms, you may use Microchip software
  15. * and any derivatives exclusively with Microchip products. It is your
  16. * responsibility to comply with third party license terms applicable to your
  17. * use of third party software (including open source software) that may
  18. * accompany Microchip software.
  19. *
  20. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
  21. * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
  22. * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
  23. * PARTICULAR PURPOSE.
  24. *
  25. * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
  26. * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
  27. * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
  28. * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
  29. * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
  30. * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  31. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  32. *******************************************************************************/
  33. // DOM-IGNORE-END
  34. /**@defgroup FLASHAPI Flash
  35. */
  36. #ifndef __M2M_FLASH_H__
  37. #define __M2M_FLASH_H__
  38. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  39. INCLUDES
  40. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  41. #include "nm_common.h"
  42. #include "m2m_types.h"
  43. /**@defgroup FlashEnums Enumeration/Typedefs
  44. * @ingroup FLASHAPI
  45. * @{*/
  46. /*!
  47. @enum tenuWincFlashRegion
  48. @brief The regions of WINC flash available for accessing.
  49. */
  50. typedef enum
  51. {
  52. /*! Access to the entire flash address space. */
  53. WINC_FLASH_REGION_RAW,
  54. /*! Access to the active firmware region. */
  55. WINC_FLASH_REGION_FIRMWARE_ACTIVE,
  56. /*! Access to the inactive firmware region. */
  57. WINC_FLASH_REGION_FIRMWARE_INACTIVE,
  58. /*! Access to PLL table region. Erase is not supported for this region. */
  59. WINC_FLASH_REGION_PLL_TABLE,
  60. /*! Access to gain table region. Erase is not supported for this region. */
  61. WINC_FLASH_REGION_GAIN_TABLE,
  62. /*! Access to PLL and gain tables region. Erase is supported for this region. */
  63. WINC_FLASH_REGION_PLL_AND_GAIN_TABLES,
  64. /*! Access to TLS root certificate region. */
  65. WINC_FLASH_REGION_ROOT_CERTS,
  66. /*! Access to TLS local certificate region. */
  67. WINC_FLASH_REGION_LOCAL_CERTS,
  68. /*! Access to connection parameters region. */
  69. WINC_FLASH_REGION_CONN_PARAM,
  70. /*! Access to HTTP files region. This region is also erased/written by erase/write of firmware regions. */
  71. WINC_FLASH_REGION_HTTP_FILES,
  72. /*! Number of regions. */
  73. WINC_FLASH_NUM_REGIONS
  74. } tenuWincFlashRegion;
  75. /**@}
  76. */
  77. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  78. FUNCTION PROTOTYPES
  79. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  80. /** \defgroup FLASHFUNCTIONS Functions
  81. * @ingroup FLASHAPI
  82. */
  83. /**@{*/
  84. /*!
  85. @fn \
  86. int8_t m2m_flash_erase_sector(tenuWincFlashRegion enuRegion, uint8_t u8StartSector, uint8_t u8NumSectors);
  87. @brief Erase one or more sectors within a WINC flash region.
  88. @param [in] enuRegion
  89. Region of flash in which to erase.
  90. @param [in] u8StartSector
  91. Sector offset (within region) of first sector to erase.
  92. @param [in] u8NumSectors
  93. Number of sectors to erase.
  94. @return M2M_SUCCESS - The erase completed successfully.
  95. M2M_ERR_INVALID_ARG - The parameters were invalid.
  96. M2M_ERR_FAIL - The request encountered an error.
  97. @pre The WINC must have been initialised but must not be running. This can be done via
  98. @ref m2m_wifi_init_hold, @ref m2m_wifi_reinit_hold or @ref m2m_wifi_download_mode.
  99. */
  100. int8_t m2m_flash_erase_sector(tenuWincFlashRegion enuRegion, uint8_t u8StartSector, uint8_t u8NumSectors);
  101. /*!
  102. @fn \
  103. int8_t m2m_flash_write(tenuWincFlashRegion enuRegion, void *pvBuffer, uint32_t u32Offset, uint32_t u32Size);
  104. @brief Write the number of bytes specified to a WINC flash location.
  105. @param [in] enuRegion
  106. Region of flash in which to write.
  107. @param [in] pvBuffer
  108. Pointer to buffer containing the data to write.
  109. @param [in] u32Offset
  110. Byte offset (within region) of write location.
  111. @param [in] u32Size
  112. Number of bytes to write.
  113. @return M2M_SUCCESS - The write completed successfully.
  114. M2M_ERR_INVALID_ARG - The parameters were invalid.
  115. M2M_ERR_FAIL - The request encountered an error.
  116. @pre The WINC must have been initialised but must not be running. This can be done via
  117. @ref m2m_wifi_init_hold, @ref m2m_wifi_reinit_hold or @ref m2m_wifi_download_mode.
  118. @warning The write operation does not erase the flash device first, therefore the user
  119. must ensure the flash region has been erased first.
  120. */
  121. int8_t m2m_flash_write(tenuWincFlashRegion enuRegion, void *pvBuffer, uint32_t u32Offset, uint32_t u32Size);
  122. /*!
  123. @fn \
  124. int8_t m2m_flash_read(tenuWincFlashRegion enuRegion, void *pvBuffer, uint32_t u32Offset, uint32_t u32Size);
  125. @brief Read the number of bytes specified from a WINC flash location.
  126. @param [in] enuRegion
  127. Region of flash from which to read.
  128. @param [out] pvBuffer
  129. Pointer to buffer to populate with the data being read.
  130. @param [in] u32Offset
  131. Byte offset (within region) of read location.
  132. @param [in] u32Size
  133. Number of bytes to read.
  134. @return M2M_SUCCESS - The read completed successfully.
  135. M2M_ERR_INVALID_ARG - The parameters were invalid.
  136. M2M_ERR_FAIL - The request encountered an error.
  137. @pre The WINC must have been initialised but must not be running. This can be done via
  138. @ref m2m_wifi_init_hold, @ref m2m_wifi_reinit_hold or @ref m2m_wifi_download_mode.
  139. */
  140. int8_t m2m_flash_read(tenuWincFlashRegion enuRegion, void *pvBuffer, uint32_t u32Offset, uint32_t u32Size);
  141. /*!
  142. @fn \
  143. int8_t m2m_flash_switch_firmware(void);
  144. @brief Switch the active and inactive firmware images.
  145. @return M2M_SUCCESS - The firmware switch completed successfully.
  146. M2M_ERR_FAIL - The request encountered an error.
  147. @pre The WINC must have been initialised but must not be running. This can be done via
  148. @ref m2m_wifi_init_hold, @ref m2m_wifi_reinit_hold or @ref m2m_wifi_download_mode.
  149. */
  150. int8_t m2m_flash_switch_firmware(void);
  151. /**@}*/
  152. #endif /* __M2M_FLASH_H__ */