2 ******************************************************************************
3 * @file stm32f7xx_hal_mdios.h
4 * @author MCD Application Team
7 * @brief Header file of MDIOS HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
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.
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.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_MDIOS_H
40 #define __STM32F7xx_HAL_MDIOS_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f7xx_hal_def.h"
51 /** @addtogroup STM32F7xx_HAL_Driver
59 /* Exported types ------------------------------------------------------------*/
60 /** @defgroup MDIOS_Exported_Types MDIOS Exported Types
64 /** @defgroup MDIOS_Exported_Types_Group1 MDIOS State structures definition
70 HAL_MDIOS_STATE_RESET
= 0x00U
, /*!< Peripheral not yet Initialized or disabled */
71 HAL_MDIOS_STATE_READY
= 0x01U
, /*!< Peripheral Initialized and ready for use */
72 HAL_MDIOS_STATE_BUSY
= 0x02U
, /*!< an internal process is ongoing */
73 HAL_MDIOS_STATE_ERROR
= 0x04U
/*!< Reception process is ongoing */
74 }HAL_MDIOS_StateTypeDef
;
80 /** @defgroup MDIOS_Exported_Types_Group2 MDIOS Init Structure definition
86 uint32_t PortAddress
; /*!< Specifies the MDIOS port address.
87 This parameter can be a value from 0 to 31 */
88 uint32_t PreambleCheck
; /*!< Specifies whether the preamble check is enabled or disabled.
89 This parameter can be a value of @ref MDIOS_Preamble_Check */
96 /** @defgroup MDIOS_Exported_Types_Group4 MDIOS handle Structure definition
102 MDIOS_TypeDef
*Instance
; /*!< Register base address */
104 MDIOS_InitTypeDef Init
; /*!< MDIOS Init Structure */
106 __IO HAL_MDIOS_StateTypeDef State
; /*!< MDIOS communication state */
108 HAL_LockTypeDef Lock
; /*!< MDIOS Lock */
109 }MDIOS_HandleTypeDef
;
119 /* Exported constants --------------------------------------------------------*/
120 /** @defgroup MDIOS_Exported_Constants MDIOS Exported Constants
124 /** @defgroup MDIOS_Preamble_Check MDIOS Preamble Check
127 #define MDIOS_PREAMBLE_CHECK_ENABLE ((uint32_t)0x00000000U)
128 #define MDIOS_PREAMBLE_CHECK_DISABLE MDIOS_CR_DPC
133 /** @defgroup MDIOS_Input_Output_Registers_Definitions MDIOS Input Output Registers Definitions
136 #define MDIOS_REG0 ((uint32_t)0x00000000U)
137 #define MDIOS_REG1 ((uint32_t)0x00000001U)
138 #define MDIOS_REG2 ((uint32_t)0x00000002U)
139 #define MDIOS_REG3 ((uint32_t)0x00000003U)
140 #define MDIOS_REG4 ((uint32_t)0x00000004U)
141 #define MDIOS_REG5 ((uint32_t)0x00000005U)
142 #define MDIOS_REG6 ((uint32_t)0x00000006U)
143 #define MDIOS_REG7 ((uint32_t)0x00000007U)
144 #define MDIOS_REG8 ((uint32_t)0x00000008U)
145 #define MDIOS_REG9 ((uint32_t)0x00000009U)
146 #define MDIOS_REG10 ((uint32_t)0x0000000AU)
147 #define MDIOS_REG11 ((uint32_t)0x0000000BU)
148 #define MDIOS_REG12 ((uint32_t)0x0000000CU)
149 #define MDIOS_REG13 ((uint32_t)0x0000000DU)
150 #define MDIOS_REG14 ((uint32_t)0x0000000EU)
151 #define MDIOS_REG15 ((uint32_t)0x0000000FU)
152 #define MDIOS_REG16 ((uint32_t)0x00000010U)
153 #define MDIOS_REG17 ((uint32_t)0x00000011U)
154 #define MDIOS_REG18 ((uint32_t)0x00000012U)
155 #define MDIOS_REG19 ((uint32_t)0x00000013U)
156 #define MDIOS_REG20 ((uint32_t)0x00000014U)
157 #define MDIOS_REG21 ((uint32_t)0x00000015U)
158 #define MDIOS_REG22 ((uint32_t)0x00000016U)
159 #define MDIOS_REG23 ((uint32_t)0x00000017U)
160 #define MDIOS_REG24 ((uint32_t)0x00000018U)
161 #define MDIOS_REG25 ((uint32_t)0x00000019U)
162 #define MDIOS_REG26 ((uint32_t)0x0000001AU)
163 #define MDIOS_REG27 ((uint32_t)0x0000001BU)
164 #define MDIOS_REG28 ((uint32_t)0x0000001CU)
165 #define MDIOS_REG29 ((uint32_t)0x0000001DU)
166 #define MDIOS_REG30 ((uint32_t)0x0000001EU)
167 #define MDIOS_REG31 ((uint32_t)0x0000001FU)
172 /** @defgroup MDIOS_Registers_Flags MDIOS Registers Flags
175 #define MDIOS_REG0_FLAG ((uint32_t)0x00000001U)
176 #define MDIOS_REG1_FLAG ((uint32_t)0x00000002U)
177 #define MDIOS_REG2_FLAG ((uint32_t)0x00000004U)
178 #define MDIOS_REG3_FLAG ((uint32_t)0x00000008U)
179 #define MDIOS_REG4_FLAG ((uint32_t)0x00000010U)
180 #define MDIOS_REG5_FLAG ((uint32_t)0x00000020U)
181 #define MDIOS_REG6_FLAG ((uint32_t)0x00000040U)
182 #define MDIOS_REG7_FLAG ((uint32_t)0x00000080U)
183 #define MDIOS_REG8_FLAG ((uint32_t)0x00000100U)
184 #define MDIOS_REG9_FLAG ((uint32_t)0x00000200U)
185 #define MDIOS_REG10_FLAG ((uint32_t)0x00000400U)
186 #define MDIOS_REG11_FLAG ((uint32_t)0x00000800U)
187 #define MDIOS_REG12_FLAG ((uint32_t)0x00001000U)
188 #define MDIOS_REG13_FLAG ((uint32_t)0x00002000U)
189 #define MDIOS_REG14_FLAG ((uint32_t)0x00004000U)
190 #define MDIOS_REG15_FLAG ((uint32_t)0x00008000U)
191 #define MDIOS_REG16_FLAG ((uint32_t)0x00010000U)
192 #define MDIOS_REG17_FLAG ((uint32_t)0x00020000U)
193 #define MDIOS_REG18_FLAG ((uint32_t)0x00040000U)
194 #define MDIOS_REG19_FLAG ((uint32_t)0x00080000U)
195 #define MDIOS_REG20_FLAG ((uint32_t)0x00100000U)
196 #define MDIOS_REG21_FLAG ((uint32_t)0x00200000U)
197 #define MDIOS_REG22_FLAG ((uint32_t)0x00400000U)
198 #define MDIOS_REG23_FLAG ((uint32_t)0x00800000U)
199 #define MDIOS_REG24_FLAG ((uint32_t)0x01000000U)
200 #define MDIOS_REG25_FLAG ((uint32_t)0x02000000U)
201 #define MDIOS_REG26_FLAG ((uint32_t)0x04000000U)
202 #define MDIOS_REG27_FLAG ((uint32_t)0x08000000U)
203 #define MDIOS_REG28_FLAG ((uint32_t)0x10000000U)
204 #define MDIOS_REG29_FLAG ((uint32_t)0x20000000U)
205 #define MDIOS_REG30_FLAG ((uint32_t)0x40000000U)
206 #define MDIOS_REG31_FLAG ((uint32_t)0x80000000U)
207 #define MDIOS_ALLREG_FLAG ((uint32_t)0xFFFFFFFFU)
212 /** @defgroup MDIOS_Interrupt_sources Interrupt Sources
215 #define MDIOS_IT_WRITE MDIOS_CR_WRIE
216 #define MDIOS_IT_READ MDIOS_CR_RDIE
217 #define MDIOS_IT_ERROR MDIOS_CR_EIE
222 /** @defgroup MDIOS_Interrupt_Flags MDIOS Interrupt Flags
225 #define MDIOS_TURNAROUND_ERROR_FLAG MDIOS_SR_TERF
226 #define MDIOS_START_ERROR_FLAG MDIOS_SR_SERF
227 #define MDIOS_PREAMBLE_ERROR_FLAG MDIOS_SR_PERF
232 /** @defgroup MDIOS_Wakeup_Line MDIOS Wakeup Line
235 #define MDIOS_WAKEUP_EXTI_LINE ((uint32_t)0x01000000) /* !< EXTI Line 24 */
243 /* Exported macros -----------------------------------------------------------*/
244 /** @defgroup MDIOS_Exported_Macros MDIOS Exported Macros
248 /** @brief Reset MDIOS handle state
249 * @param __HANDLE__: MDIOS handle.
252 #define __HAL_MDIOS_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_MDIOS_STATE_RESET)
255 * @brief Enable/Disable the MDIOS peripheral.
256 * @param __HANDLE__: specifies the MDIOS handle.
259 #define __HAL_MDIOS_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= MDIOS_CR_EN)
260 #define __HAL_MDIOS_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~MDIOS_CR_EN)
264 * @brief Enable the MDIOS device interrupt.
265 * @param __HANDLE__: specifies the MDIOS handle.
266 * @param __INTERRUPT__ : specifies the MDIOS interrupt sources to be enabled.
267 * This parameter can be one or a combination of the following values:
268 * @arg MDIOS_IT_WRITE: Register write interrupt
269 * @arg MDIOS_IT_READ: Register read interrupt
270 * @arg MDIOS_IT_ERROR: Error interrupt
273 #define __HAL_MDIOS_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
276 * @brief Disable the MDIOS device interrupt.
277 * @param __HANDLE__: specifies the MDIOS handle.
278 * @param __INTERRUPT__ : specifies the MDIOS interrupt sources to be disabled.
279 * This parameter can be one or a combination of the following values:
280 * @arg MDIOS_IT_WRITE: Register write interrupt
281 * @arg MDIOS_IT_READ: Register read interrupt
282 * @arg MDIOS_IT_ERROR: Error interrupt
285 #define __HAL_MDIOS_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
287 /** @brief Set MDIOS slave get write register flag
288 * @param __HANDLE__: specifies the MDIOS handle.
289 * @param __FLAG__: specifies the write register flag
290 * @retval The state of write flag
292 #define __HAL_MDIOS_GET_WRITE_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->WRFR & (__FLAG__))
294 /** @brief MDIOS slave get read register flag
295 * @param __HANDLE__: specifies the MDIOS handle.
296 * @param __FLAG__: specifies the read register flag
297 * @retval The state of read flag
299 #define __HAL_MDIOS_GET_READ_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->RDFR & (__FLAG__))
301 /** @brief MDIOS slave get interrupt
302 * @param __HANDLE__: specifies the MDIOS handle.
303 * @param __FLAG__ : specifies the Error flag.
304 * This parameter can be one or a combination of the following values:
305 * @arg MDIOS_TURNARROUND_ERROR_FLAG: Register write interrupt
306 * @arg MDIOS_START_ERROR_FLAG: Register read interrupt
307 * @arg MDIOS_PREAMBLE_ERROR_FLAG: Error interrupt
308 * @retval The state of the error flag
310 #define __HAL_MDIOS_GET_ERROR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR & (__FLAG__))
312 /** @brief MDIOS slave clear interrupt
313 * @param __HANDLE__: specifies the MDIOS handle.
314 * @param __FLAG__ : specifies the Error flag.
315 * This parameter can be one or a combination of the following values:
316 * @arg MDIOS_TURNARROUND_ERROR_FLAG: Register write interrupt
317 * @arg MDIOS_START_ERROR_FLAG: Register read interrupt
318 * @arg MDIOS_PREAMBLE_ERROR_FLAG: Error interrupt
321 #define __HAL_MDIOS_CLEAR_ERROR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR) |= (__FLAG__)
324 * @brief Checks whether the specified MDIOS interrupt is set or not.
325 * @param __HANDLE__: specifies the MDIOS handle.
326 * @param __INTERRUPT__ : specifies the MDIOS interrupt sources
327 * This parameter can be one or a combination of the following values:
328 * @arg MDIOS_IT_WRITE: Register write interrupt
329 * @arg MDIOS_IT_READ: Register read interrupt
330 * @arg MDIOS_IT_ERROR: Error interrupt
331 * @retval The state of the interrupt source
333 #define __HAL_MDIOS_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__))
336 * @brief Enable the MDIOS WAKEUP Exti Line.
339 #define __HAL_MDIOS_WAKEUP_EXTI_ENABLE_IT() (EXTI->IMR |= (MDIOS_WAKEUP_EXTI_LINE))
342 * @brief Disable the MDIOS WAKEUP Exti Line.
345 #define __HAL_MDIOS_WAKEUP_EXTI_DISABLE_IT() (EXTI->IMR &= ~(MDIOS_WAKEUP_EXTI_LINE))
348 * @brief Enable event on MDIOS WAKEUP Exti Line.
351 #define __HAL_MDIOS_WAKEUP_EXTI_ENABLE_EVENT() (EXTI->EMR |= (MDIOS_WAKEUP_EXTI_LINE))
354 * @brief Disable event on MDIOS WAKEUP Exti Line.
357 #define __HAL_MDIOS_WAKEUP_EXTI_DISABLE_EVENT() (EXTI->EMR &= ~(MDIOS_WAKEUP_EXTI_LINE))
360 * @brief checks whether the specified MDIOS WAKEUP Exti interrupt flag is set or not.
361 * @retval EXTI MDIOS WAKEUP Line Status.
363 #define __HAL_MDIOS_WAKEUP_EXTI_GET_FLAG() (EXTI->PR & (MDIOS_WAKEUP_EXTI_LINE))
366 * @brief Clear the MDIOS WAKEUP Exti flag.
369 #define __HAL_MDIOS_WAKEUP_EXTI_CLEAR_FLAG() (EXTI->PR = (MDIOS_WAKEUP_EXTI_LINE))
372 * @brief Enables rising edge trigger to the MDIOS External interrupt line.
375 #define __HAL_MDIOS_WAKEUP_EXTI_ENABLE_RISING_EDGE_TRIGGER() EXTI->RTSR |= MDIOS_WAKEUP_EXTI_LINE
378 * @brief Disables the rising edge trigger to the MDIOS External interrupt line.
381 #define __HAL_MDIOS_WAKEUP_EXTI_DISABLE_RISING_EDGE_TRIGGER() EXTI->RTSR &= ~(MDIOS_WAKEUP_EXTI_LINE)
384 * @brief Enables falling edge trigger to the MDIOS External interrupt line.
387 #define __HAL_MDIOS_WAKEUP_EXTI_ENABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR |= (MDIOS_WAKEUP_EXTI_LINE)
390 * @brief Disables falling edge trigger to the MDIOS External interrupt line.
393 #define __HAL_MDIOS_WAKEUP_EXTI_DISABLE_FALLING_EDGE_TRIGGER() EXTI->FTSR &= ~(MDIOS_WAKEUP_EXTI_LINE)
396 * @brief Enables rising/falling edge trigger to the MDIOS External interrupt line.
399 #define __HAL_MDIOS_WAKEUP_EXTI_ENABLE_FALLINGRISING_TRIGGER() EXTI->RTSR |= MDIOS_WAKEUP_EXTI_LINE;\
400 EXTI->FTSR |= MDIOS_WAKEUP_EXTI_LINE
403 * @brief Disables rising/falling edge trigger to the MDIOS External interrupt line.
406 #define __HAL_MDIOS_WAKEUP_EXTI_DISABLE_FALLINGRISING_TRIGGER() EXTI->RTSR &= ~(MDIOS_WAKEUP_EXTI_LINE);\
407 EXTI->FTSR &= ~(MDIOS_WAKEUP_EXTI_LINE)
409 * @brief Generates a Software interrupt on selected EXTI line.
412 #define __HAL_MDIOS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= (MDIOS_WAKEUP_EXTI_LINE))
418 /* Exported functions --------------------------------------------------------*/
419 /** @defgroup MDIOS_Exported_Functions MDIOS Exported Functions
423 /** @addtogroup MDIOS_Exported_Functions_Group1
426 HAL_StatusTypeDef
HAL_MDIOS_Init(MDIOS_HandleTypeDef
*hmdios
);
427 HAL_StatusTypeDef
HAL_MDIOS_DeInit(MDIOS_HandleTypeDef
*hmdios
);
428 void HAL_MDIOS_MspInit(MDIOS_HandleTypeDef
*hmdios
);
429 void HAL_MDIOS_MspDeInit(MDIOS_HandleTypeDef
*hmdios
);
434 /** @addtogroup MDIOS_Exported_Functions_Group2
437 HAL_StatusTypeDef
HAL_MDIOS_WriteReg(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
, uint16_t Data
);
438 HAL_StatusTypeDef
HAL_MDIOS_ReadReg(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
, uint16_t *pData
);
440 uint32_t HAL_MDIOS_GetWrittenRegAddress(MDIOS_HandleTypeDef
*hmdios
);
441 uint32_t HAL_MDIOS_GetReadRegAddress(MDIOS_HandleTypeDef
*hmdios
);
442 HAL_StatusTypeDef
HAL_MDIOS_ClearWriteRegAddress(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
);
443 HAL_StatusTypeDef
HAL_MDIOS_ClearReadRegAddress(MDIOS_HandleTypeDef
*hmdios
, uint32_t RegNum
);
445 HAL_StatusTypeDef
HAL_MDIOS_EnableEvents(MDIOS_HandleTypeDef
*hmdios
);
446 void HAL_MDIOS_IRQHandler(MDIOS_HandleTypeDef
*hmdios
);
447 void HAL_MDIOS_WriteCpltCallback(MDIOS_HandleTypeDef
*hmdios
);
448 void HAL_MDIOS_ReadCpltCallback(MDIOS_HandleTypeDef
*hmdios
);
449 void HAL_MDIOS_ErrorCallback(MDIOS_HandleTypeDef
*hmdios
);
450 void HAL_MDIOS_WakeUpCallback(MDIOS_HandleTypeDef
*hmdios
);
455 /** @addtogroup MDIOS_Exported_Functions_Group3
458 uint32_t HAL_MDIOS_GetError(MDIOS_HandleTypeDef
*hmdios
);
459 HAL_MDIOS_StateTypeDef
HAL_MDIOS_GetState(MDIOS_HandleTypeDef
*hmdios
);
468 /* Private types -------------------------------------------------------------*/
469 /** @defgroup MDIOS_Private_Types MDIOS Private Types
477 /* Private variables ---------------------------------------------------------*/
478 /** @defgroup MDIOS_Private_Variables MDIOS Private Variables
486 /* Private constants ---------------------------------------------------------*/
487 /** @defgroup MDIOS_Private_Constants MDIOS Private Constants
495 /* Private macros ------------------------------------------------------------*/
496 /** @defgroup MDIOS_Private_Macros MDIOS Private Macros
500 #define IS_MDIOS_PORTADDRESS(__ADDR__) ((__ADDR__) < 32)
502 #define IS_MDIOS_REGISTER(__REGISTER__) ((__REGISTER__) < 32)
504 #define IS_MDIOS_PREAMBLECHECK(__PREAMBLECHECK__) (((__PREAMBLECHECK__) == MDIOS_PREAMBLE_CHECK_ENABLE) || \
505 ((__PREAMBLECHECK__) == MDIOS_PREAMBLE_CHECK_DISABLE))
511 /* Private functions ---------------------------------------------------------*/
512 /** @defgroup MDIOS_Private_Functions MDIOS Private Functions
535 #endif /* __STM32F7xx_HAL_MDIOS_H */
537 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/