This look fine.gpio_pull_up():
gpio_set_pulls(gpio, true, false);
In the C SDK bus_scan.c example, GPIO calls are made to enable the pullups but there are no calls to disable the pulldowns -- this might be the difference versus MicroPython.
Code:
gpio_pull_up(PICO_DEFAULT_I2C_SDA_PIN); gpio_pull_up(PICO_DEFAULT_I2C_SCL_PIN);
Code:
/*! \brief Set specified GPIO to be pulled up. * \ingroup hardware_gpio * * \param gpio GPIO number */static inline void gpio_pull_up(uint gpio) { gpio_set_pulls(gpio, true, false);}
gpio_set_pulls(gpio, true, false);
4.1.10.7.65. gpio_set_pulls
void gpio_set_pulls (uint gpio, bool up, bool down)
Select up and down pulls on specific GPIO.
Parameters
gpio GPIO number
up If true set a pull up on the GPIO
down If true set a pull down on the GPIO
NOTE On the RP2040, setting both pulls enables a "bus keep" function, i.e. a weak pull to whatever is current high/low state of GPIO.
Statistics: Posted by gmx — Fri Mar 28, 2025 7:29 pm