WildernessLabs / Netduino_SDK

32 stars 21 forks source link

Porting4_4 - I2C - failure #18

Closed valoni closed 6 years ago

valoni commented 6 years ago

Maybe you could face I2C problem on line

https://github.com/WildernessLabs/Netduino_SDK/blob/Porting4_4/NetMF4_4/DeviceCode/Targets/Native/STM32F4/DeviceCode/STM32F4_I2C/STM32F4_i2c_functions.cpp

cause fail of I2C on some cases // set pins to AF4 and open drain if (STM32F4_I2C_PORT == 2 && STM32F4_I2C_SDA_PIN == 25)//PB9 CPU_GPIO_DisablePin(STM32F4_I2C_SDA_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x93); //AF9 else CPU_GPIO_DisablePin(STM32F4_I2C_SDA_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x43); //AF4

should be replaced with

   CPU_GPIO_DisablePin(STM32F4_I2C_SDA_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x43); //AF4
   CPU_GPIO_DisablePin(STM32F4_I2C_SCL_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x43); //AF4

or maybe for netduino could work also

        if (STM32F4_I2C_PORT == 2 && STM32F4_I2C_SDA_PIN == 25)  //PB9 
        {           
        CPU_GPIO_DisablePin(STM32F4_I2C_SDA_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x93); //AF9
        CPU_GPIO_DisablePin(STM32F4_I2C_SCL_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x93); //AF4
        }
        else
        {
          CPU_GPIO_DisablePin(STM32F4_I2C_SDA_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x43); //AF4
          CPU_GPIO_DisablePin(STM32F4_I2C_SCL_PIN, RESISTOR_PULLUP, 0, (GPIO_ALT_MODE)0x43); //AF4
        }
valoni commented 6 years ago

seems it was corrected now