stm32f7xx_hal_mdios.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_mdios.c
  4. * @author MCD Application Team
  5. * @brief MDIOS HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the MDIOS Peripheral.
  8. * + Initialization and de-initialization functions
  9. * + IO operation functions
  10. * + Peripheral Control functions
  11. *
  12. @verbatim
  13. ===============================================================================
  14. ##### How to use this driver #####
  15. ===============================================================================
  16. [..]
  17. The MDIOS HAL driver can be used as follows:
  18. (#) Declare a MDIOS_HandleTypeDef handle structure.
  19. (#) Initialize the MDIOS low level resources by implementing the HAL_MDIOS_MspInit() API:
  20. (##) Enable the MDIOS interface clock.
  21. (##) MDIOS pins configuration:
  22. (+++) Enable clocks for the MDIOS GPIOs.
  23. (+++) Configure the MDIOS pins as alternate function.
  24. (##) NVIC configuration if you need to use interrupt process:
  25. (+++) Configure the MDIOS interrupt priority.
  26. (+++) Enable the NVIC MDIOS IRQ handle.
  27. (#) Program the Port Address and the Preamble Check in the Init structure.
  28. (#) Initialize the MDIOS registers by calling the HAL_MDIOS_Init() API.
  29. (#) Perform direct slave read/write operations using the following APIs:
  30. (##) Read the value of a DINn register: HAL_MDIOS_ReadReg()
  31. (##) Write a value to a DOUTn register: HAL_MDIOS_WriteReg()
  32. (#) Get the Master read/write operations flags using the following APIs:
  33. (##) Bit map of DOUTn registers read by Master: HAL_MDIOS_GetReadRegAddress()
  34. (##) Bit map of DINn registers written by Master : HAL_MDIOS_GetWrittenRegAddress()
  35. (#) Clear the read/write flags using the following APIs:
  36. (##) Clear read flags of a set of registers: HAL_MDIOS_ClearReadRegAddress()
  37. (##) Clear write flags of a set of registers: HAL_MDIOS_ClearWriteRegAddress()
  38. (#) Enable interrupts on events using HAL_MDIOS_EnableEvents(), when called
  39. the MDIOS will generate an interrupt in the following cases:
  40. (##) a DINn register written by the Master
  41. (##) a DOUTn register read by the Master
  42. (##) an error occur
  43. -@@- A callback is executed for each genereted interrupt, so the driver provides the following
  44. HAL_MDIOS_WriteCpltCallback(), HAL_MDIOS_ReadCpltCallback() and HAL_MDIOS_ErrorCallback()
  45. -@@- HAL_MDIOS_IRQHandler() must be called from the MDIOS IRQ Handler, to handle the interrupt
  46. and execute the previous callbacks
  47. (#) Reset the MDIOS peripheral and all related ressources by calling the HAL_MDIOS_DeInit() API.
  48. (##) HAL_MDIOS_MspDeInit() must be implemented to reset low level ressources
  49. (GPIO, Clocks, NVIC configuration ...)
  50. @endverbatim
  51. ******************************************************************************
  52. * @attention
  53. *
  54. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  55. *
  56. * Redistribution and use in source and binary forms, with or without modification,
  57. * are permitted provided that the following conditions are met:
  58. * 1. Redistributions of source code must retain the above copyright notice,
  59. * this list of conditions and the following disclaimer.
  60. * 2. Redistributions in binary form must reproduce the above copyright notice,
  61. * this list of conditions and the following disclaimer in the documentation
  62. * and/or other materials provided with the distribution.
  63. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  64. * may be used to endorse or promote products derived from this software
  65. * without specific prior written permission.
  66. *
  67. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  68. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  69. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  70. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  71. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  72. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  73. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  74. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  75. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  76. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  77. *
  78. ******************************************************************************
  79. */
  80. /* Includes ------------------------------------------------------------------*/
  81. #include "stm32f7xx_hal.h"
  82. /** @addtogroup STM32F7xx_HAL_Driver
  83. * @{
  84. */
  85. /** @defgroup MDIOS MDIOS
  86. * @brief HAL MDIOS module driver
  87. * @{
  88. */
  89. #ifdef HAL_MDIOS_MODULE_ENABLED
  90. #if defined (MDIOS)
  91. /* Private typedef -----------------------------------------------------------*/
  92. /* Private define ------------------------------------------------------------*/
  93. #define MDIOS_PORT_ADDRESS_SHIFT ((uint32_t)8)
  94. #define MDIOS_ALL_REG_FLAG ((uint32_t)0xFFFFFFFFU)
  95. #define MDIOS_ALL_ERRORS_FLAG ((uint32_t)(MDIOS_SR_PERF | MDIOS_SR_SERF | MDIOS_SR_TERF))
  96. #define MDIOS_DIN_BASE_ADDR (MDIOS_BASE + 0x100)
  97. #define MDIOS_DOUT_BASE_ADDR (MDIOS_BASE + 0x180)
  98. /* Private macro -------------------------------------------------------------*/
  99. /* Private variables ---------------------------------------------------------*/
  100. /* Private function prototypes -----------------------------------------------*/
  101. /* Private functions ---------------------------------------------------------*/
  102. /* Exported functions --------------------------------------------------------*/
  103. /** @defgroup MDIOS_Exported_Functions MDIOS Exported Functions
  104. * @{
  105. */
  106. /** @defgroup MDIOS_Exported_Functions_Group1 Initialization/de-initialization functions
  107. * @brief Initialization and Configuration functions
  108. *
  109. @verbatim
  110. ===============================================================================
  111. ##### Initialization and Configuration functions #####
  112. ===============================================================================
  113. [..]
  114. This subsection provides a set of functions allowing to initialize the MDIOS
  115. (+) The following parameters can be configured:
  116. (++) Port Address
  117. (++) Preamble Check
  118. @endverbatim
  119. * @{
  120. */
  121. /**
  122. * @brief Initializes the MDIOS according to the specified parameters in
  123. * the MDIOS_InitTypeDef and creates the associated handle .
  124. * @param hmdios pointer to a MDIOS_HandleTypeDef structure that contains
  125. * the configuration information for MDIOS module
  126. * @retval HAL status
  127. */
  128. HAL_StatusTypeDef HAL_MDIOS_Init(MDIOS_HandleTypeDef *hmdios)
  129. {
  130. uint32_t tmpcr = 0;
  131. /* Check the MDIOS handle allocation */
  132. if(hmdios == NULL)
  133. {
  134. return HAL_ERROR;
  135. }
  136. /* Check the parameters */
  137. assert_param(IS_MDIOS_ALL_INSTANCE(hmdios->Instance));
  138. assert_param(IS_MDIOS_PORTADDRESS(hmdios->Init.PortAddress));
  139. assert_param(IS_MDIOS_PREAMBLECHECK(hmdios->Init.PreambleCheck));
  140. /* Process Locked */
  141. __HAL_LOCK(hmdios);
  142. if(hmdios->State == HAL_MDIOS_STATE_RESET)
  143. {
  144. /* Init the low level hardware */
  145. HAL_MDIOS_MspInit(hmdios);
  146. }
  147. /* Change the MDIOS state */
  148. hmdios->State = HAL_MDIOS_STATE_BUSY;
  149. /* Get the MDIOS CR value */
  150. tmpcr = hmdios->Instance->CR;
  151. /* Clear PORT_ADDRESS, DPC and EN bits */
  152. tmpcr &= ((uint32_t)~(MDIOS_CR_EN | MDIOS_CR_DPC | MDIOS_CR_PORT_ADDRESS));
  153. /* Set MDIOS control parametrs and enable the peripheral */
  154. tmpcr |= (uint32_t)(((hmdios->Init.PortAddress) << MDIOS_PORT_ADDRESS_SHIFT) |\
  155. (hmdios->Init.PreambleCheck) | \
  156. (MDIOS_CR_EN));
  157. /* Write the MDIOS CR */
  158. hmdios->Instance->CR = tmpcr;
  159. /* Change the MDIOS state */
  160. hmdios->State = HAL_MDIOS_STATE_READY;
  161. /* Release Lock */
  162. __HAL_UNLOCK(hmdios);
  163. /* Return function status */
  164. return HAL_OK;
  165. }
  166. /**
  167. * @brief DeInitializes the MDIOS peripheral.
  168. * @param hmdios MDIOS handle
  169. * @retval HAL status
  170. */
  171. HAL_StatusTypeDef HAL_MDIOS_DeInit(MDIOS_HandleTypeDef *hmdios)
  172. {
  173. /* Check the MDIOS handle allocation */
  174. if(hmdios == NULL)
  175. {
  176. return HAL_ERROR;
  177. }
  178. /* Check the parameters */
  179. assert_param(IS_MDIOS_ALL_INSTANCE(hmdios->Instance));
  180. /* Change the MDIOS state */
  181. hmdios->State = HAL_MDIOS_STATE_BUSY;
  182. /* Disable the Peripheral */
  183. __HAL_MDIOS_DISABLE(hmdios);
  184. /* DeInit the low level hardware */
  185. HAL_MDIOS_MspDeInit(hmdios);
  186. /* Change the MDIOS state */
  187. hmdios->State = HAL_MDIOS_STATE_RESET;
  188. /* Release Lock */
  189. __HAL_UNLOCK(hmdios);
  190. /* Return function status */
  191. return HAL_OK;
  192. }
  193. /**
  194. * @brief MDIOS MSP Init
  195. * @param hmdios mdios handle
  196. * @retval None
  197. */
  198. __weak void HAL_MDIOS_MspInit(MDIOS_HandleTypeDef *hmdios)
  199. {
  200. /* Prevent unused argument(s) compilation warning */
  201. UNUSED(hmdios);
  202. /* NOTE : This function should not be modified, when the callback is needed,
  203. the HAL_MDIOS_MspInit can be implemented in the user file
  204. */
  205. }
  206. /**
  207. * @brief MDIOS MSP DeInit
  208. * @param hmdios mdios handle
  209. * @retval None
  210. */
  211. __weak void HAL_MDIOS_MspDeInit(MDIOS_HandleTypeDef *hmdios)
  212. {
  213. /* Prevent unused argument(s) compilation warning */
  214. UNUSED(hmdios);
  215. /* NOTE : This function should not be modified, when the callback is needed,
  216. the HAL_MDIOS_MspDeInit can be implemented in the user file
  217. */
  218. }
  219. /**
  220. * @}
  221. */
  222. /** @defgroup MDIOS_Exported_Functions_Group2 IO operation functions
  223. * @brief MDIOS Read/Write functions
  224. *
  225. @verbatim
  226. ===============================================================================
  227. ##### IO operation functions #####
  228. ===============================================================================
  229. This subsection provides a set of functions allowing to manage the MDIOS
  230. read and write operations.
  231. (#) APIs that allow to the MDIOS to read/write from/to the
  232. values of one of the DINn/DOUTn registers:
  233. (+) Read the value of a DINn register: HAL_MDIOS_ReadReg()
  234. (+) Write a value to a DOUTn register: HAL_MDIOS_WriteReg()
  235. (#) APIs that provide if there are some Slave registres have been
  236. read or written by the Master:
  237. (+) DOUTn registers read by Master: HAL_MDIOS_GetReadRegAddress()
  238. (+) DINn registers written by Master : HAL_MDIOS_GetWrittenRegAddress()
  239. (#) APIs that Clear the read/write flags:
  240. (+) Clear read registers flags: HAL_MDIOS_ClearReadRegAddress()
  241. (+) Clear write registers flags: HAL_MDIOS_ClearWriteRegAddress()
  242. (#) A set of Callbacks are provided:
  243. (+) HAL_MDIOS_WriteCpltCallback()
  244. (+) HAL_MDIOS_ReadCpltCallback()
  245. (+) HAL_MDIOS_ErrorCallback()
  246. @endverbatim
  247. * @{
  248. */
  249. /**
  250. * @brief Writes to an MDIOS output register
  251. * @param hmdios mdios handle
  252. * @param RegNum MDIOS input register number
  253. * @param Data Data to write
  254. * @retval HAL status
  255. */
  256. HAL_StatusTypeDef HAL_MDIOS_WriteReg(MDIOS_HandleTypeDef *hmdios, uint32_t RegNum, uint16_t Data)
  257. {
  258. uint32_t tmpreg;
  259. /* Check the parameters */
  260. assert_param(IS_MDIOS_REGISTER(RegNum));
  261. /* Process Locked */
  262. __HAL_LOCK(hmdios);
  263. /* Get the addr of output register to be written by the MDIOS */
  264. tmpreg = MDIOS_DOUT_BASE_ADDR + (4 * RegNum);
  265. /* Write to DOUTn register */
  266. *((uint32_t *)tmpreg) = Data;
  267. /* Process Unlocked */
  268. __HAL_UNLOCK(hmdios);
  269. return HAL_OK;
  270. }
  271. /**
  272. * @brief Reads an MDIOS input register
  273. * @param hmdios mdios handle
  274. * @param RegNum MDIOS input register number
  275. * @param pData pointer to Data
  276. * @retval HAL status
  277. */
  278. HAL_StatusTypeDef HAL_MDIOS_ReadReg(MDIOS_HandleTypeDef *hmdios, uint32_t RegNum, uint16_t *pData)
  279. {
  280. uint32_t tmpreg;
  281. /* Check the parameters */
  282. assert_param(IS_MDIOS_REGISTER(RegNum));
  283. /* Process Locked */
  284. __HAL_LOCK(hmdios);
  285. /* Get the addr of input register to be read by the MDIOS */
  286. tmpreg = MDIOS_DIN_BASE_ADDR + (4 * RegNum);
  287. /* Read DINn register */
  288. *pData = (uint16_t)(*((uint32_t *)tmpreg));
  289. /* Process Unlocked */
  290. __HAL_UNLOCK(hmdios);
  291. return HAL_OK;
  292. }
  293. /**
  294. * @brief Gets Written registers by MDIO master
  295. * @param hmdios mdios handle
  296. * @retval bit map of written registers addresses
  297. */
  298. uint32_t HAL_MDIOS_GetWrittenRegAddress(MDIOS_HandleTypeDef *hmdios)
  299. {
  300. return hmdios->Instance->WRFR;
  301. }
  302. /**
  303. * @brief Gets Read registers by MDIO master
  304. * @param hmdios mdios handle
  305. * @retval bit map of read registers addresses
  306. */
  307. uint32_t HAL_MDIOS_GetReadRegAddress(MDIOS_HandleTypeDef *hmdios)
  308. {
  309. return hmdios->Instance->RDFR;
  310. }
  311. /**
  312. * @brief Clears Write registers flag
  313. * @param hmdios mdios handle
  314. * @param RegNum registers addresses to be cleared
  315. * @retval HAL status
  316. */
  317. HAL_StatusTypeDef HAL_MDIOS_ClearWriteRegAddress(MDIOS_HandleTypeDef *hmdios, uint32_t RegNum)
  318. {
  319. /* Check the parameters */
  320. assert_param(IS_MDIOS_REGISTER(RegNum));
  321. /* Process Locked */
  322. __HAL_LOCK(hmdios);
  323. /* Clear write registers flags */
  324. hmdios->Instance->CWRFR |= (RegNum);
  325. /* Release Lock */
  326. __HAL_UNLOCK(hmdios);
  327. return HAL_OK;
  328. }
  329. /**
  330. * @brief Clears Read register flag
  331. * @param hmdios mdios handle
  332. * @param RegNum registers addresses to be cleared
  333. * @retval HAL status
  334. */
  335. HAL_StatusTypeDef HAL_MDIOS_ClearReadRegAddress(MDIOS_HandleTypeDef *hmdios, uint32_t RegNum)
  336. {
  337. /* Check the parameters */
  338. assert_param(IS_MDIOS_REGISTER(RegNum));
  339. /* Process Locked */
  340. __HAL_LOCK(hmdios);
  341. /* Clear read registers flags */
  342. hmdios->Instance->CRDFR |= (RegNum);
  343. /* Release Lock */
  344. __HAL_UNLOCK(hmdios);
  345. return HAL_OK;
  346. }
  347. /**
  348. * @brief Enables Events for MDIOS peripheral
  349. * @param hmdios mdios handle
  350. * @retval HAL status
  351. */
  352. HAL_StatusTypeDef HAL_MDIOS_EnableEvents(MDIOS_HandleTypeDef *hmdios)
  353. {
  354. /* Process Locked */
  355. __HAL_LOCK(hmdios);
  356. /* Enable MDIOS interrupts: Register Write, Register Read and Error ITs */
  357. __HAL_MDIOS_ENABLE_IT(hmdios, (MDIOS_IT_WRITE | MDIOS_IT_READ | MDIOS_IT_ERROR));
  358. /* Process Unlocked */
  359. __HAL_UNLOCK(hmdios);
  360. return HAL_OK;
  361. }
  362. /**
  363. * @brief This function handles MDIOS interrupt request.
  364. * @param hmdios MDIOS handle
  365. * @retval None
  366. */
  367. void HAL_MDIOS_IRQHandler(MDIOS_HandleTypeDef *hmdios)
  368. {
  369. /* Write Register Interrupt enabled ? */
  370. if(__HAL_MDIOS_GET_IT_SOURCE(hmdios, MDIOS_IT_WRITE) != RESET)
  371. {
  372. /* Write register flag */
  373. if(HAL_MDIOS_GetWrittenRegAddress(hmdios) != RESET)
  374. {
  375. /* Write callback function */
  376. HAL_MDIOS_WriteCpltCallback(hmdios);
  377. /* Clear write register flag */
  378. HAL_MDIOS_ClearWriteRegAddress(hmdios, MDIOS_ALL_REG_FLAG);
  379. }
  380. }
  381. /* Read Register Interrupt enabled ? */
  382. if(__HAL_MDIOS_GET_IT_SOURCE(hmdios, MDIOS_IT_READ) != RESET)
  383. {
  384. /* Read register flag */
  385. if(HAL_MDIOS_GetReadRegAddress(hmdios) != RESET)
  386. {
  387. /* Read callback function */
  388. HAL_MDIOS_ReadCpltCallback(hmdios);
  389. /* Clear read register flag */
  390. HAL_MDIOS_ClearReadRegAddress(hmdios, MDIOS_ALL_REG_FLAG);
  391. }
  392. }
  393. /* Error Interrupt enabled ? */
  394. if(__HAL_MDIOS_GET_IT_SOURCE(hmdios, MDIOS_IT_ERROR) != RESET)
  395. {
  396. /* All Errors Flag */
  397. if(__HAL_MDIOS_GET_ERROR_FLAG(hmdios, MDIOS_ALL_ERRORS_FLAG) !=RESET)
  398. {
  399. /* Error Callback */
  400. HAL_MDIOS_ErrorCallback(hmdios);
  401. /* Clear errors flag */
  402. __HAL_MDIOS_CLEAR_ERROR_FLAG(hmdios, MDIOS_ALL_ERRORS_FLAG);
  403. }
  404. }
  405. /* check MDIOS WAKEUP exti flag */
  406. if(__HAL_MDIOS_WAKEUP_EXTI_GET_FLAG() != RESET)
  407. {
  408. /* MDIOS WAKEUP interrupt user callback */
  409. HAL_MDIOS_WakeUpCallback(hmdios);
  410. /* Clear MDIOS WAKEUP Exti pending bit */
  411. __HAL_MDIOS_WAKEUP_EXTI_CLEAR_FLAG();
  412. }
  413. }
  414. /**
  415. * @brief Write Complete Callback
  416. * @param hmdios mdios handle
  417. * @retval None
  418. */
  419. __weak void HAL_MDIOS_WriteCpltCallback(MDIOS_HandleTypeDef *hmdios)
  420. {
  421. /* Prevent unused argument(s) compilation warning */
  422. UNUSED(hmdios);
  423. /* NOTE : This function should not be modified, when the callback is needed,
  424. the HAL_MDIOS_WriteCpltCallback can be implemented in the user file
  425. */
  426. }
  427. /**
  428. * @brief Read Complete Callback
  429. * @param hmdios mdios handle
  430. * @retval None
  431. */
  432. __weak void HAL_MDIOS_ReadCpltCallback(MDIOS_HandleTypeDef *hmdios)
  433. {
  434. /* Prevent unused argument(s) compilation warning */
  435. UNUSED(hmdios);
  436. /* NOTE : This function should not be modified, when the callback is needed,
  437. the HAL_MDIOS_ReadCpltCallback can be implemented in the user file
  438. */
  439. }
  440. /**
  441. * @brief Error Callback
  442. * @param hmdios mdios handle
  443. * @retval None
  444. */
  445. __weak void HAL_MDIOS_ErrorCallback(MDIOS_HandleTypeDef *hmdios)
  446. {
  447. /* Prevent unused argument(s) compilation warning */
  448. UNUSED(hmdios);
  449. /* NOTE : This function should not be modified, when the callback is needed,
  450. the HAL_MDIOS_ErrorCallback can be implemented in the user file
  451. */
  452. }
  453. /**
  454. * @brief MDIOS WAKEUP interrupt callback
  455. * @param hmdios mdios handle
  456. * @retval None
  457. */
  458. __weak void HAL_MDIOS_WakeUpCallback(MDIOS_HandleTypeDef *hmdios)
  459. {
  460. /* Prevent unused argument(s) compilation warning */
  461. UNUSED(hmdios);
  462. /* NOTE : This function Should not be modified, when the callback is needed,
  463. the HAL_MDIOS_WakeUpCallback could be implemented in the user file
  464. */
  465. }
  466. /**
  467. * @}
  468. */
  469. /** @defgroup MDIOS_Exported_Functions_Group3 Peripheral Control functions
  470. * @brief MDIOS control functions
  471. *
  472. @verbatim
  473. ===============================================================================
  474. ##### Peripheral Control functions #####
  475. ===============================================================================
  476. [..]
  477. This subsection provides a set of functions allowing to control the MDIOS.
  478. (+) HAL_MDIOS_GetState() API, helpful to check in run-time the state.
  479. (+) HAL_MDIOS_GetError() API, returns the errors occured during data transfer.
  480. @endverbatim
  481. * @{
  482. */
  483. /**
  484. * @brief Gets MDIOS error flags
  485. * @param hmdios mdios handle
  486. * @retval bit map of occured errors
  487. */
  488. uint32_t HAL_MDIOS_GetError(MDIOS_HandleTypeDef *hmdios)
  489. {
  490. /* return errors flags on status register */
  491. return hmdios->Instance->SR;
  492. }
  493. /**
  494. * @brief Return the MDIOS HAL state
  495. * @param hmdios mdios handle
  496. * @retval MDIOS state
  497. */
  498. HAL_MDIOS_StateTypeDef HAL_MDIOS_GetState(MDIOS_HandleTypeDef *hmdios)
  499. {
  500. /* Return MDIOS state */
  501. return hmdios->State;
  502. }
  503. /**
  504. * @}
  505. */
  506. /**
  507. * @}
  508. */
  509. #endif /* MDIOS */
  510. #endif /* HAL_MDIOS_MODULE_ENABLED */
  511. /**
  512. * @}
  513. */
  514. /**
  515. * @}
  516. */
  517. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/