Home > other >  [] in the standard library STM32F4 configuration of IO pin when simulating IIC why will influence ea
[] in the standard library STM32F4 configuration of IO pin when simulating IIC why will influence ea

Time:01-10

When simulating IIC, need from the IIC bus, reading and writing level, so wrote two functions

Has enabled the clock, SCL configuration for the output. So these two functions only in charge of the SDA line shift mode.
but more meng force happened, read out is disorderly or not in line with expectations.
Early in the morning and later in writing function added to reconfigure SCL.

Try to revise a few places, only change is the only useful to the write mode function configuration SCL.
That in theory could not have happened?
Or I have I don't understand?
o do bosses can help answer.

CodePudding user response:

# define SDA_OUT () \
{\
LL_GPIO_InitTypeDef GPIO_InitStruct. \
GPIO_InitStruct. Pin=I2C_SDA_Pin; \
GPIO_InitStruct. Mode=LL_GPIO_MODE_OUTPUT; \
GPIO_InitStruct. Speed=LL_GPIO_SPEED_FREQ_MEDIUM; \
GPIO_InitStruct. OutputType=LL_GPIO_OUTPUT_OPENDRAIN; \
GPIO_InitStruct. Pull=LL_GPIO_PULL_UP; \
LL_GPIO_Init (I2C_SDA_GPIO_Port, & amp; GPIO_InitStruct); \
}

# define SDA_IN () \
{\
LL_GPIO_InitTypeDef GPIO_InitStruct. \
GPIO_InitStruct. Pin=I2C_SDA_Pin; \
GPIO_InitStruct. Mode=LL_GPIO_MODE_INPUT; \
GPIO_InitStruct. Pull=LL_GPIO_PULL_UP; \
LL_GPIO_Init (GPIOA, & amp; GPIO_InitStruct); \
}

This code all normal, LZ analyze yourself

CodePudding user response:

How can??
  • Related