aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-24 09:45:15 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-24 09:45:15 +0200
commit3e7765dd54706eb927b653d1ed8fa03a1f288c88 (patch)
treee4d30b24ba91a3740b9cfc35caa749637ae4c5ed
parent2528775b34f9c0033027931385a4de866ab2749d (diff)
ignore some addresses in bus scan
-rw-r--r--main/i2c.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/main/i2c.c b/main/i2c.c
index 87c8161..2237b4d 100644
--- a/main/i2c.c
+++ b/main/i2c.c
@@ -12,6 +12,9 @@
#include "pb-buf.h"
#include "pb-send.h"
+// stolen from lib/pico-sdk/src/rp2_common/hardware_i2c/i2c.c
+#define i2c_reserved_addr(addr) (((addr) & 0x78) == 0 || ((addr) & 0x78) == 0x78)
+
i2c_addr_t modules[CFG_PB_MOD_MAX];
size_t modules_size = 0;
@@ -21,6 +24,9 @@ static void bus_scan() {
// check for all 7-bit addresses
uint16_t addr_max = 1 << 7;
for (uint16_t addr = 0x00; addr < addr_max; addr++) {
+ if (i2c_reserved_addr(addr)) continue;
+ if (addr == PB_MOD_ADDR) continue;
+
pb_i2c_send(addr, (uint8_t *) buf.data, buf.size);
}