STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_i2c_ex.c
Go to the documentation of this file.
1
41/* Includes ------------------------------------------------------------------*/
42#include "stm32f4xx_hal.h"
43
53#ifdef HAL_I2C_MODULE_ENABLED
54
55#if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
56/* Private typedef -----------------------------------------------------------*/
57/* Private define ------------------------------------------------------------*/
58/* Private macro -------------------------------------------------------------*/
59/* Private variables ---------------------------------------------------------*/
60/* Private function prototypes -----------------------------------------------*/
61/* Exported functions --------------------------------------------------------*/
88HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
89{
90 /* Check the parameters */
91 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
92 assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
93
94 if (hi2c->State == HAL_I2C_STATE_READY)
95 {
97
98 /* Disable the selected I2C peripheral */
100
101 /* Reset I2Cx ANOFF bit */
102 hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF);
103
104 /* Disable the analog filter */
105 hi2c->Instance->FLTR |= AnalogFilter;
106
107 __HAL_I2C_ENABLE(hi2c);
108
110
111 return HAL_OK;
112 }
113 else
114 {
115 return HAL_BUSY;
116 }
117}
118
126HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
127{
128 uint16_t tmpreg = 0;
129
130 /* Check the parameters */
131 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
132 assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
133
134 if (hi2c->State == HAL_I2C_STATE_READY)
135 {
137
138 /* Disable the selected I2C peripheral */
139 __HAL_I2C_DISABLE(hi2c);
140
141 /* Get the old register value */
142 tmpreg = hi2c->Instance->FLTR;
143
144 /* Reset I2Cx DNF bit [3:0] */
145 tmpreg &= ~(I2C_FLTR_DNF);
146
147 /* Set I2Cx DNF coefficient */
148 tmpreg |= DigitalFilter;
149
150 /* Store the new register value */
151 hi2c->Instance->FLTR = tmpreg;
152
153 __HAL_I2C_ENABLE(hi2c);
154
156
157 return HAL_OK;
158 }
159 else
160 {
161 return HAL_BUSY;
162 }
163}
164
172#endif
173
174#endif /* HAL_I2C_MODULE_ENABLED */
@ HAL_I2C_STATE_BUSY
@ HAL_I2C_STATE_READY
#define __HAL_I2C_DISABLE(__HANDLE__)
Disable the specified I2C peripheral.
#define __HAL_I2C_ENABLE(__HANDLE__)
Enable the specified I2C peripheral.
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_OK
@ HAL_BUSY
__IO HAL_I2C_StateTypeDef State