stm32f4xx_hal_fmpi2c.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_fmpi2c.h
  4. * @author MCD Application Team
  5. * @version V1.4.3
  6. * @date 11-December-2015
  7. * @brief Header file of FMPI2C HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_HAL_FMPI2C_H
  39. #define __STM32F4xx_HAL_FMPI2C_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal_def.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup FMPI2C
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup FMPI2C_Exported_Types FMPI2C Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief FMPI2C Configuration Structure definition
  58. */
  59. typedef struct
  60. {
  61. uint32_t Timing; /*!< Specifies the FMPI2C_TIMINGR_register value.
  62. This parameter calculated by referring to FMPI2C initialization
  63. section in Reference manual */
  64. uint32_t OwnAddress1; /*!< Specifies the first device own address.
  65. This parameter can be a 7-bit or 10-bit address. */
  66. uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
  67. This parameter can be a value of @ref FMPI2C_addressing_mode */
  68. uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
  69. This parameter can be a value of @ref FMPI2C_dual_addressing_mode */
  70. uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
  71. This parameter can be a 7-bit address. */
  72. uint32_t OwnAddress2Masks; /*!< Specifies the acknoledge mask address second device own address if dual addressing mode is selected
  73. This parameter can be a value of @ref FMPI2C_own_address2_masks */
  74. uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
  75. This parameter can be a value of @ref FMPI2C_general_call_addressing_mode */
  76. uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
  77. This parameter can be a value of @ref FMPI2C_nostretch_mode */
  78. }FMPI2C_InitTypeDef;
  79. /**
  80. * @brief HAL State structures definition
  81. */
  82. typedef enum
  83. {
  84. HAL_FMPI2C_STATE_RESET = 0x00, /*!< FMPI2C not yet initialized or disabled */
  85. HAL_FMPI2C_STATE_READY = 0x01, /*!< FMPI2C initialized and ready for use */
  86. HAL_FMPI2C_STATE_BUSY = 0x02, /*!< FMPI2C internal process is ongoing */
  87. HAL_FMPI2C_STATE_MASTER_BUSY_TX = 0x12, /*!< Master Data Transmission process is ongoing */
  88. HAL_FMPI2C_STATE_MASTER_BUSY_RX = 0x22, /*!< Master Data Reception process is ongoing */
  89. HAL_FMPI2C_STATE_SLAVE_BUSY_TX = 0x32, /*!< Slave Data Transmission process is ongoing */
  90. HAL_FMPI2C_STATE_SLAVE_BUSY_RX = 0x42, /*!< Slave Data Reception process is ongoing */
  91. HAL_FMPI2C_STATE_MEM_BUSY_TX = 0x52, /*!< Memory Data Transmission process is ongoing */
  92. HAL_FMPI2C_STATE_MEM_BUSY_RX = 0x62, /*!< Memory Data Reception process is ongoing */
  93. HAL_FMPI2C_STATE_TIMEOUT = 0x03, /*!< Timeout state */
  94. HAL_FMPI2C_STATE_ERROR = 0x04 /*!< Reception process is ongoing */
  95. }HAL_FMPI2C_StateTypeDef;
  96. /**
  97. * @brief HAL FMPI2C Error Code structure definition
  98. */
  99. typedef enum
  100. {
  101. HAL_FMPI2C_ERROR_NONE = 0x00, /*!< No error */
  102. HAL_FMPI2C_ERROR_BERR = 0x01, /*!< BERR error */
  103. HAL_FMPI2C_ERROR_ARLO = 0x02, /*!< ARLO error */
  104. HAL_FMPI2C_ERROR_AF = 0x04, /*!< ACKF error */
  105. HAL_FMPI2C_ERROR_OVR = 0x08, /*!< OVR error */
  106. HAL_FMPI2C_ERROR_DMA = 0x10, /*!< DMA transfer error */
  107. HAL_FMPI2C_ERROR_TIMEOUT = 0x20, /*!< Timeout error */
  108. HAL_FMPI2C_ERROR_SIZE = 0x40 /*!< Size Management error */
  109. }HAL_FMPI2C_ErrorTypeDef;
  110. /**
  111. * @brief FMPI2C handle Structure definition
  112. */
  113. typedef struct
  114. {
  115. FMPI2C_TypeDef *Instance; /*!< FMPI2C registers base address */
  116. FMPI2C_InitTypeDef Init; /*!< FMPI2C communication parameters */
  117. uint8_t *pBuffPtr; /*!< Pointer to FMPI2C transfer buffer */
  118. uint16_t XferSize; /*!< FMPI2C transfer size */
  119. __IO uint16_t XferCount; /*!< FMPI2C transfer counter */
  120. DMA_HandleTypeDef *hdmatx; /*!< FMPI2C Tx DMA handle parameters */
  121. DMA_HandleTypeDef *hdmarx; /*!< FMPI2C Rx DMA handle parameters */
  122. HAL_LockTypeDef Lock; /*!< FMPI2C locking object */
  123. __IO HAL_FMPI2C_StateTypeDef State; /*!< FMPI2C communication state */
  124. __IO HAL_FMPI2C_ErrorTypeDef ErrorCode; /* FMPI2C Error code */
  125. }FMPI2C_HandleTypeDef;
  126. /**
  127. * @}
  128. */
  129. /* Exported constants --------------------------------------------------------*/
  130. /** @defgroup FMPI2C_Exported_Constants FMPI2C Exported Constants
  131. * @{
  132. */
  133. /** @defgroup FMPI2C_addressing_mode FMPI2C addressing mode
  134. * @{
  135. */
  136. #define FMPI2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00000001)
  137. #define FMPI2C_ADDRESSINGMODE_10BIT ((uint32_t)0x00000002)
  138. /**
  139. * @}
  140. */
  141. /** @defgroup FMPI2C_dual_addressing_mode FMPI2C dual addressing mode
  142. * @{
  143. */
  144. #define FMPI2C_DUALADDRESS_DISABLE ((uint32_t)0x00000000)
  145. #define FMPI2C_DUALADDRESS_ENABLE FMPI2C_OAR2_OA2EN
  146. /**
  147. * @}
  148. */
  149. /** @defgroup FMPI2C_own_address2_masks FMPI2C own address2 masks
  150. * @{
  151. */
  152. #define FMPI2C_OA2_NOMASK ((uint8_t)0x00)
  153. #define FMPI2C_OA2_MASK01 ((uint8_t)0x01)
  154. #define FMPI2C_OA2_MASK02 ((uint8_t)0x02)
  155. #define FMPI2C_OA2_MASK03 ((uint8_t)0x03)
  156. #define FMPI2C_OA2_MASK04 ((uint8_t)0x04)
  157. #define FMPI2C_OA2_MASK05 ((uint8_t)0x05)
  158. #define FMPI2C_OA2_MASK06 ((uint8_t)0x06)
  159. #define FMPI2C_OA2_MASK07 ((uint8_t)0x07)
  160. /**
  161. * @}
  162. */
  163. /** @defgroup FMPI2C_general_call_addressing_mode FMPI2C general call addressing mode
  164. * @{
  165. */
  166. #define FMPI2C_GENERALCALL_DISABLE ((uint32_t)0x00000000)
  167. #define FMPI2C_GENERALCALL_ENABLE FMPI2C_CR1_GCEN
  168. /**
  169. * @}
  170. */
  171. /** @defgroup FMPI2C_nostretch_mode FMPI2C nostretch mode
  172. * @{
  173. */
  174. #define FMPI2C_NOSTRETCH_DISABLE ((uint32_t)0x00000000)
  175. #define FMPI2C_NOSTRETCH_ENABLE FMPI2C_CR1_NOSTRETCH
  176. /**
  177. * @}
  178. */
  179. /** @defgroup FMPI2C_Memory_Address_Size FMPI2C Memory Address Size
  180. * @{
  181. */
  182. #define FMPI2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001)
  183. #define FMPI2C_MEMADD_SIZE_16BIT ((uint32_t)0x00000002)
  184. /**
  185. * @}
  186. */
  187. /** @defgroup FMPI2C_ReloadEndMode_definition FMPI2C ReloadEndMode definition
  188. * @{
  189. */
  190. #define FMPI2C_RELOAD_MODE FMPI2C_CR2_RELOAD
  191. #define FMPI2C_AUTOEND_MODE FMPI2C_CR2_AUTOEND
  192. #define FMPI2C_SOFTEND_MODE ((uint32_t)0x00000000)
  193. /**
  194. * @}
  195. */
  196. /** @defgroup FMPI2C_StartStopMode_definition FMPI2C StartStopMode definition
  197. * @{
  198. */
  199. #define FMPI2C_NO_STARTSTOP ((uint32_t)0x00000000)
  200. #define FMPI2C_GENERATE_STOP FMPI2C_CR2_STOP
  201. #define FMPI2C_GENERATE_START_READ (uint32_t)(FMPI2C_CR2_START | FMPI2C_CR2_RD_WRN)
  202. #define FMPI2C_GENERATE_START_WRITE FMPI2C_CR2_START
  203. /**
  204. * @}
  205. */
  206. /** @defgroup FMPI2C_Interrupt_configuration_definition FMPI2C Interrupt configuration definition
  207. * @brief FMPI2C Interrupt definition
  208. * Elements values convention: 0xXXXXXXXX
  209. * - XXXXXXXX : Interrupt control mask
  210. * @{
  211. */
  212. #define FMPI2C_IT_ERRI FMPI2C_CR1_ERRIE
  213. #define FMPI2C_IT_TCI FMPI2C_CR1_TCIE
  214. #define FMPI2C_IT_STOPI FMPI2C_CR1_STOPIE
  215. #define FMPI2C_IT_NACKI FMPI2C_CR1_NACKIE
  216. #define FMPI2C_IT_ADDRI FMPI2C_CR1_ADDRIE
  217. #define FMPI2C_IT_RXI FMPI2C_CR1_RXIE
  218. #define FMPI2C_IT_TXI FMPI2C_CR1_TXIE
  219. /**
  220. * @}
  221. */
  222. /** @defgroup FMPI2C_Flag_definition FMPI2C Flag definition
  223. * @{
  224. */
  225. #define FMPI2C_FLAG_TXE FMPI2C_ISR_TXE
  226. #define FMPI2C_FLAG_TXIS FMPI2C_ISR_TXIS
  227. #define FMPI2C_FLAG_RXNE FMPI2C_ISR_RXNE
  228. #define FMPI2C_FLAG_ADDR FMPI2C_ISR_ADDR
  229. #define FMPI2C_FLAG_AF FMPI2C_ISR_NACKF
  230. #define FMPI2C_FLAG_STOPF FMPI2C_ISR_STOPF
  231. #define FMPI2C_FLAG_TC FMPI2C_ISR_TC
  232. #define FMPI2C_FLAG_TCR FMPI2C_ISR_TCR
  233. #define FMPI2C_FLAG_BERR FMPI2C_ISR_BERR
  234. #define FMPI2C_FLAG_ARLO FMPI2C_ISR_ARLO
  235. #define FMPI2C_FLAG_OVR FMPI2C_ISR_OVR
  236. #define FMPI2C_FLAG_PECERR FMPI2C_ISR_PECERR
  237. #define FMPI2C_FLAG_TIMEOUT FMPI2C_ISR_TIMEOUT
  238. #define FMPI2C_FLAG_ALERT FMPI2C_ISR_ALERT
  239. #define FMPI2C_FLAG_BUSY FMPI2C_ISR_BUSY
  240. #define FMPI2C_FLAG_DIR FMPI2C_ISR_DIR
  241. /**
  242. * @}
  243. */
  244. /**
  245. * @}
  246. */
  247. /* Exported macro ------------------------------------------------------------*/
  248. /** @defgroup FMPI2C_Exported_Macros FMPI2C Exported Macros
  249. * @{
  250. */
  251. /** @brief Reset FMPI2C handle state
  252. * @param __HANDLE__: specifies the FMPI2C Handle.
  253. * This parameter can be FMPI2C where x: 1 or 2 to select the FMPI2C peripheral.
  254. * @retval None
  255. */
  256. #define __HAL_FMPI2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMPI2C_STATE_RESET)
  257. /** @brief Enables or disables the specified FMPI2C interrupts.
  258. * @param __HANDLE__: specifies the FMPI2C Handle.
  259. * This parameter can be FMPI2C where x: 1 or 2 to select the FMPI2C peripheral.
  260. * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
  261. * This parameter can be one of the following values:
  262. * @arg FMPI2C_IT_ERRI: Errors interrupt enable
  263. * @arg FMPI2C_IT_TCI: Transfer complete interrupt enable
  264. * @arg FMPI2C_IT_STOPI: STOP detection interrupt enable
  265. * @arg FMPI2C_IT_NACKI: NACK received interrupt enable
  266. * @arg FMPI2C_IT_ADDRI: Address match interrupt enable
  267. * @arg FMPI2C_IT_RXI: RX interrupt enable
  268. * @arg FMPI2C_IT_TXI: TX interrupt enable
  269. *
  270. * @retval None
  271. */
  272. #define __HAL_FMPI2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
  273. #define __HAL_FMPI2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
  274. /** @brief Checks if the specified FMPI2C interrupt source is enabled or disabled.
  275. * @param __HANDLE__: specifies the FMPI2C Handle.
  276. * This parameter can be FMPI2C where x: 1 or 2 to select the FMPI2C peripheral.
  277. * @param __INTERRUPT__: specifies the FMPI2C interrupt source to check.
  278. * This parameter can be one of the following values:
  279. * @arg FMPI2C_IT_ERRI: Errors interrupt enable
  280. * @arg FMPI2C_IT_TCI: Transfer complete interrupt enable
  281. * @arg FMPI2C_IT_STOPI: STOP detection interrupt enable
  282. * @arg FMPI2C_IT_NACKI: NACK received interrupt enable
  283. * @arg FMPI2C_IT_ADDRI: Address match interrupt enable
  284. * @arg FMPI2C_IT_RXI: RX interrupt enable
  285. * @arg FMPI2C_IT_TXI: TX interrupt enable
  286. *
  287. * @retval The new state of __IT__ (TRUE or FALSE).
  288. */
  289. #define __HAL_FMPI2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  290. /** @brief Checks whether the specified FMPI2C flag is set or not.
  291. * @param __HANDLE__: specifies the FMPI2C Handle.
  292. * This parameter can be FMPI2C where x: 1 or 2 to select the FMPI2C peripheral.
  293. * @param __FLAG__: specifies the flag to check.
  294. * This parameter can be one of the following values:
  295. * @arg FMPI2C_FLAG_TXE: Transmit data register empty
  296. * @arg FMPI2C_FLAG_TXIS: Transmit interrupt status
  297. * @arg FMPI2C_FLAG_RXNE: Receive data register not empty
  298. * @arg FMPI2C_FLAG_ADDR: Address matched (slave mode)
  299. * @arg FMPI2C_FLAG_AF: Acknowledge failure received flag
  300. * @arg FMPI2C_FLAG_STOPF: STOP detection flag
  301. * @arg FMPI2C_FLAG_TC: Transfer complete (master mode)
  302. * @arg FMPI2C_FLAG_TCR: Transfer complete reload
  303. * @arg FMPI2C_FLAG_BERR: Bus error
  304. * @arg FMPI2C_FLAG_ARLO: Arbitration lost
  305. * @arg FMPI2C_FLAG_OVR: Overrun/Underrun
  306. * @arg FMPI2C_FLAG_PECERR: PEC error in reception
  307. * @arg FMPI2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
  308. * @arg FMPI2C_FLAG_ALERT: SMBus alert
  309. * @arg FMPI2C_FLAG_BUSY: Bus busy
  310. * @arg FMPI2C_FLAG_DIR: Transfer direction (slave mode)
  311. *
  312. * @retval The new state of __FLAG__ (TRUE or FALSE).
  313. */
  314. #define __HAL_FMPI2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__) & FMPI2C_FLAG_MASK)) == ((__FLAG__) & FMPI2C_FLAG_MASK)))
  315. /** @brief Clears the FMPI2C pending flags which are cleared by writing 1 in a specific bit.
  316. * @param __HANDLE__: specifies the FMPI2C Handle.
  317. * This parameter can be FMPI2C where x: 1 or 2 to select the FMPI2C peripheral.
  318. * @param __FLAG__: specifies the flag to clear.
  319. * This parameter can be any combination of the following values:
  320. * @arg FMPI2C_FLAG_ADDR: Address matched (slave mode)
  321. * @arg FMPI2C_FLAG_AF: Acknowledge failure received flag
  322. * @arg FMPI2C_FLAG_STOPF: STOP detection flag
  323. * @arg FMPI2C_FLAG_BERR: Bus error
  324. * @arg FMPI2C_FLAG_ARLO: Arbitration lost
  325. * @arg FMPI2C_FLAG_OVR: Overrun/Underrun
  326. * @arg FMPI2C_FLAG_PECERR: PEC error in reception
  327. * @arg FMPI2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
  328. * @arg FMPI2C_FLAG_ALERT: SMBus alert
  329. *
  330. * @retval None
  331. */
  332. #define __HAL_FMPI2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = ((__FLAG__) & FMPI2C_FLAG_MASK))
  333. #define __HAL_FMPI2C_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= FMPI2C_CR1_PE)
  334. #define __HAL_FMPI2C_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~FMPI2C_CR1_PE)
  335. #define __HAL_FMPI2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(FMPI2C_CR2_SADD | FMPI2C_CR2_HEAD10R | FMPI2C_CR2_NBYTES | FMPI2C_CR2_RELOAD | FMPI2C_CR2_RD_WRN)))
  336. #define __HAL_FMPI2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8)))
  337. #define __HAL_FMPI2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
  338. #define __HAL_FMPI2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == FMPI2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (FMPI2C_CR2_SADD)) | (FMPI2C_CR2_START) | (FMPI2C_CR2_AUTOEND)) & (~FMPI2C_CR2_RD_WRN)) : \
  339. (uint32_t)((((uint32_t)(__ADDRESS__) & (FMPI2C_CR2_SADD)) | (FMPI2C_CR2_ADD10) | (FMPI2C_CR2_START)) & (~FMPI2C_CR2_RD_WRN)))
  340. #define IS_FMPI2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= (uint32_t)0x000003FF)
  341. #define IS_FMPI2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF)
  342. /**
  343. * @}
  344. */
  345. /* Include FMPI2C HAL Extension module */
  346. #include "stm32f4xx_hal_fmpi2c_ex.h"
  347. /* Exported functions --------------------------------------------------------*/
  348. /** @addtogroup FMPI2C_Exported_Functions
  349. * @{
  350. */
  351. /** @addtogroup FMPI2C_Exported_Functions_Group1
  352. * @{
  353. */
  354. /* Initialization/de-initialization functions**********************************/
  355. HAL_StatusTypeDef HAL_FMPI2C_Init(FMPI2C_HandleTypeDef *hFMPI2C);
  356. HAL_StatusTypeDef HAL_FMPI2C_DeInit (FMPI2C_HandleTypeDef *hFMPI2C);
  357. void HAL_FMPI2C_MspInit(FMPI2C_HandleTypeDef *hFMPI2C);
  358. void HAL_FMPI2C_MspDeInit(FMPI2C_HandleTypeDef *hFMPI2C);
  359. /**
  360. * @}
  361. */
  362. /** @addtogroup FMPI2C_Exported_Functions_Group2
  363. * @{
  364. */
  365. /* I/O operation functions ***************************************************/
  366. /******* Blocking mode: Polling */
  367. HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  368. HAL_StatusTypeDef HAL_FMPI2C_Master_Receive(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  369. HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  370. HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  371. HAL_StatusTypeDef HAL_FMPI2C_Mem_Write(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  372. HAL_StatusTypeDef HAL_FMPI2C_Mem_Read(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  373. HAL_StatusTypeDef HAL_FMPI2C_IsDeviceReady(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
  374. /******* Non-Blocking mode: Interrupt */
  375. HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
  376. HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
  377. HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size);
  378. HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size);
  379. HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
  380. HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_IT(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
  381. /******* Non-Blocking mode: DMA */
  382. HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
  383. HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
  384. HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size);
  385. HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint8_t *pData, uint16_t Size);
  386. HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
  387. HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_DMA(FMPI2C_HandleTypeDef *hFMPI2C, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
  388. /******* FMPI2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  389. void HAL_FMPI2C_EV_IRQHandler(FMPI2C_HandleTypeDef *hFMPI2C);
  390. void HAL_FMPI2C_ER_IRQHandler(FMPI2C_HandleTypeDef *hFMPI2C);
  391. void HAL_FMPI2C_MasterTxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  392. void HAL_FMPI2C_MasterRxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  393. void HAL_FMPI2C_SlaveTxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  394. void HAL_FMPI2C_SlaveRxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  395. void HAL_FMPI2C_MemTxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  396. void HAL_FMPI2C_MemRxCpltCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  397. void HAL_FMPI2C_ErrorCallback(FMPI2C_HandleTypeDef *hFMPI2C);
  398. /**
  399. * @}
  400. */
  401. /** @addtogroup FMPI2C_Exported_Functions_Group3
  402. * @{
  403. */
  404. /* Peripheral State functions ************************************************/
  405. HAL_FMPI2C_StateTypeDef HAL_FMPI2C_GetState(FMPI2C_HandleTypeDef *hFMPI2C);
  406. uint32_t HAL_FMPI2C_GetError(FMPI2C_HandleTypeDef *hFMPI2C);
  407. /**
  408. * @}
  409. */
  410. /**
  411. * @}
  412. */
  413. /* Private types -------------------------------------------------------------*/
  414. /* Private variables ---------------------------------------------------------*/
  415. /* Private constants ---------------------------------------------------------*/
  416. /** @defgroup FMPI2C_Private_Constants FMPI2C Private Constants
  417. * @{
  418. */
  419. #define FMPI2C_FLAG_MASK ((uint32_t)0x0001FFFF)
  420. /**
  421. * @}
  422. */
  423. /* Private macros ------------------------------------------------------------*/
  424. /** @defgroup FMPI2C_Private_Macros FMPI2C Private Macros
  425. * @{
  426. */
  427. #define IS_FMPI2C_ADDRESSING_MODE(MODE) (((MODE) == FMPI2C_ADDRESSINGMODE_7BIT) || \
  428. ((MODE) == FMPI2C_ADDRESSINGMODE_10BIT))
  429. #define IS_FMPI2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == FMPI2C_DUALADDRESS_DISABLE) || \
  430. ((ADDRESS) == FMPI2C_DUALADDRESS_ENABLE))
  431. #define IS_FMPI2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == FMPI2C_OA2_NOMASK) || \
  432. ((MASK) == FMPI2C_OA2_MASK01) || \
  433. ((MASK) == FMPI2C_OA2_MASK02) || \
  434. ((MASK) == FMPI2C_OA2_MASK03) || \
  435. ((MASK) == FMPI2C_OA2_MASK04) || \
  436. ((MASK) == FMPI2C_OA2_MASK05) || \
  437. ((MASK) == FMPI2C_OA2_MASK06) || \
  438. ((MASK) == FMPI2C_OA2_MASK07))
  439. #define IS_FMPI2C_GENERAL_CALL(CALL) (((CALL) == FMPI2C_GENERALCALL_DISABLE) || \
  440. ((CALL) == FMPI2C_GENERALCALL_ENABLE))
  441. #define IS_FMPI2C_NO_STRETCH(STRETCH) (((STRETCH) == FMPI2C_NOSTRETCH_DISABLE) || \
  442. ((STRETCH) == FMPI2C_NOSTRETCH_ENABLE))
  443. #define IS_FMPI2C_MEMADD_SIZE(SIZE) (((SIZE) == FMPI2C_MEMADD_SIZE_8BIT) || \
  444. ((SIZE) == FMPI2C_MEMADD_SIZE_16BIT))
  445. #define IS_TRANSFER_MODE(MODE) (((MODE) == FMPI2C_RELOAD_MODE) || \
  446. ((MODE) == FMPI2C_AUTOEND_MODE) || \
  447. ((MODE) == FMPI2C_SOFTEND_MODE))
  448. #define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == FMPI2C_GENERATE_STOP) || \
  449. ((REQUEST) == FMPI2C_GENERATE_START_READ) || \
  450. ((REQUEST) == FMPI2C_GENERATE_START_WRITE) || \
  451. ((REQUEST) == FMPI2C_NO_STARTSTOP))
  452. /**
  453. * @}
  454. */
  455. /* Private functions ---------------------------------------------------------*/
  456. /** @defgroup FMPI2C_Private_Functions FMPI2C Private Functions
  457. * @brief FMPI2C private functions
  458. * @{
  459. */
  460. /**
  461. * @}
  462. */
  463. /**
  464. * @}
  465. */
  466. /**
  467. * @}
  468. */
  469. #endif /* STM32F410xx || STM32F446xx */
  470. #ifdef __cplusplus
  471. }
  472. #endif
  473. #endif /* __STM32F4xx_HAL_FMPI2C_H */
  474. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/