![]() |
|
|||
File indexing completed on 2025-05-11 08:23:09
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_hal_smbus_ex.c 0004 * @author MCD Application Team 0005 * @brief SMBUS Extended HAL module driver. 0006 * This file provides firmware functions to manage the following 0007 * functionalities of SMBUS Extended peripheral: 0008 * + Extended features functions 0009 * 0010 ****************************************************************************** 0011 * @attention 0012 * 0013 * Copyright (c) 2017 STMicroelectronics. 0014 * All rights reserved. 0015 * 0016 * This software is licensed under terms that can be found in the LICENSE file 0017 * in the root directory of this software component. 0018 * If no LICENSE file comes with this software, it is provided AS-IS. 0019 * 0020 ****************************************************************************** 0021 @verbatim 0022 ============================================================================== 0023 ##### SMBUS peripheral Extended features ##### 0024 ============================================================================== 0025 0026 [..] Comparing to other previous devices, the SMBUS interface for STM32H7xx 0027 devices contains the following additional features 0028 0029 (+) Disable or enable wakeup from Stop mode(s) 0030 (+) Disable or enable Fast Mode Plus 0031 0032 ##### How to use this driver ##### 0033 ============================================================================== 0034 (#) Configure the enable or disable of SMBUS Wake Up Mode using the functions : 0035 (++) HAL_SMBUSEx_EnableWakeUp() 0036 (++) HAL_SMBUSEx_DisableWakeUp() 0037 (#) Configure the enable or disable of fast mode plus driving capability using the functions : 0038 (++) HAL_SMBUSEx_EnableFastModePlus() 0039 (++) HAL_SMBUSEx_DisableFastModePlus() 0040 @endverbatim 0041 */ 0042 0043 /* Includes ------------------------------------------------------------------*/ 0044 #include "stm32h7xx_hal.h" 0045 0046 /** @addtogroup STM32H7xx_HAL_Driver 0047 * @{ 0048 */ 0049 0050 /** @defgroup SMBUSEx SMBUSEx 0051 * @ingroup RTEMSBSPsARMSTM32H7 0052 * @brief SMBUS Extended HAL module driver 0053 * @{ 0054 */ 0055 0056 #ifdef HAL_SMBUS_MODULE_ENABLED 0057 0058 /* Private typedef -----------------------------------------------------------*/ 0059 /* Private define ------------------------------------------------------------*/ 0060 /* Private macro -------------------------------------------------------------*/ 0061 /* Private variables ---------------------------------------------------------*/ 0062 /* Private function prototypes -----------------------------------------------*/ 0063 /* Private functions ---------------------------------------------------------*/ 0064 0065 /** @defgroup SMBUSEx_Exported_Functions SMBUS Extended Exported Functions 0066 * @ingroup RTEMSBSPsARMSTM32H7 0067 * @{ 0068 */ 0069 0070 /** @defgroup SMBUSEx_Exported_Functions_Group2 WakeUp Mode Functions 0071 * @ingroup RTEMSBSPsARMSTM32H7 0072 * @brief WakeUp Mode Functions 0073 * 0074 @verbatim 0075 =============================================================================== 0076 ##### WakeUp Mode Functions ##### 0077 =============================================================================== 0078 [..] This section provides functions allowing to: 0079 (+) Configure Wake Up Feature 0080 0081 @endverbatim 0082 * @{ 0083 */ 0084 0085 /** 0086 * @brief Enable SMBUS wakeup from Stop mode(s). 0087 * @param hsmbus Pointer to a SMBUS_HandleTypeDef structure that contains 0088 * the configuration information for the specified SMBUSx peripheral. 0089 * @retval HAL status 0090 */ 0091 HAL_StatusTypeDef HAL_SMBUSEx_EnableWakeUp(SMBUS_HandleTypeDef *hsmbus) 0092 { 0093 /* Check the parameters */ 0094 assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hsmbus->Instance)); 0095 0096 if (hsmbus->State == HAL_SMBUS_STATE_READY) 0097 { 0098 /* Process Locked */ 0099 __HAL_LOCK(hsmbus); 0100 0101 hsmbus->State = HAL_SMBUS_STATE_BUSY; 0102 0103 /* Disable the selected SMBUS peripheral */ 0104 __HAL_SMBUS_DISABLE(hsmbus); 0105 0106 /* Enable wakeup from stop mode */ 0107 hsmbus->Instance->CR1 |= I2C_CR1_WUPEN; 0108 0109 __HAL_SMBUS_ENABLE(hsmbus); 0110 0111 hsmbus->State = HAL_SMBUS_STATE_READY; 0112 0113 /* Process Unlocked */ 0114 __HAL_UNLOCK(hsmbus); 0115 0116 return HAL_OK; 0117 } 0118 else 0119 { 0120 return HAL_BUSY; 0121 } 0122 } 0123 0124 /** 0125 * @brief Disable SMBUS wakeup from Stop mode(s). 0126 * @param hsmbus Pointer to a SMBUS_HandleTypeDef structure that contains 0127 * the configuration information for the specified SMBUSx peripheral. 0128 * @retval HAL status 0129 */ 0130 HAL_StatusTypeDef HAL_SMBUSEx_DisableWakeUp(SMBUS_HandleTypeDef *hsmbus) 0131 { 0132 /* Check the parameters */ 0133 assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hsmbus->Instance)); 0134 0135 if (hsmbus->State == HAL_SMBUS_STATE_READY) 0136 { 0137 /* Process Locked */ 0138 __HAL_LOCK(hsmbus); 0139 0140 hsmbus->State = HAL_SMBUS_STATE_BUSY; 0141 0142 /* Disable the selected SMBUS peripheral */ 0143 __HAL_SMBUS_DISABLE(hsmbus); 0144 0145 /* Disable wakeup from stop mode */ 0146 hsmbus->Instance->CR1 &= ~(I2C_CR1_WUPEN); 0147 0148 __HAL_SMBUS_ENABLE(hsmbus); 0149 0150 hsmbus->State = HAL_SMBUS_STATE_READY; 0151 0152 /* Process Unlocked */ 0153 __HAL_UNLOCK(hsmbus); 0154 0155 return HAL_OK; 0156 } 0157 else 0158 { 0159 return HAL_BUSY; 0160 } 0161 } 0162 /** 0163 * @} 0164 */ 0165 0166 /** @defgroup SMBUSEx_Exported_Functions_Group3 Fast Mode Plus Functions 0167 * @ingroup RTEMSBSPsARMSTM32H7 0168 * @brief Fast Mode Plus Functions 0169 * 0170 @verbatim 0171 =============================================================================== 0172 ##### Fast Mode Plus Functions ##### 0173 =============================================================================== 0174 [..] This section provides functions allowing to: 0175 (+) Configure Fast Mode Plus 0176 0177 @endverbatim 0178 * @{ 0179 */ 0180 0181 /** 0182 * @brief Enable the SMBUS fast mode plus driving capability. 0183 * @param ConfigFastModePlus Selects the pin. 0184 * This parameter can be one of the @ref SMBUSEx_FastModePlus values 0185 * @note For I2C1, fast mode plus driving capability can be enabled on all selected 0186 * I2C1 pins using SMBUS_FASTMODEPLUS_I2C1 parameter or independently 0187 * on each one of the following pins PB6, PB7, PB8 and PB9. 0188 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability 0189 * can be enabled only by using SMBUS_FASTMODEPLUS_I2C1 parameter. 0190 * @note For all I2C2 pins fast mode plus driving capability can be enabled 0191 * only by using SMBUS_FASTMODEPLUS_I2C2 parameter. 0192 * @note For all I2C3 pins fast mode plus driving capability can be enabled 0193 * only by using SMBUS_FASTMODEPLUS_I2C3 parameter. 0194 * @note For all I2C4 pins fast mode plus driving capability can be enabled 0195 * only by using SMBUS_FASTMODEPLUS_I2C4 parameter. 0196 * @note For all I2C5 pins fast mode plus driving capability can be enabled 0197 * only by using SMBUS_FASTMODEPLUS_I2C5 parameter. 0198 * @retval None 0199 */ 0200 void HAL_SMBUSEx_EnableFastModePlus(uint32_t ConfigFastModePlus) 0201 { 0202 /* Check the parameter */ 0203 assert_param(IS_SMBUS_FASTMODEPLUS(ConfigFastModePlus)); 0204 0205 /* Enable SYSCFG clock */ 0206 __HAL_RCC_SYSCFG_CLK_ENABLE(); 0207 0208 /* Enable fast mode plus driving capability for selected pin */ 0209 SET_BIT(SYSCFG->PMCR, (uint32_t)ConfigFastModePlus); 0210 } 0211 0212 /** 0213 * @brief Disable the SMBUS fast mode plus driving capability. 0214 * @param ConfigFastModePlus Selects the pin. 0215 * This parameter can be one of the @ref SMBUSEx_FastModePlus values 0216 * @note For I2C1, fast mode plus driving capability can be disabled on all selected 0217 * I2C1 pins using SMBUS_FASTMODEPLUS_I2C1 parameter or independently 0218 * on each one of the following pins PB6, PB7, PB8 and PB9. 0219 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability 0220 * can be disabled only by using SMBUS_FASTMODEPLUS_I2C1 parameter. 0221 * @note For all I2C2 pins fast mode plus driving capability can be disabled 0222 * only by using SMBUS_FASTMODEPLUS_I2C2 parameter. 0223 * @note For all I2C3 pins fast mode plus driving capability can be disabled 0224 * only by using SMBUS_FASTMODEPLUS_I2C3 parameter. 0225 * @note For all I2C4 pins fast mode plus driving capability can be disabled 0226 * only by using SMBUS_FASTMODEPLUS_I2C4 parameter. 0227 * @note For all I2C5 pins fast mode plus driving capability can be disabled 0228 * only by using SMBUS_FASTMODEPLUS_I2C5 parameter. 0229 * @retval None 0230 */ 0231 void HAL_SMBUSEx_DisableFastModePlus(uint32_t ConfigFastModePlus) 0232 { 0233 /* Check the parameter */ 0234 assert_param(IS_SMBUS_FASTMODEPLUS(ConfigFastModePlus)); 0235 0236 /* Enable SYSCFG clock */ 0237 __HAL_RCC_SYSCFG_CLK_ENABLE(); 0238 0239 /* Disable fast mode plus driving capability for selected pin */ 0240 CLEAR_BIT(SYSCFG->PMCR, (uint32_t)ConfigFastModePlus); 0241 } 0242 0243 /** 0244 * @} 0245 */ 0246 0247 /** 0248 * @} 0249 */ 0250 0251 /** 0252 * @} 0253 */ 0254 0255 #endif /* HAL_SMBUS_MODULE_ENABLED */ 0256 /** 0257 * @} 0258 */ 0259 0260 /** 0261 * @} 0262 */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |