STM32L443xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_smbus_ex.c 00004 * @author MCD Application Team 00005 * @brief SMBUS Extended HAL module driver. 00006 * This file provides firmware functions to manage the following 00007 * functionalities of SMBUS Extended peripheral: 00008 * + Extended features functions 00009 * 00010 ****************************************************************************** 00011 * @attention 00012 * 00013 * Copyright (c) 2017 STMicroelectronics. 00014 * All rights reserved. 00015 * 00016 * This software is licensed under terms that can be found in the LICENSE file 00017 * in the root directory of this software component. 00018 * If no LICENSE file comes with this software, it is provided AS-IS. 00019 * 00020 ****************************************************************************** 00021 @verbatim 00022 ============================================================================== 00023 ##### SMBUS peripheral Extended features ##### 00024 ============================================================================== 00025 00026 [..] Comparing to other previous devices, the SMBUS interface for STM32L4xx 00027 devices contains the following additional features 00028 00029 (+) Disable or enable wakeup from Stop mode(s) 00030 (+) Disable or enable Fast Mode Plus 00031 00032 ##### How to use this driver ##### 00033 ============================================================================== 00034 (#) Configure the enable or disable of SMBUS Wake Up Mode using the functions : 00035 (++) HAL_SMBUSEx_EnableWakeUp() 00036 (++) HAL_SMBUSEx_DisableWakeUp() 00037 (#) Configure the enable or disable of fast mode plus driving capability using the functions : 00038 (++) HAL_SMBUSEx_EnableFastModePlus() 00039 (++) HAL_SMBUSEx_DisableFastModePlus() 00040 @endverbatim 00041 */ 00042 00043 /* Includes ------------------------------------------------------------------*/ 00044 #include "stm32l4xx_hal.h" 00045 00046 /** @addtogroup STM32L4xx_HAL_Driver 00047 * @{ 00048 */ 00049 00050 /** @defgroup SMBUSEx SMBUSEx 00051 * @brief SMBUS Extended HAL module driver 00052 * @{ 00053 */ 00054 00055 #ifdef HAL_SMBUS_MODULE_ENABLED 00056 00057 /* Private typedef -----------------------------------------------------------*/ 00058 /* Private define ------------------------------------------------------------*/ 00059 /* Private macro -------------------------------------------------------------*/ 00060 /* Private variables ---------------------------------------------------------*/ 00061 /* Private function prototypes -----------------------------------------------*/ 00062 /* Private functions ---------------------------------------------------------*/ 00063 00064 /** @defgroup SMBUSEx_Exported_Functions SMBUS Extended Exported Functions 00065 * @{ 00066 */ 00067 00068 /** @defgroup SMBUSEx_Exported_Functions_Group2 WakeUp Mode Functions 00069 * @brief WakeUp Mode Functions 00070 * 00071 @verbatim 00072 =============================================================================== 00073 ##### WakeUp Mode Functions ##### 00074 =============================================================================== 00075 [..] This section provides functions allowing to: 00076 (+) Configure Wake Up Feature 00077 00078 @endverbatim 00079 * @{ 00080 */ 00081 00082 /** 00083 * @brief Enable SMBUS wakeup from Stop mode(s). 00084 * @param hsmbus Pointer to a SMBUS_HandleTypeDef structure that contains 00085 * the configuration information for the specified SMBUSx peripheral. 00086 * @retval HAL status 00087 */ 00088 HAL_StatusTypeDef HAL_SMBUSEx_EnableWakeUp(SMBUS_HandleTypeDef *hsmbus) 00089 { 00090 /* Check the parameters */ 00091 assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hsmbus->Instance)); 00092 00093 if (hsmbus->State == HAL_SMBUS_STATE_READY) 00094 { 00095 /* Process Locked */ 00096 __HAL_LOCK(hsmbus); 00097 00098 hsmbus->State = HAL_SMBUS_STATE_BUSY; 00099 00100 /* Disable the selected SMBUS peripheral */ 00101 __HAL_SMBUS_DISABLE(hsmbus); 00102 00103 /* Enable wakeup from stop mode */ 00104 hsmbus->Instance->CR1 |= I2C_CR1_WUPEN; 00105 00106 __HAL_SMBUS_ENABLE(hsmbus); 00107 00108 hsmbus->State = HAL_SMBUS_STATE_READY; 00109 00110 /* Process Unlocked */ 00111 __HAL_UNLOCK(hsmbus); 00112 00113 return HAL_OK; 00114 } 00115 else 00116 { 00117 return HAL_BUSY; 00118 } 00119 } 00120 00121 /** 00122 * @brief Disable SMBUS wakeup from Stop mode(s). 00123 * @param hsmbus Pointer to a SMBUS_HandleTypeDef structure that contains 00124 * the configuration information for the specified SMBUSx peripheral. 00125 * @retval HAL status 00126 */ 00127 HAL_StatusTypeDef HAL_SMBUSEx_DisableWakeUp(SMBUS_HandleTypeDef *hsmbus) 00128 { 00129 /* Check the parameters */ 00130 assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hsmbus->Instance)); 00131 00132 if (hsmbus->State == HAL_SMBUS_STATE_READY) 00133 { 00134 /* Process Locked */ 00135 __HAL_LOCK(hsmbus); 00136 00137 hsmbus->State = HAL_SMBUS_STATE_BUSY; 00138 00139 /* Disable the selected SMBUS peripheral */ 00140 __HAL_SMBUS_DISABLE(hsmbus); 00141 00142 /* Disable wakeup from stop mode */ 00143 hsmbus->Instance->CR1 &= ~(I2C_CR1_WUPEN); 00144 00145 __HAL_SMBUS_ENABLE(hsmbus); 00146 00147 hsmbus->State = HAL_SMBUS_STATE_READY; 00148 00149 /* Process Unlocked */ 00150 __HAL_UNLOCK(hsmbus); 00151 00152 return HAL_OK; 00153 } 00154 else 00155 { 00156 return HAL_BUSY; 00157 } 00158 } 00159 /** 00160 * @} 00161 */ 00162 00163 /** @defgroup SMBUSEx_Exported_Functions_Group3 Fast Mode Plus Functions 00164 * @brief Fast Mode Plus Functions 00165 * 00166 @verbatim 00167 =============================================================================== 00168 ##### Fast Mode Plus Functions ##### 00169 =============================================================================== 00170 [..] This section provides functions allowing to: 00171 (+) Configure Fast Mode Plus 00172 00173 @endverbatim 00174 * @{ 00175 */ 00176 00177 /** 00178 * @brief Enable the SMBUS fast mode plus driving capability. 00179 * @param ConfigFastModePlus Selects the pin. 00180 * This parameter can be one of the @ref SMBUSEx_FastModePlus values 00181 * @note For I2C1, fast mode plus driving capability can be enabled on all selected 00182 * I2C1 pins using SMBUS_FASTMODEPLUS_I2C1 parameter or independently 00183 * on each one of the following pins PB6, PB7, PB8 and PB9. 00184 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability 00185 * can be enabled only by using SMBUS_FASTMODEPLUS_I2C1 parameter. 00186 * @note For all I2C2 pins fast mode plus driving capability can be enabled 00187 * only by using SMBUS_FASTMODEPLUS_I2C2 parameter. 00188 * @note For all I2C3 pins fast mode plus driving capability can be enabled 00189 * only by using SMBUS_FASTMODEPLUS_I2C3 parameter. 00190 * @note For all I2C4 pins fast mode plus driving capability can be enabled 00191 * only by using SMBUS_FASTMODEPLUS_I2C4 parameter. 00192 * @retval None 00193 */ 00194 void HAL_SMBUSEx_EnableFastModePlus(uint32_t ConfigFastModePlus) 00195 { 00196 /* Check the parameter */ 00197 assert_param(IS_SMBUS_FASTMODEPLUS(ConfigFastModePlus)); 00198 00199 /* Enable SYSCFG clock */ 00200 __HAL_RCC_SYSCFG_CLK_ENABLE(); 00201 00202 /* Enable fast mode plus driving capability for selected pin */ 00203 SET_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus); 00204 } 00205 00206 /** 00207 * @brief Disable the SMBUS fast mode plus driving capability. 00208 * @param ConfigFastModePlus Selects the pin. 00209 * This parameter can be one of the @ref SMBUSEx_FastModePlus values 00210 * @note For I2C1, fast mode plus driving capability can be disabled on all selected 00211 * I2C1 pins using SMBUS_FASTMODEPLUS_I2C1 parameter or independently 00212 * on each one of the following pins PB6, PB7, PB8 and PB9. 00213 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability 00214 * can be disabled only by using SMBUS_FASTMODEPLUS_I2C1 parameter. 00215 * @note For all I2C2 pins fast mode plus driving capability can be disabled 00216 * only by using SMBUS_FASTMODEPLUS_I2C2 parameter. 00217 * @note For all I2C3 pins fast mode plus driving capability can be disabled 00218 * only by using SMBUS_FASTMODEPLUS_I2C3 parameter. 00219 * @note For all I2C4 pins fast mode plus driving capability can be disabled 00220 * only by using SMBUS_FASTMODEPLUS_I2C4 parameter. 00221 * @retval None 00222 */ 00223 void HAL_SMBUSEx_DisableFastModePlus(uint32_t ConfigFastModePlus) 00224 { 00225 /* Check the parameter */ 00226 assert_param(IS_SMBUS_FASTMODEPLUS(ConfigFastModePlus)); 00227 00228 /* Enable SYSCFG clock */ 00229 __HAL_RCC_SYSCFG_CLK_ENABLE(); 00230 00231 /* Disable fast mode plus driving capability for selected pin */ 00232 CLEAR_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus); 00233 } 00234 00235 /** 00236 * @} 00237 */ 00238 00239 /** 00240 * @} 00241 */ 00242 00243 /** 00244 * @} 00245 */ 00246 00247 #endif /* HAL_SMBUS_MODULE_ENABLED */ 00248 /** 00249 * @} 00250 */ 00251 00252 /** 00253 * @} 00254 */