STM32F4xx HAL Driver
master
STM32CubeF4 HAL / LL Drivers API Reference
Toggle main menu visibility
Loading...
Searching...
No Matches
stm32f4xx_hal_i2c_ex.c
Go to the documentation of this file.
1
40
41
/* Includes ------------------------------------------------------------------*/
42
#include "
stm32f4xx_hal.h
"
43
47
52
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 --------------------------------------------------------*/
65
66
80
88
HAL_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
{
96
hi2c->
State
=
HAL_I2C_STATE_BUSY
;
97
98
/* Disable the selected I2C peripheral */
99
__HAL_I2C_DISABLE
(hi2c);
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
109
hi2c->
State
=
HAL_I2C_STATE_READY
;
110
111
return
HAL_OK
;
112
}
113
else
114
{
115
return
HAL_BUSY
;
116
}
117
}
118
126
HAL_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
{
136
hi2c->
State
=
HAL_I2C_STATE_BUSY
;
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
155
hi2c->
State
=
HAL_I2C_STATE_READY
;
156
157
return
HAL_OK
;
158
}
159
else
160
{
161
return
HAL_BUSY
;
162
}
163
}
164
168
172
#endif
173
174
#endif
/* HAL_I2C_MODULE_ENABLED */
178
182
HAL_I2C_STATE_BUSY
@ HAL_I2C_STATE_BUSY
Definition
stm32f4xx_hal_i2c.h:110
HAL_I2C_STATE_READY
@ HAL_I2C_STATE_READY
Definition
stm32f4xx_hal_i2c.h:109
__HAL_I2C_DISABLE
#define __HAL_I2C_DISABLE(__HANDLE__)
Disable the specified I2C peripheral.
Definition
stm32f4xx_hal_i2c.h:526
__HAL_I2C_ENABLE
#define __HAL_I2C_ENABLE(__HANDLE__)
Enable the specified I2C peripheral.
Definition
stm32f4xx_hal_i2c.h:520
assert_param
#define assert_param(expr)
Definition
stm32_assert_template.h:46
stm32f4xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition
stm32f4xx_hal_def.h:39
HAL_OK
@ HAL_OK
Definition
stm32f4xx_hal_def.h:40
HAL_BUSY
@ HAL_BUSY
Definition
stm32f4xx_hal_def.h:42
I2C_HandleTypeDef
Definition
stm32f4xx_hal_i2c.h:189
I2C_HandleTypeDef::State
volatile HAL_I2C_StateTypeDef State
Definition
stm32f4xx_hal_i2c.h:211
I2C_HandleTypeDef::Instance
I2C_TypeDef * Instance
Definition
stm32f4xx_hal_i2c.h:190
hal-driver
Src
stm32f4xx_hal_i2c_ex.c
Generated by
1.17.0