STM32H735xx HAL User Manual
Defines | Functions
stm32h7xx_hal_mdios.c File Reference

MDIOS HAL module driver. This file provides firmware functions to manage the following functionalities of the MDIOS Peripheral. + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions. More...

#include "stm32h7xx_hal.h"

Go to the source code of this file.

Defines

#define MDIOS_PORT_ADDRESS_SHIFT   ((uint32_t)8)
#define MDIOS_ALL_REG_FLAG   ((uint32_t)0xFFFFFFFFU)
#define MDIOS_ALL_ERRORS_FLAG   ((uint32_t)(MDIOS_SR_PERF | MDIOS_SR_SERF | MDIOS_SR_TERF))
#define MDIOS_DIN_BASE_ADDR   (MDIOS_BASE + 0x100U)
#define MDIOS_DOUT_BASE_ADDR   (MDIOS_BASE + 0x180U)

Functions

static void MDIOS_InitCallbacksToDefault (MDIOS_HandleTypeDef *hmdios)
HAL_StatusTypeDef HAL_MDIOS_Init (MDIOS_HandleTypeDef *hmdios)
 Initializes the MDIOS according to the specified parameters in the MDIOS_InitTypeDef and creates the associated handle .
HAL_StatusTypeDef HAL_MDIOS_DeInit (MDIOS_HandleTypeDef *hmdios)
 DeInitializes the MDIOS peripheral.
__weak void HAL_MDIOS_MspInit (MDIOS_HandleTypeDef *hmdios)
 MDIOS MSP Init.
__weak void HAL_MDIOS_MspDeInit (MDIOS_HandleTypeDef *hmdios)
 MDIOS MSP DeInit.
HAL_StatusTypeDef HAL_MDIOS_RegisterCallback (MDIOS_HandleTypeDef *hmdios, HAL_MDIOS_CallbackIDTypeDef CallbackID, pMDIOS_CallbackTypeDef pCallback)
 Register a User MDIOS Callback To be used instead of the weak predefined callback.
HAL_StatusTypeDef HAL_MDIOS_UnRegisterCallback (MDIOS_HandleTypeDef *hmdios, HAL_MDIOS_CallbackIDTypeDef CallbackID)
 Unregister an MDIOS Callback MDIOS callabck is redirected to the weak predefined callback.
HAL_StatusTypeDef HAL_MDIOS_WriteReg (MDIOS_HandleTypeDef *hmdios, uint32_t RegNum, uint16_t Data)
 Writes to an MDIOS output register.
HAL_StatusTypeDef HAL_MDIOS_ReadReg (MDIOS_HandleTypeDef *hmdios, uint32_t RegNum, uint16_t *pData)
 Reads an MDIOS input register.
uint32_t HAL_MDIOS_GetWrittenRegAddress (MDIOS_HandleTypeDef *hmdios)
 Gets Written registers by MDIO master.
uint32_t HAL_MDIOS_GetReadRegAddress (MDIOS_HandleTypeDef *hmdios)
 Gets Read registers by MDIO master.
HAL_StatusTypeDef HAL_MDIOS_ClearWriteRegAddress (MDIOS_HandleTypeDef *hmdios, uint32_t RegNum)
 Clears Write registers flag.
HAL_StatusTypeDef HAL_MDIOS_ClearReadRegAddress (MDIOS_HandleTypeDef *hmdios, uint32_t RegNum)
 Clears Read register flag.
HAL_StatusTypeDef HAL_MDIOS_EnableEvents (MDIOS_HandleTypeDef *hmdios)
 Enables Events for MDIOS peripheral.
void HAL_MDIOS_IRQHandler (MDIOS_HandleTypeDef *hmdios)
 This function handles MDIOS interrupt request.
__weak void HAL_MDIOS_WriteCpltCallback (MDIOS_HandleTypeDef *hmdios)
 Write Complete Callback.
__weak void HAL_MDIOS_ReadCpltCallback (MDIOS_HandleTypeDef *hmdios)
 Read Complete Callback.
__weak void HAL_MDIOS_ErrorCallback (MDIOS_HandleTypeDef *hmdios)
 Error Callback.
__weak void HAL_MDIOS_WakeUpCallback (MDIOS_HandleTypeDef *hmdios)
 MDIOS WAKEUP interrupt callback.
uint32_t HAL_MDIOS_GetError (MDIOS_HandleTypeDef *hmdios)
 Gets MDIOS error code.
HAL_MDIOS_StateTypeDef HAL_MDIOS_GetState (MDIOS_HandleTypeDef *hmdios)
 Return the MDIOS HAL state.

Detailed Description

MDIOS HAL module driver. This file provides firmware functions to manage the following functionalities of the MDIOS Peripheral. + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions.

