2008-07-02 04:54 AM
2011-05-17 12:54 AM
Hi,
I'm after some clarification on the correct configuration of GPIO pins when used for I2C. I see from the doc'n that each I2C pin (Clock & Data) has both an IN and an OUT (via alternative input/output settings). Does this mean, for example, that for a Master the CLK pin remains as an output, but the Data pin needs to be re-configured to be an input during a read cycle- or will the following work? // Configure I2C1 as Master on port 2 vl_GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; vl_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; vl_GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector ; vl_GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable; vl_GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2; GPIO_Init (GPIO2, &vl_GPIO_InitStructure); Presumably, the required GPIO configuration for Master and Slave I2C ports are different...? Thanks Dave