stm32h7xx_hal_mdios.c 19 KB

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