Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

249 lignes
7.2 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief This module contains WINC3400 BSP APIs declarations.
  6. *
  7. * Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
  8. *
  9. * \asf_license_start
  10. *
  11. * \page License
  12. *
  13. * Subject to your compliance with these terms, you may use Microchip
  14. * software and any derivatives exclusively with Microchip products.
  15. * It is your responsibility to comply with third party license terms applicable
  16. * to your use of third party software (including open source software) that
  17. * may accompany Microchip software.
  18. *
  19. * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
  20. * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
  21. * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
  22. * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
  23. * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
  24. * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
  25. * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
  26. * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
  27. * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
  28. * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
  29. * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
  30. *
  31. * \asf_license_stop
  32. *
  33. */
  34. /**@defgroup nm_bsp BSP
  35. */
  36. /**@defgroup BSPDefine Defines
  37. * @ingroup nm_bsp
  38. * @{
  39. */
  40. #ifndef _NM_BSP_H_
  41. #define _NM_BSP_H_
  42. #define NMI_API
  43. /*!<
  44. * Attribute used to define memory section to map Functions in host memory.
  45. */
  46. #include "winc3400_config.h"
  47. #define CONST const
  48. #ifndef NULL
  49. #define NULL ((void*)0)
  50. #endif
  51. /*!<
  52. * Void Pointer to '0' in case of NULL is not defined.
  53. */
  54. #define BSP_MIN(x,y) ((x)>(y)?(y):(x))
  55. /*!<
  56. * Computes the minimum of \b x and \b y.
  57. */
  58. //@}
  59. /**@defgroup DataT Enumeration/Typedefs
  60. * @ingroup nm_bsp
  61. * @{
  62. */
  63. /*!
  64. * Used for code portability.
  65. */
  66. /*!
  67. * @typedef void (*tpfNmBspIsr) (void);
  68. * @brief Pointer to function.\n
  69. * Used as a data type of ISR function registered by \ref nm_bsp_register_isr
  70. * @return None
  71. */
  72. typedef void (*tpfNmBspIsr)(void);
  73. /*!
  74. * @ingroup DataTypes
  75. * @typedef unsigned char uint8;
  76. * @brief Range of values between 0 to 255
  77. */
  78. typedef unsigned char uint8;
  79. /*!
  80. * @ingroup DataTypes
  81. * @typedef unsigned short uint16;
  82. * @brief Range of values between 0 to 65535
  83. */
  84. typedef unsigned short uint16;
  85. /*!
  86. * @ingroup Data Types
  87. * @typedef unsigned long uint32;
  88. * @brief Range of values between 0 to 4294967295
  89. */
  90. typedef unsigned long uint32;
  91. /*!
  92. * @ingroup Data Types
  93. * @typedef signed char sint8;
  94. * @brief Range of values between -128 to 127
  95. */
  96. typedef signed char sint8;
  97. /*!
  98. * @ingroup DataTypes
  99. * @typedef signed short sint16;
  100. * @brief Range of values between -32768 to 32767
  101. */
  102. typedef signed short sint16;
  103. /*!
  104. * @ingroup DataTypes
  105. * @typedef signed long sint32;
  106. * @brief Range of values between -2147483648 to 2147483647
  107. */
  108. typedef signed long sint32;
  109. //@}
  110. #ifndef CORTUS_APP
  111. #ifdef __cplusplus
  112. extern "C"{
  113. #endif
  114. /** \defgroup BSPAPI Functions
  115. * @ingroup nm_bsp
  116. * @{
  117. */
  118. /*!
  119. * @fn sint8 nm_bsp_init(void);
  120. * Initialization for BSP such as Reset and Chip Enable Pins for WINC, delays, register ISR, enable/disable IRQ for WINC, ...etc. You must use this function in the head of your application to
  121. * enable WINC and Host Driver to communicate with each other.
  122. * @note Implementation of this function is host dependent.
  123. * @warning Omission will lead to unavailability of host communication.\n
  124. *
  125. * @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
  126. */
  127. sint8 nm_bsp_init(void);
  128. /*!
  129. * @fn sint8 nm_bsp_deinit(void);
  130. * De-initialization for BSP (\e Board \e Support \e Package)
  131. * @pre Initialize \ref nm_bsp_init first
  132. * @note Implementation of this function is host dependent.
  133. * @warning Omission may lead to unknown behavior in case of soft reset.\n
  134. * @see nm_bsp_init
  135. * @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise.
  136. */
  137. sint8 nm_bsp_deinit(void);
  138. /*!
  139. * @fn void nm_bsp_reset(void);
  140. * Resetting NMC1500 SoC by setting CHIP_EN and RESET_N signals low, then after specific delay the function will put CHIP_EN high then RESET_N high,
  141. * for the timing between signals please review the WINC data-sheet
  142. * @pre Initialize \ref nm_bsp_init first
  143. * @note Implementation of this function is host dependent and called by HIF layer.
  144. * @see nm_bsp_init
  145. * @return None
  146. */
  147. void nm_bsp_reset(void);
  148. /*!
  149. * @fn void nm_bsp_sleep(uint32);
  150. * Sleep in units of milliseconds.\n
  151. * This function is used by HIF Layer as required in various situations.
  152. * @brief
  153. * @param [in] u32TimeMsec
  154. * Time unit in milliseconds
  155. * @pre Initialize \ref nm_bsp_init first
  156. * @warning Maximum value must nor exceed 4294967295 milliseconds which is equal to 4294967.295 seconds.\n
  157. * @note Implementation of this function is host dependent.
  158. * @see nm_bsp_init
  159. * @return None
  160. */
  161. void nm_bsp_sleep(uint32 u32TimeMsec);
  162. /*!
  163. * @fn void nm_bsp_register_isr(tpfNmBspIsr);
  164. * Register ISR (Interrupt Service Routine) in the initialization of HIF (Host Interface) Layer.
  165. * When the interrupt trigger the BSP layer should call the pfisr function once inside the interrupt.
  166. * @param [in] pfIsr
  167. * Pointer to ISR handler in HIF
  168. * @warning Make sure that ISR for IRQ pin for WINC is disabled by default in your implementation.
  169. * @note Implementation of this function is host dependent and called by HIF layer.
  170. * @see tpfNmBspIsr
  171. * @return None
  172. */
  173. void nm_bsp_register_isr(tpfNmBspIsr pfIsr);
  174. /*!
  175. * @fn void nm_bsp_interrupt_ctrl(uint8);
  176. * Synchronous enable/disable interrupts function
  177. * @brief Enable/Disable interrupts
  178. * @param [in] u8Enable
  179. * '0' disable interrupts. '1' enable interrupts
  180. * @see tpfNmBspIsr
  181. * @note Implementation of this function is host dependent and called by HIF layer.
  182. * @return None
  183. */
  184. void nm_bsp_interrupt_ctrl(uint8 u8Enable);
  185. /**@}*/
  186. #ifdef __cplusplus
  187. }
  188. #endif
  189. #endif
  190. /**
  191. * @addtogroup BSPDefine
  192. * @{
  193. */
  194. #ifdef _NM_BSP_BIG_END
  195. /*! Switch endianness of 32bit word (In the case that Host is BE) */
  196. #define NM_BSP_B_L_32(x) \
  197. ((((x) & 0x000000FF) << 24) + \
  198. (((x) & 0x0000FF00) << 8) + \
  199. (((x) & 0x00FF0000) >> 8) + \
  200. (((x) & 0xFF000000) >> 24))
  201. /*! Switch endianness of 16bit word (In the case that Host is BE) */
  202. #define NM_BSP_B_L_16(x) \
  203. ((((x) & 0x00FF) << 8) + \
  204. (((x) & 0xFF00) >> 8))
  205. #else
  206. /*! Retain endianness of 32bit word (In the case that Host is LE) */
  207. #define NM_BSP_B_L_32(x) (x)
  208. /*! Retain endianness of 16bit word (In the case that Host is LE) */
  209. #define NM_BSP_B_L_16(x) (x)
  210. #endif
  211. /**@}
  212. */
  213. #endif /*_NM_BSP_H_*/