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
13 ===============================================================================
14 ##### How to use this driver #####
15 ===============================================================================
17 The MDIOS HAL driver can be used as follows:
19 (#) Declare a MDIOS_HandleTypeDef handle structure.
21 (#) Initialize the MDIOS low level resources by implementing the HAL_MDIOS_MspInit() API:
22 (##) Enable the MDIOS interface clock.
23 (##) MDIOS pins configuration:
24 (+++) Enable clocks for the MDIOS GPIOs.
25 (+++) Configure the MDIOS pins as alternate function.
26 (##) NVIC configuration if you need to use interrupt process:
27 (+++) Configure the MDIOS interrupt priority.
28 (+++) Enable the NVIC MDIOS IRQ handle.
30 (#) Program the Port Address and the Preamble Check in the Init structure.
32 (#) Initialize the MDIOS registers by calling the HAL_MDIOS_Init() API.
34 (#) Perform direct slave read/write operations using the following APIs:
35 (##) Read the value of a DINn register: HAL_MDIOS_ReadReg()
36 (##) Write a value to a DOUTn register: HAL_MDIOS_WriteReg()
38 (#) Get the Master read/write operations flags using the following APIs:
39 (##) Bit map of DOUTn registers read by Master: HAL_MDIOS_GetReadRegAddress()
40 (##) Bit map of DINn registers written by Master : HAL_MDIOS_GetWrittenRegAddress()
42 (#) Clear the read/write flags using the following APIs:
43 (##) Clear read flags of a set of registers: HAL_MDIOS_ClearReadRegAddress()
44 (##) Clear write flags of a set of registers: HAL_MDIOS_ClearWriteRegAddress()
46 (#) Enable interrupts on events using HAL_MDIOS_EnableEvents(), when called
47 the MDIOS will generate an interrupt in the following cases:
48 (##) a DINn register written by the Master
49 (##) a DOUTn register read by the Master
52 -@@- A callback is executed for each genereted interrupt, so the driver provides the following
53 HAL_MDIOS_WriteCpltCallback(), HAL_MDIOS_ReadCpltCallback() and HAL_MDIOS_ErrorCallback()
54 -@@- HAL_MDIOS_IRQHandler() must be called from the MDIOS IRQ Handler, to handle the interrupt
55 and execute the previous callbacks
57 (#) Reset the MDIOS peripheral and all related ressources by calling the HAL_MDIOS_DeInit() API.
58 (##) HAL_MDIOS_MspDeInit() must be implemented to reset low level ressources
59 (GPIO, Clocks, NVIC configuration ...)
61 *** Callback registration ***
62 =============================================
64 The compilation define USE_HAL_MDIOS_REGISTER_CALLBACKS when set to 1
65 allows the user to configure dynamically the driver callbacks.
66 Use Function @ref HAL_MDIOS_RegisterCallback() to register an interrupt callback.
68 Function @ref HAL_MDIOS_RegisterCallback() allows to register following callbacks:
69 (+) WriteCpltCallback : Write Complete Callback.
70 (+) ReadCpltCallback : Read Complete Callback.
71 (+) ErrorCallback : Error Callback.
72 (+) WakeUpCallback : Wake UP Callback
73 (+) MspInitCallback : MspInit Callback.
74 (+) MspDeInitCallback : MspDeInit Callback.
76 This function takes as parameters the HAL peripheral handle, the Callback ID
77 and a pointer to the user callback function.
79 Use function @ref HAL_MDIOS_UnRegisterCallback() to reset a callback to the default
81 @ref HAL_MDIOS_UnRegisterCallback takes as parameters the HAL peripheral handle,
83 This function allows to reset following callbacks:
84 (+) WriteCpltCallback : Write Complete Callback.
85 (+) ReadCpltCallback : Read Complete Callback.
86 (+) ErrorCallback : Error Callback.
87 (+) WakeUpCallback : Wake UP Callback
88 (+) MspInitCallback : MspInit Callback.
89 (+) MspDeInitCallback : MspDeInit Callback.
91 By default, after the HAL_MDIOS_Init and when the state is HAL_MDIOS_STATE_RESET
92 all callbacks are set to the corresponding weak functions:
93 examples @ref HAL_MDIOS_WriteCpltCallback(), @ref HAL_MDIOS_ReadCpltCallback().
94 Exception done for MspInit and MspDeInit functions that are
95 reset to the legacy weak function in the HAL_MDIOS_Init/ @ref HAL_MDIOS_DeInit only when
96 these callbacks are null (not registered beforehand).
97 if not, MspInit or MspDeInit are not null, the HAL_MDIOS_Init/ @ref HAL_MDIOS_DeInit
98 keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
100 Callbacks can be registered/unregistered in HAL_MDIOS_STATE_READY state only.
101 Exception done MspInit/MspDeInit that can be registered/unregistered
102 in HAL_MDIOS_STATE_READY or HAL_MDIOS_STATE_RESET state,
103 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
104 In that case first register the MspInit/MspDeInit user callbacks
105 using @ref HAL_MDIOS_RegisterCallback() before calling @ref HAL_MDIOS_DeInit
106 or HAL_MDIOS_Init function.
108 When The compilation define USE_HAL_MDIOS_REGISTER_CALLBACKS is set to 0 or
109 not defined, the callback registration feature is not available and all callbacks
110 are set to the corresponding weak functions.
114 ******************************************************************************
117 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
118 * All rights reserved.</center></h2>
120 * This software component is licensed by ST under BSD 3-Clause license,
121 * the "License"; You may not use this file except in compliance with the
122 * License. You may obtain a copy of the License at:
123 * opensource.org/licenses/BSD-3-Clause
125 ******************************************************************************
128 /* Includes ------------------------------------------------------------------*/
129 #include "stm32f7xx_hal.h"
131 /** @addtogroup STM32F7xx_HAL_Driver
135 /** @defgroup MDIOS MDIOS
136 * @brief HAL MDIOS module driver
139 #ifdef HAL_MDIOS_MODULE_ENABLED
143 /* Private typedef -----------------------------------------------------------*/
144 /* Private define ------------------------------------------------------------*/
145 #define MDIOS_PORT_ADDRESS_SHIFT ((uint32_t)8)
146 #define MDIOS_ALL_REG_FLAG ((uint32_t)0xFFFFFFFFU)
147 #define MDIOS_ALL_ERRORS_FLAG ((uint32_t)(MDIOS_SR_PERF | MDIOS_SR_SERF | MDIOS_SR_TERF))
149 #define MDIOS_DIN_BASE_ADDR (MDIOS_BASE + 0x100)
150 #define MDIOS_DOUT_BASE_ADDR (MDIOS_BASE + 0x180)
152 /* Private macro -------------------------------------------------------------*/
153 /* Private variables ---------------------------------------------------------*/
154 /* Private function prototypes -----------------------------------------------*/
155 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
156 static void MDIOS_InitCallbacksToDefault(MDIOS_HandleTypeDef
*hmdios
);
157 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
158 /* Private functions ---------------------------------------------------------*/
159 /* Exported functions --------------------------------------------------------*/
160 /** @defgroup MDIOS_Exported_Functions MDIOS Exported Functions
164 /** @defgroup MDIOS_Exported_Functions_Group1 Initialization/de-initialization functions
165 * @brief Initialization and Configuration functions
168 ===============================================================================
169 ##### Initialization and Configuration functions #####
170 ===============================================================================
172 This subsection provides a set of functions allowing to initialize the MDIOS
173 (+) The following parameters can be configured:
182 * @brief Initializes the MDIOS according to the specified parameters in
183 * the MDIOS_InitTypeDef and creates the associated handle .
184 * @param hmdios pointer to a MDIOS_HandleTypeDef structure that contains
185 * the configuration information for MDIOS module
188 HAL_StatusTypeDef
HAL_MDIOS_Init(MDIOS_HandleTypeDef
*hmdios
)
192 /* Check the MDIOS handle allocation */
198 /* Check the parameters */
199 assert_param(IS_MDIOS_ALL_INSTANCE(hmdios
->Instance
));
200 assert_param(IS_MDIOS_PORTADDRESS(hmdios
->Init
.PortAddress
));
201 assert_param(IS_MDIOS_PREAMBLECHECK(hmdios
->Init
.PreambleCheck
));
206 if(hmdios
->State
== HAL_MDIOS_STATE_RESET
)
208 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
210 MDIOS_InitCallbacksToDefault(hmdios
);
212 if(hmdios
->MspInitCallback
== NULL
)
214 hmdios
->MspInitCallback
= HAL_MDIOS_MspInit
;
217 /* Init the low level hardware */
218 hmdios
->MspInitCallback(hmdios
);
221 /* Init the low level hardware */
222 HAL_MDIOS_MspInit(hmdios
);
224 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
227 /* Change the MDIOS state */
228 hmdios
->State
= HAL_MDIOS_STATE_BUSY
;
230 /* Get the MDIOS CR value */
231 tmpcr
= hmdios
->Instance
->CR
;
233 /* Clear PORT_ADDRESS, DPC and EN bits */
234 tmpcr
&= ((uint32_t)~(MDIOS_CR_EN
| MDIOS_CR_DPC
| MDIOS_CR_PORT_ADDRESS
));
236 /* Set MDIOS control parametrs and enable the peripheral */
237 tmpcr
|= (uint32_t)(((hmdios
->Init
.PortAddress
) << MDIOS_PORT_ADDRESS_SHIFT
) |\
238 (hmdios
->Init
.PreambleCheck
) | \
241 /* Write the MDIOS CR */
242 hmdios
->Instance
->CR
= tmpcr
;
244 /* Change the MDIOS state */
245 hmdios
->State
= HAL_MDIOS_STATE_READY
;
248 __HAL_UNLOCK(hmdios
);
250 /* Return function status */
256 * @brief DeInitializes the MDIOS peripheral.
257 * @param hmdios MDIOS handle
260 HAL_StatusTypeDef
HAL_MDIOS_DeInit(MDIOS_HandleTypeDef
*hmdios
)
262 /* Check the MDIOS handle allocation */
268 /* Check the parameters */
269 assert_param(IS_MDIOS_ALL_INSTANCE(hmdios
->Instance
));
271 /* Change the MDIOS state */
272 hmdios
->State
= HAL_MDIOS_STATE_BUSY
;
274 /* Disable the Peripheral */
275 __HAL_MDIOS_DISABLE(hmdios
);
277 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
279 if(hmdios
->MspDeInitCallback
== NULL
)
281 hmdios
->MspDeInitCallback
= HAL_MDIOS_MspDeInit
;
283 /* DeInit the low level hardware */
284 hmdios
->MspDeInitCallback(hmdios
);
288 /* DeInit the low level hardware */
289 HAL_MDIOS_MspDeInit(hmdios
);
291 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
293 /* Change the MDIOS state */
294 hmdios
->State
= HAL_MDIOS_STATE_RESET
;
297 __HAL_UNLOCK(hmdios
);
299 /* Return function status */
304 * @brief MDIOS MSP Init
305 * @param hmdios mdios handle
308 __weak
void HAL_MDIOS_MspInit(MDIOS_HandleTypeDef
*hmdios
)
310 /* Prevent unused argument(s) compilation warning */
313 /* NOTE : This function should not be modified, when the callback is needed,
314 the HAL_MDIOS_MspInit can be implemented in the user file
319 * @brief MDIOS MSP DeInit
320 * @param hmdios mdios handle
323 __weak
void HAL_MDIOS_MspDeInit(MDIOS_HandleTypeDef
*hmdios
)
325 /* Prevent unused argument(s) compilation warning */
328 /* NOTE : This function should not be modified, when the callback is needed,
329 the HAL_MDIOS_MspDeInit can be implemented in the user file
333 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
335 * @brief Register a User MDIOS Callback
336 * To be used instead of the weak predefined callback
337 * @param hmdios mdios handle
338 * @param CallbackID ID of the callback to be registered
339 * This parameter can be one of the following values:
340 * @arg @ref HAL_MDIOS_WRITE_COMPLETE_CB_ID Write Complete Callback ID
341 * @arg @ref HAL_MDIOS_READ_COMPLETE_CB_ID Read Complete Callback ID
342 * @arg @ref HAL_MDIOS_ERROR_CB_ID Error Callback ID
343 * @arg @ref HAL_MDIOS_WAKEUP_CB_ID Wake Up Callback ID
344 * @arg @ref HAL_MDIOS_MSPINIT_CB_ID MspInit callback ID
345 * @arg @ref HAL_MDIOS_MSPDEINIT_CB_ID MspDeInit callback ID
346 * @param pCallback pointer to the Callback function
349 HAL_StatusTypeDef
HAL_MDIOS_RegisterCallback(MDIOS_HandleTypeDef
*hmdios
, HAL_MDIOS_CallbackIDTypeDef CallbackID
, pMDIOS_CallbackTypeDef pCallback
)
351 HAL_StatusTypeDef status
= HAL_OK
;
353 if(pCallback
== NULL
)
355 /* Return error status */
361 if(hmdios
->State
== HAL_MDIOS_STATE_READY
)
365 case HAL_MDIOS_WRITE_COMPLETE_CB_ID
:
366 hmdios
->WriteCpltCallback
= pCallback
;
369 case HAL_MDIOS_READ_COMPLETE_CB_ID
:
370 hmdios
->ReadCpltCallback
= pCallback
;
373 case HAL_MDIOS_ERROR_CB_ID
:
374 hmdios
->ErrorCallback
= pCallback
;
377 case HAL_MDIOS_WAKEUP_CB_ID
:
378 hmdios
->WakeUpCallback
= pCallback
;
381 case HAL_MDIOS_MSPINIT_CB_ID
:
382 hmdios
->MspInitCallback
= pCallback
;
385 case HAL_MDIOS_MSPDEINIT_CB_ID
:
386 hmdios
->MspDeInitCallback
= pCallback
;
390 /* Return error status */
395 else if(hmdios
->State
== HAL_MDIOS_STATE_RESET
)
399 case HAL_MDIOS_MSPINIT_CB_ID
:
400 hmdios
->MspInitCallback
= pCallback
;
403 case HAL_MDIOS_MSPDEINIT_CB_ID
:
404 hmdios
->MspDeInitCallback
= pCallback
;
408 /* Return error status */
415 /* Return error status */
420 __HAL_UNLOCK(hmdios
);
426 * @brief Unregister an MDIOS Callback
427 * MDIOS callabck is redirected to the weak predefined callback
428 * @param hmdios mdios handle
429 * @param CallbackID ID of the callback to be unregistered
430 * This parameter can be one of the following values:
431 * @arg @ref HAL_MDIOS_WRITE_COMPLETE_CB_ID Write Complete Callback ID
432 * @arg @ref HAL_MDIOS_READ_COMPLETE_CB_ID Read Complete Callback ID
433 * @arg @ref HAL_MDIOS_ERROR_CB_ID Error Callback ID
434 * @arg @ref HAL_MDIOS_WAKEUP_CB_ID Wake Up Callback ID
435 * @arg @ref HAL_MDIOS_MSPINIT_CB_ID MspInit callback ID
436 * @arg @ref HAL_MDIOS_MSPDEINIT_CB_ID MspDeInit callback ID
439 HAL_StatusTypeDef
HAL_MDIOS_UnRegisterCallback(MDIOS_HandleTypeDef
*hmdios
, HAL_MDIOS_CallbackIDTypeDef CallbackID
)
441 HAL_StatusTypeDef status
= HAL_OK
;
446 if(hmdios
->State
== HAL_MDIOS_STATE_READY
)
450 case HAL_MDIOS_WRITE_COMPLETE_CB_ID
:
451 hmdios
->WriteCpltCallback
= HAL_MDIOS_WriteCpltCallback
;
454 case HAL_MDIOS_READ_COMPLETE_CB_ID
:
455 hmdios
->ReadCpltCallback
= HAL_MDIOS_ReadCpltCallback
;
458 case HAL_MDIOS_ERROR_CB_ID
:
459 hmdios
->ErrorCallback
= HAL_MDIOS_ErrorCallback
;
462 case HAL_MDIOS_WAKEUP_CB_ID
:
463 hmdios
->WakeUpCallback
= HAL_MDIOS_WakeUpCallback
;
466 case HAL_MDIOS_MSPINIT_CB_ID
:
467 hmdios
->MspInitCallback
= HAL_MDIOS_MspInit
;
470 case HAL_MDIOS_MSPDEINIT_CB_ID
:
471 hmdios
->MspDeInitCallback
= HAL_MDIOS_MspDeInit
;
475 /* Return error status */
480 else if(hmdios
->State
== HAL_MDIOS_STATE_RESET
)
484 case HAL_MDIOS_MSPINIT_CB_ID
:
485 hmdios
->MspInitCallback
= HAL_MDIOS_MspInit
;
488 case HAL_MDIOS_MSPDEINIT_CB_ID
:
489 hmdios
->MspDeInitCallback
= HAL_MDIOS_MspDeInit
;
493 /* Return error status */
500 /* Return error status */
505 __HAL_UNLOCK(hmdios
);
510 static void MDIOS_InitCallbacksToDefault(MDIOS_HandleTypeDef
*hmdios
)
512 /* Init the MDIOS Callback settings */
513 hmdios
->WriteCpltCallback
= HAL_MDIOS_WriteCpltCallback
; /* Legacy weak WriteCpltCallback */
514 hmdios
->ReadCpltCallback
= HAL_MDIOS_ReadCpltCallback
; /* Legacy weak ReadCpltCallback */
515 hmdios
->ErrorCallback
= HAL_MDIOS_ErrorCallback
; /* Legacy weak ErrorCallback */
516 hmdios
->WakeUpCallback
= HAL_MDIOS_WakeUpCallback
; /* Legacy weak WakeUpCallback */
518 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
524 /** @defgroup MDIOS_Exported_Functions_Group2 IO operation functions
525 * @brief MDIOS Read/Write functions
528 ===============================================================================
529 ##### IO operation functions #####
530 ===============================================================================
531 This subsection provides a set of functions allowing to manage the MDIOS
532 read and write operations.
534 (#) APIs that allow to the MDIOS to read/write from/to the
535 values of one of the DINn/DOUTn registers:
536 (+) Read the value of a DINn register: HAL_MDIOS_ReadReg()
537 (+) Write a value to a DOUTn register: HAL_MDIOS_WriteReg()
539 (#) APIs that provide if there are some Slave registres have been
540 read or written by the Master:
541 (+) DOUTn registers read by Master: HAL_MDIOS_GetReadRegAddress()
542 (+) DINn registers written by Master : HAL_MDIOS_GetWrittenRegAddress()
544 (#) APIs that Clear the read/write flags:
545 (+) Clear read registers flags: HAL_MDIOS_ClearReadRegAddress()
546 (+) Clear write registers flags: HAL_MDIOS_ClearWriteRegAddress()
548 (#) A set of Callbacks are provided:
549 (+) HAL_MDIOS_WriteCpltCallback()
550 (+) HAL_MDIOS_ReadCpltCallback()
551 (+) HAL_MDIOS_ErrorCallback()
558 * @brief Writes to an MDIOS output register
559 * @param hmdios mdios handle
560 * @param RegNum MDIOS input register number
561 * @param Data Data to write
564 HAL_StatusTypeDef
HAL_MDIOS_WriteReg(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
, uint16_t Data
)
568 /* Check the parameters */
569 assert_param(IS_MDIOS_REGISTER(RegNum
));
574 /* Get the addr of output register to be written by the MDIOS */
575 tmpreg
= MDIOS_DOUT_BASE_ADDR
+ (4 * RegNum
);
577 /* Write to DOUTn register */
578 *((uint32_t *)tmpreg
) = Data
;
580 /* Process Unlocked */
581 __HAL_UNLOCK(hmdios
);
587 * @brief Reads an MDIOS input register
588 * @param hmdios mdios handle
589 * @param RegNum MDIOS input register number
590 * @param pData pointer to Data
593 HAL_StatusTypeDef
HAL_MDIOS_ReadReg(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
, uint16_t *pData
)
597 /* Check the parameters */
598 assert_param(IS_MDIOS_REGISTER(RegNum
));
603 /* Get the addr of input register to be read by the MDIOS */
604 tmpreg
= MDIOS_DIN_BASE_ADDR
+ (4 * RegNum
);
606 /* Read DINn register */
607 *pData
= (uint16_t)(*((uint32_t *)tmpreg
));
609 /* Process Unlocked */
610 __HAL_UNLOCK(hmdios
);
616 * @brief Gets Written registers by MDIO master
617 * @param hmdios mdios handle
618 * @retval bit map of written registers addresses
620 uint32_t HAL_MDIOS_GetWrittenRegAddress(MDIOS_HandleTypeDef
*hmdios
)
622 return hmdios
->Instance
->WRFR
;
626 * @brief Gets Read registers by MDIO master
627 * @param hmdios mdios handle
628 * @retval bit map of read registers addresses
630 uint32_t HAL_MDIOS_GetReadRegAddress(MDIOS_HandleTypeDef
*hmdios
)
632 return hmdios
->Instance
->RDFR
;
636 * @brief Clears Write registers flag
637 * @param hmdios mdios handle
638 * @param RegNum registers addresses to be cleared
641 HAL_StatusTypeDef
HAL_MDIOS_ClearWriteRegAddress(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
)
643 /* Check the parameters */
644 assert_param(IS_MDIOS_REGISTER(RegNum
));
649 /* Clear write registers flags */
650 hmdios
->Instance
->CWRFR
|= (RegNum
);
653 __HAL_UNLOCK(hmdios
);
659 * @brief Clears Read register flag
660 * @param hmdios mdios handle
661 * @param RegNum registers addresses to be cleared
664 HAL_StatusTypeDef
HAL_MDIOS_ClearReadRegAddress(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
)
666 /* Check the parameters */
667 assert_param(IS_MDIOS_REGISTER(RegNum
));
672 /* Clear read registers flags */
673 hmdios
->Instance
->CRDFR
|= (RegNum
);
676 __HAL_UNLOCK(hmdios
);
682 * @brief Enables Events for MDIOS peripheral
683 * @param hmdios mdios handle
686 HAL_StatusTypeDef
HAL_MDIOS_EnableEvents(MDIOS_HandleTypeDef
*hmdios
)
691 /* Enable MDIOS interrupts: Register Write, Register Read and Error ITs */
692 __HAL_MDIOS_ENABLE_IT(hmdios
, (MDIOS_IT_WRITE
| MDIOS_IT_READ
| MDIOS_IT_ERROR
));
694 /* Process Unlocked */
695 __HAL_UNLOCK(hmdios
);
701 * @brief This function handles MDIOS interrupt request.
702 * @param hmdios MDIOS handle
705 void HAL_MDIOS_IRQHandler(MDIOS_HandleTypeDef
*hmdios
)
707 /* Write Register Interrupt enabled ? */
708 if(__HAL_MDIOS_GET_IT_SOURCE(hmdios
, MDIOS_IT_WRITE
) != RESET
)
710 /* Write register flag */
711 if(HAL_MDIOS_GetWrittenRegAddress(hmdios
) != RESET
)
713 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
714 /* Call registered Write complete callback */
715 hmdios
->WriteCpltCallback(hmdios
);
717 /* Write callback function */
718 HAL_MDIOS_WriteCpltCallback(hmdios
);
719 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
721 /* Clear write register flag */
722 HAL_MDIOS_ClearWriteRegAddress(hmdios
, MDIOS_ALL_REG_FLAG
);
726 /* Read Register Interrupt enabled ? */
727 if(__HAL_MDIOS_GET_IT_SOURCE(hmdios
, MDIOS_IT_READ
) != RESET
)
729 /* Read register flag */
730 if(HAL_MDIOS_GetReadRegAddress(hmdios
) != RESET
)
732 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
733 /* Call registered Read complete callback */
734 hmdios
->ReadCpltCallback(hmdios
);
736 /* Read callback function */
737 HAL_MDIOS_ReadCpltCallback(hmdios
);
738 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
740 /* Clear read register flag */
741 HAL_MDIOS_ClearReadRegAddress(hmdios
, MDIOS_ALL_REG_FLAG
);
745 /* Error Interrupt enabled ? */
746 if(__HAL_MDIOS_GET_IT_SOURCE(hmdios
, MDIOS_IT_ERROR
) != RESET
)
748 /* All Errors Flag */
749 if(__HAL_MDIOS_GET_ERROR_FLAG(hmdios
, MDIOS_ALL_ERRORS_FLAG
) !=RESET
)
751 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
752 /* Call registered Error callback */
753 hmdios
->ErrorCallback(hmdios
);
756 HAL_MDIOS_ErrorCallback(hmdios
);
757 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
759 /* Clear errors flag */
760 __HAL_MDIOS_CLEAR_ERROR_FLAG(hmdios
, MDIOS_ALL_ERRORS_FLAG
);
764 /* check MDIOS WAKEUP exti flag */
765 if(__HAL_MDIOS_WAKEUP_EXTI_GET_FLAG() != RESET
)
767 #if (USE_HAL_MDIOS_REGISTER_CALLBACKS == 1)
768 /* Call registered WakeUp callback */
769 hmdios
->WakeUpCallback(hmdios
);
771 /* MDIOS WAKEUP interrupt user callback */
772 HAL_MDIOS_WakeUpCallback(hmdios
);
773 #endif /* USE_HAL_MDIOS_REGISTER_CALLBACKS */
775 /* Clear MDIOS WAKEUP Exti pending bit */
776 __HAL_MDIOS_WAKEUP_EXTI_CLEAR_FLAG();
781 * @brief Write Complete Callback
782 * @param hmdios mdios handle
785 __weak
void HAL_MDIOS_WriteCpltCallback(MDIOS_HandleTypeDef
*hmdios
)
787 /* Prevent unused argument(s) compilation warning */
790 /* NOTE : This function should not be modified, when the callback is needed,
791 the HAL_MDIOS_WriteCpltCallback can be implemented in the user file
796 * @brief Read Complete Callback
797 * @param hmdios mdios handle
800 __weak
void HAL_MDIOS_ReadCpltCallback(MDIOS_HandleTypeDef
*hmdios
)
802 /* Prevent unused argument(s) compilation warning */
805 /* NOTE : This function should not be modified, when the callback is needed,
806 the HAL_MDIOS_ReadCpltCallback can be implemented in the user file
811 * @brief Error Callback
812 * @param hmdios mdios handle
815 __weak
void HAL_MDIOS_ErrorCallback(MDIOS_HandleTypeDef
*hmdios
)
817 /* Prevent unused argument(s) compilation warning */
820 /* NOTE : This function should not be modified, when the callback is needed,
821 the HAL_MDIOS_ErrorCallback can be implemented in the user file
826 * @brief MDIOS WAKEUP interrupt callback
827 * @param hmdios mdios handle
830 __weak
void HAL_MDIOS_WakeUpCallback(MDIOS_HandleTypeDef
*hmdios
)
832 /* Prevent unused argument(s) compilation warning */
835 /* NOTE : This function Should not be modified, when the callback is needed,
836 the HAL_MDIOS_WakeUpCallback could be implemented in the user file
844 /** @defgroup MDIOS_Exported_Functions_Group3 Peripheral Control functions
845 * @brief MDIOS control functions
848 ===============================================================================
849 ##### Peripheral Control functions #####
850 ===============================================================================
852 This subsection provides a set of functions allowing to control the MDIOS.
853 (+) HAL_MDIOS_GetState() API, helpful to check in run-time the state.
854 (+) HAL_MDIOS_GetError() API, returns the errors occurred during data transfer.
861 * @brief Gets MDIOS error flags
862 * @param hmdios mdios handle
863 * @retval bit map of occurred errors
865 uint32_t HAL_MDIOS_GetError(MDIOS_HandleTypeDef
*hmdios
)
867 /* return errors flags on status register */
868 return hmdios
->Instance
->SR
;
872 * @brief Return the MDIOS HAL state
873 * @param hmdios mdios handle
874 * @retval MDIOS state
876 HAL_MDIOS_StateTypeDef
HAL_MDIOS_GetState(MDIOS_HandleTypeDef
*hmdios
)
878 /* Return MDIOS state */
879 return hmdios
->State
;
890 #endif /* HAL_MDIOS_MODULE_ENABLED */
899 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/