Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

310 rader
9.9 KiB

  1. /**
  2. *
  3. * \file
  4. *
  5. * \brief WINC3400 Peripherals Application Interface.
  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. #ifndef _M2M_PERIPH_H_
  35. #define _M2M_PERIPH_H_
  36. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  37. INCLUDES
  38. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  39. #include "common/include/nm_common.h"
  40. #include "driver/include/m2m_types.h"
  41. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  42. MACROS
  43. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  44. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  45. DATA TYPES
  46. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  47. /*!
  48. @struct \
  49. tstrPerphInitParam
  50. @brief
  51. Peripheral module initialization parameters.
  52. */
  53. typedef struct {
  54. void * arg;
  55. } tstrPerphInitParam;
  56. /*!
  57. @enum \
  58. tenuGpioNum
  59. @brief
  60. A list of GPIO numbers configurable through the m2m_periph module.
  61. */
  62. typedef enum {
  63. M2M_PERIPH_GPIO3,
  64. M2M_PERIPH_GPIO4,
  65. M2M_PERIPH_GPIO15, /*!< GPIO15 pad */
  66. M2M_PERIPH_GPIO16, /*!< GPIO16 pad */
  67. M2M_PERIPH_GPIO18, /*!< GPIO18 pad */
  68. M2M_PERIPH_GPIO_MAX
  69. } tenuGpioNum;
  70. /*!
  71. @enum \
  72. tenuI2cMasterSclMuxOpt
  73. @brief
  74. Allowed pin multiplexing options for I2C master SCL signal.
  75. */
  76. typedef enum {
  77. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_HOST_WAKEUP, /*!< I2C master SCL is avaiable on HOST_WAKEUP. */
  78. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_SD_DAT3, /*!< I2C master SCL is avaiable on SD_DAT3 (GPIO 7). */
  79. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_GPIO13, /*!< I2C master SCL is avaiable on GPIO 13. */
  80. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_GPIO4, /*!< I2C master SCL is avaiable on GPIO 4.*/
  81. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_I2C_SCL, /*!< I2C master SCL is avaiable on I2C slave SCL. */
  82. M2M_PERIPH_I2C_MASTER_SCL_MUX_OPT_NUM
  83. } tenuI2cMasterSclMuxOpt;
  84. /*!
  85. @enum \
  86. tenuI2cMasterSdaMuxOpt
  87. @brief
  88. Allowed pin multiplexing options for I2C master SDA signal.
  89. */
  90. typedef enum {
  91. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_RTC_CLK , /*!< I2C master SDA is avaiable on RTC_CLK. */
  92. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_SD_CLK, /*!< I2C master SDA is avaiable on SD_CLK (GPIO 8). */
  93. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_GPIO14, /*!< I2C master SDA is avaiable on GPIO 14. */
  94. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_GPIO6, /*!< I2C master SDA is avaiable on GPIO 6.*/
  95. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_I2C_SDA, /*!< I2C master SDA is avaiable on I2C slave SDA. */
  96. M2M_PERIPH_I2C_MASTER_SDA_MUX_OPT_NUM
  97. } tenuI2cMasterSdaMuxOpt;
  98. /*!
  99. @struct \
  100. tstrI2cMasterInitParam
  101. @brief
  102. I2C master configuration parameters.
  103. @sa
  104. tenuI2cMasterSclMuxOpt
  105. tenuI2cMasterSdaMuxOpt
  106. */
  107. typedef struct {
  108. uint8 enuSclMuxOpt; /*!< SCL multiplexing option. Allowed value are defined in tenuI2cMasterSclMuxOpt */
  109. uint8 enuSdaMuxOpt; /*!< SDA multiplexing option. Allowed value are defined in tenuI2cMasterSdaMuxOpt */
  110. uint8 u8ClkSpeedKHz; /*!< I2C master clock speed in KHz. */
  111. } tstrI2cMasterInitParam;
  112. /*!
  113. @enum \
  114. tenuI2cMasterFlags
  115. @brief
  116. Bitwise-ORed flags for use in m2m_periph_i2c_master_write and m2m_periph_i2c_master_read
  117. @sa
  118. m2m_periph_i2c_master_write
  119. m2m_periph_i2c_master_read
  120. */
  121. typedef enum {
  122. I2C_MASTER_NO_FLAGS = 0x00,
  123. /*!< No flags. */
  124. I2C_MASTER_NO_STOP = 0x01,
  125. /*!< No stop bit after this transaction. Useful for scattered buffer read/write operations. */
  126. I2C_MASTER_NO_START = 0x02,
  127. /*!< No start bit at the beginning of this transaction. Useful for scattered buffer read/write operations.*/
  128. } tenuI2cMasterFlags;
  129. /*!
  130. @enum \
  131. tenuPullupMask
  132. @brief
  133. Bitwise-ORed flags for use in m2m_perph_pullup_ctrl.
  134. @sa
  135. m2m_periph_pullup_ctrl
  136. */
  137. typedef enum {
  138. M2M_PERIPH_PULLUP_DIS_HOST_WAKEUP = (1ul << 0),
  139. M2M_PERIPH_PULLUP_DIS_RTC_CLK = (1ul << 1),
  140. M2M_PERIPH_PULLUP_DIS_IRQN = (1ul << 2),
  141. M2M_PERIPH_PULLUP_DIS_GPIO_3 = (1ul << 3),
  142. M2M_PERIPH_PULLUP_DIS_GPIO_4 = (1ul << 4),
  143. M2M_PERIPH_PULLUP_DIS_GPIO_5 = (1ul << 5),
  144. M2M_PERIPH_PULLUP_DIS_GPIO_6 = (1ul << 6),
  145. M2M_PERIPH_PULLUP_DIS_SD_CLK = (1ul << 7),
  146. M2M_PERIPH_PULLUP_DIS_SD_CMD_SPI_SCK = (1ul << 8),
  147. M2M_PERIPH_PULLUP_DIS_SD_DAT0_SPI_TXD = (1ul << 9),
  148. M2M_PERIPH_PULLUP_DIS_SD_DAT1_SPI_SSN = (1ul << 10),
  149. M2M_PERIPH_PULLUP_DIS_SD_DAT1_SPI_RXD = (1ul << 11),
  150. M2M_PERIPH_PULLUP_DIS_SD_DAT3 = (1ul << 12),
  151. } tenuPullupEnable1Mask;
  152. typedef enum {
  153. M2M_PERIPH_PULLUP_DIS_GPIO_13 = (1ul << 0),
  154. M2M_PERIPH_PULLUP_DIS_GPIO_14 = (1ul << 1),
  155. M2M_PERIPH_PULLUP_DIS_GPIO_15 = (1ul << 2),
  156. M2M_PERIPH_PULLUP_DIS_GPIO_16 = (1ul << 3),
  157. M2M_PERIPH_PULLUP_DIS_GPIO_17 = (1ul << 4),
  158. M2M_PERIPH_PULLUP_DIS_GPIO_18 = (1ul << 5),
  159. M2M_PERIPH_PULLUP_DIS_GPIO_19 = (1ul << 6),
  160. M2M_PERIPH_PULLUP_DIS_GPIO_20 = (1ul << 7),
  161. M2M_PERIPH_PULLUP_DIS_GPIO_22 = (1ul << 9),
  162. M2M_PERIPH_PULLUP_DIS_GPIO_23 = (1ul << 10),
  163. M2M_PERIPH_PULLUP_DIS_GPIO_38 = (1ul << 25),
  164. M2M_PERIPH_PULLUP_DIS_GPIO_39 = (1ul << 26),
  165. M2M_PERIPH_PULLUP_DIS_GPIO_40 = (1ul << 27),
  166. M2M_PERIPH_PULLUP_DIS_GPIO_42 = (1ul << 29),
  167. } tenuPullupEnable2Mask;
  168. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
  169. FUNCTION PROTOTYPES
  170. *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
  171. #ifdef __cplusplus
  172. extern "C" {
  173. #endif
  174. /*!
  175. @fn \
  176. NMI_API sint8 m2m_periph_init(tstrPerphInitParam * param);
  177. @brief
  178. Initialize the NMC1500 peripheral driver module.
  179. @param [in] param
  180. Peripheral module initialization structure. See members of tstrPerphInitParam.
  181. @return
  182. The function SHALL return 0 for success and a negative value otherwise.
  183. @sa
  184. tstrPerphInitParam
  185. */
  186. NMI_API sint8 m2m_periph_init(tstrPerphInitParam * param);
  187. /*!
  188. @fn \
  189. NMI_API sint8 m2m_periph_gpio_set_dir(uint8 u8GpioNum, uint8 u8GpioDir);
  190. @brief
  191. Configure a specific NMC1500 pad as a GPIO and sets its direction (input or output).
  192. @param [in] u8GpioNum
  193. GPIO number. Allowed values are defined in tenuGpioNum.
  194. @param [in] u8GpioDir
  195. GPIO direction: Zero = input. Non-zero = output.
  196. @return
  197. The function SHALL return 0 for success and a negative value otherwise.
  198. @sa
  199. tenuGpioNum
  200. */
  201. NMI_API sint8 m2m_periph_gpio_set_dir(uint8 u8GpioNum, uint8 u8GpioDir);
  202. /*!
  203. @fn \
  204. NMI_API sint8 m2m_periph_gpio_set_val(uint8 u8GpioNum, uint8 u8GpioVal);
  205. @brief
  206. Set an NMC1500 GPIO output level high or low.
  207. @param [in] u8GpioNum
  208. GPIO number. Allowed values are defined in tenuGpioNum.
  209. @param [in] u8GpioVal
  210. GPIO output value. Zero = low, non-zero = high.
  211. @return
  212. The function SHALL return 0 for success and a negative value otherwise.
  213. @sa
  214. tenuGpioNum
  215. */
  216. NMI_API sint8 m2m_periph_gpio_set_val(uint8 u8GpioNum, uint8 u8GpioVal);
  217. /*!
  218. @fn \
  219. NMI_API sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 * pu8GpioVal);
  220. @brief
  221. Read an NMC1500 GPIO input level.
  222. @param [in] u8GpioNum
  223. GPIO number. Allowed values are defined in tenuGpioNum.
  224. @param [out] pu8GpioVal
  225. GPIO input value. Zero = low, non-zero = high.
  226. @return
  227. The function SHALL return 0 for success and a negative value otherwise.
  228. @sa
  229. tenuGpioNum
  230. */
  231. NMI_API sint8 m2m_periph_gpio_get_val(uint8 u8GpioNum, uint8 * pu8GpioVal);
  232. /*!
  233. @fn \
  234. NMI_API sint8 m2m_periph_pullup_ctrl(uint32 pinmask, uint8 enable);
  235. @brief
  236. Control the programmable pull-up resistor on the chip pads .
  237. @param [in] pinmask
  238. Write operation bitwise-ORed mask for which pads to control. Allowed values are defined in tenuPullupMask.
  239. @param [in] enable
  240. Set to 0 to disable pull-up resistor. Non-zero will enable the pull-up.
  241. @return
  242. The function SHALL return 0 for success and a negative value otherwise.
  243. @sa
  244. tenuPullupMask
  245. */
  246. NMI_API sint8 m2m_periph_pullup_ctrl(uint32 pinmask, uint8 enable);
  247. #ifdef __cplusplus
  248. }
  249. #endif
  250. #endif /* _M2M_PERIPH_H_ */