aboutsummaryrefslogtreecommitdiff
path: root/main/i2c.c
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-18 19:29:05 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-18 19:29:05 +0200
commitcc9b3beb1e82449e34dc3d7052395607fe12b47f (patch)
treef16258fd34abc8bda8ba9c491cd3552381a0fbe8 /main/i2c.c
parent752dca0a41581282498ccb0d3e2aedb15181e4a8 (diff)
WIP puzzle module <-> main controller <-> client communication
Diffstat (limited to 'main/i2c.c')
-rw-r--r--main/i2c.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/main/i2c.c b/main/i2c.c
index 612075b..2503560 100644
--- a/main/i2c.c
+++ b/main/i2c.c
@@ -10,13 +10,35 @@
#include "pb-mod.h"
#include "pbdrv.h"
#include "config.h"
+#include "pb-buf.h"
+#include "pb-send.h"
i2c_addr_t modules[CFG_PB_MOD_MAX];
size_t modules_size = 0;
+static void state_exchange() {
+ for (size_t i = 0; i < modules_size; i++) {
+ pb_buf_t buf = pb_send_state_req();
+
+ pb_buf_free(&buf);
+ }
+}
+
void bus_task() {
+ // do a scan of the bus
bus_scan();
- vTaskDelete(NULL);
+
+ // FIXME: this should be removed (see handover: RP2040 I2C limitations)
+ // wait for 5 seconds until all handshake responses are received
+ pb_mod_blocking_delay_ms(5e3);
+
+ while(1) {
+ // send my state to all puzzle modules
+ state_exchange();
+
+ // wait 1 second
+ pb_mod_blocking_delay_ms(1e3);
+ }
}
void pb_route_cmd_magic_res(pb_msg_t * msg) {