Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5077

SDK • I2C ssd1306 example

$
0
0
I must be doing something wrong, but I'm not seeing it.

I have the ssd1306 example working, but only when I redefine PICO_DEFAULT_I2C.

I'm showing only the bits I changed. This code works:

Code:

#ifdef PICO_DEFAULT_I2C    #undef PICO_DEFAULT_I2C    #define PICO_DEFAULT_I2C 1#endif#define PICO_I2C_SDA_PIN 14#define PICO_I2C_SCL_PIN 15...i2c_init(i2c1, SSD1306_I2C_CLK * 1000);gpio_set_function(PICO_I2C_SDA_PIN, GPIO_FUNC_I2C);gpio_set_function(PICO_I2C_SCL_PIN, GPIO_FUNC_I2C);gpio_pull_up(PICO_I2C_SDA_PIN);gpio_pull_up(PICO_I2C_SCL_PIN);
But if I remove the undef/define for PICO_DEFAULT_I2C, the code will compile but not work at all. I don't understand, since the code doesn't use PICO_DEFAULT_I2C anywhere and only appears to be defined in the board definitions. The default port for my Pico is i2c0 and I'm using i2c1.

Statistics: Posted by Mike**K — Wed Dec 25, 2024 8:46 pm



Viewing all articles
Browse latest Browse all 5077

Trending Articles