26 lines
520 B
C++
26 lines
520 B
C++
#include "hardware/i2c.h"
|
|
#include "pico/stdlib.h"
|
|
#include <cstdio>
|
|
|
|
void check_i2c() {
|
|
uint8_t buffer;
|
|
for (int addr{0x08}; addr < 0x78; addr++) {
|
|
if (i2c_read_blocking(i2c0, addr, &buffer, 1, false) > 0) {
|
|
printf("Adresse: %02X\n", addr);
|
|
}
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
sleep_ms(3000);
|
|
stdio_init_all();
|
|
i2c_init(i2c0, 400 * 1000);
|
|
gpio_set_function(0, GPIO_FUNC_I2C); // SDA
|
|
gpio_set_function(1, GPIO_FUNC_I2C); // SCL
|
|
gpio_pull_up(0);
|
|
gpio_pull_up(1);
|
|
while (true) {
|
|
check_i2c();
|
|
}
|
|
}
|