Author:
MCD Application Team
Attention:

Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

 ===============================================================================
                        ##### How to use this driver #####
 ===============================================================================
    [..]
    The MDIOS HAL driver can be used as follow:

    (#) Declare a MDIOS_HandleTypeDef handle structure.

    (#) Initialize the MDIOS low level resources by implementing the HAL_MDIOS_MspInit() API:
        (##) Enable the MDIOS interface clock.
        (##) MDIOS pins configuration:
            (+++) Enable clocks for the MDIOS GPIOs.
            (+++) Configure the MDIOS pins as alternate function.
        (##) NVIC configuration if you need to use interrupt process:
            (+++) Configure the MDIOS interrupt priority.
            (+++) Enable the NVIC MDIOS IRQ handle.

    (#) Program the Port Address and the Preamble Check in the Init structure.

    (#) Initialize the MDIOS registers by calling the HAL_MDIOS_Init() API.

    (#) Perform direct slave read/write operations using the following APIs:
        (##) Read the value of a DINn register: HAL_MDIOS_ReadReg()
        (##) Write a value to a DOUTn register: HAL_MDIOS_WriteReg()

    (#) Get the Master read/write operations flags using the following APIs:
        (##) Bit map of DOUTn registers read by Master: HAL_MDIOS_GetReadRegAddress()
        (##) Bit map of DINn registers written by Master : HAL_MDIOS_GetWrittenRegAddress()

    (#) Clear the read/write flags using the following APIs:
        (##) Clear read flags of a set of registers: HAL_MDIOS_ClearReadRegAddress()
        (##) Clear write flags of a set of registers: HAL_MDIOS_ClearWriteRegAddress()

    (#) Enable interrupts on events using HAL_MDIOS_EnableEvents(), when called
        the MDIOS will generate an interrupt in the following cases:
        (##) a DINn register written by the Master
        (##) a DOUTn register read by the Master
        (##) an error occur

        (@) A callback is executed for each genereted interrupt, so the driver provide the following
            HAL_MDIOS_WriteCpltCallback(), HAL_MDIOS_ReadCpltCallback() and HAL_MDIOS_ErrorCallback()
        (@) HAL_MDIOS_IRQHandler() must be called from the MDIOS IRQ Handler, to handle the interrupt
            and execute the previous callbacks

    (#) Reset the MDIOS peripheral and all related resources by calling the HAL_MDIOS_DeInit() API.
        (##) HAL_MDIOS_MspDeInit() must be implemented to reset low level resources
            (GPIO, Clocks, NVIC configuration ...)

  *** Callback registration ***
  =============================================

  The compilation define  USE_HAL_MDIOS_REGISTER_CALLBACKS when set to 1
  allows the user to configure dynamically the driver callbacks.
  Use Function @ref HAL_MDIOS_RegisterCallback() to register an interrupt callback.

  Function @ref HAL_MDIOS_RegisterCallback() allows to register following callbacks:
    (+) WriteCpltCallback  : Write Complete Callback.
    (+) ReadCpltCallback   : Read Complete Callback.
    (+) ErrorCallback      : Error Callback.
    (+) WakeUpCallback     : Wake UP Callback
    (+) MspInitCallback    : MspInit Callback.
    (+) MspDeInitCallback  : MspDeInit Callback.

  This function takes as parameters the HAL peripheral handle, the Callback ID
  and a pointer to the user callback function.

  Use function @ref HAL_MDIOS_UnRegisterCallback() to reset a callback to the default
  weak function.
  @ref HAL_MDIOS_UnRegisterCallback takes as parameters the HAL peripheral handle,
  and the Callback ID.
  This function allows to reset following callbacks:
    (+) WriteCpltCallback  : Write Complete Callback.
    (+) ReadCpltCallback   : Read Complete Callback.
    (+) ErrorCallback      : Error Callback.
    (+) WakeUpCallback     : Wake UP Callback
    (+) MspInitCallback    : MspInit Callback.
    (+) MspDeInitCallback  : MspDeInit Callback.

  By default, after the HAL_MDIOS_Init and when the state is HAL_MDIOS_STATE_RESET
  all callbacks are set to the corresponding weak functions:
  examples @ref HAL_MDIOS_WriteCpltCallback(), @ref HAL_MDIOS_ReadCpltCallback().
  Exception done for MspInit and MspDeInit functions that are
  reset to the legacy weak function in the HAL_MDIOS_Init/ @ref HAL_MDIOS_DeInit only when
  these callbacks are null (not registered beforehand).
  if not, MspInit or MspDeInit are not null, the HAL_MDIOS_Init/ @ref HAL_MDIOS_DeInit
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand)

  Callbacks can be registered/unregistered in HAL_MDIOS_STATE_READY state only.
  Exception done MspInit/MspDeInit that can be registered/unregistered
  in HAL_MDIOS_STATE_READY or HAL_MDIOS_STATE_RESET state,
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
  In that case first register the MspInit/MspDeInit user callbacks
  using @ref HAL_MDIOS_RegisterCallback() before calling @ref HAL_MDIOS_DeInit
  or HAL_MDIOS_Init function.

  When The compilation define USE_HAL_MDIOS_REGISTER_CALLBACKS is set to 0 or
  not defined, the callback registration feature is not available and all callbacks
  are set to the corresponding weak functions.


  

Definition in file stm32h7xx_hal_mdios.c.