diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-25 13:44:32 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-06-25 13:44:32 +0200 |
commit | f3e72c6e339eedc4ffac3a2f32cf6cbae7305ff0 (patch) | |
tree | 1828261839f17cfc7ed9b6564039d84fd7f37949 | |
parent | cf55157e92ff82b96527bbb474b3a7df6abf6ac1 (diff) |
pbdrv mod main stuff (???)
-rw-r--r-- | lib/pbdrv/mod/main.h | 13 | ||||
-rw-r--r-- | lib/pbdrv/mod/main/pb-mod-main.h | 13 | ||||
-rw-r--r-- | lib/pbdrv/pb-types.h | 6 | ||||
-rw-r--r-- | main/i2c.c | 13 |
4 files changed, 23 insertions, 22 deletions
diff --git a/lib/pbdrv/mod/main.h b/lib/pbdrv/mod/main.h deleted file mode 100644 index ec48acd..0000000 --- a/lib/pbdrv/mod/main.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "../pb-types.h" - -typedef struct { - const i2c_addr_t mod_addr; - const pb_global_state_t mod_state; -} pb_mod_main_mod_t; - -enum { - PB_MOD_MAIN_ADDR_MODS = 0x01, //!< connected puzzle modules -}; - diff --git a/lib/pbdrv/mod/main/pb-mod-main.h b/lib/pbdrv/mod/main/pb-mod-main.h new file mode 100644 index 0000000..9c69c1d --- /dev/null +++ b/lib/pbdrv/mod/main/pb-mod-main.h @@ -0,0 +1,13 @@ +#pragma once + +#include "../../pb-types.h" + +typedef struct { + i2c_addr_t mod_addr; + pb_global_state_t mod_state; +} pb_mod_main_prop_mod_t; + +enum { + PB_MOD_MAIN_PROP_MODS = 0x00, //!< structured list of connected puzzle modules +}; + diff --git a/lib/pbdrv/pb-types.h b/lib/pbdrv/pb-types.h index 44b590b..ef3df54 100644 --- a/lib/pbdrv/pb-types.h +++ b/lib/pbdrv/pb-types.h @@ -131,12 +131,6 @@ typedef struct { pb_global_state_t state; //!< global state } pb_cmd_state_t; -//! PB_MOD_STATE data -typedef struct { - i2c_addr_t sender; //!< i2c address of sender - pb_global_state_t state; //!< global state -} pb_puzzle_module_t; - //! \ref PB_CMD_MAGIC data typedef struct { char * magic; //!< magic value @@ -12,8 +12,13 @@ #include "pb-buf.h" #include "pb-send.h" +typedef struct { + i2c_addr_t sender; //!< I2C address of sender + pb_global_state_t state; //!< global state +} puzzle_module_t; + static pb_global_state_t _global_state = PB_GS_IDLE; -pb_puzzle_module_t modules[CFG_PB_MOD_MAX]; +puzzle_module_t modules[CFG_PB_MOD_MAX]; // stolen from lib/pico-sdk/src/rp2_common/hardware_i2c/i2c.c #define i2c_reserved_addr(addr) (((addr) & 0x78) == 0 || ((addr) & 0x78) == 0x78) size_t modules_size = 0; @@ -100,8 +105,10 @@ void bus_task() { */ void pb_route_cmd_magic_res(pb_msg_t * msg) { if (modules_size == CFG_PB_MOD_MAX) return; - pb_puzzle_module_t tmp_module = {msg->sender, PB_GS_NOINIT}; - modules[modules_size++] = tmp_module; + modules[modules_size++] = (puzzle_module_t) { + .sender = msg->sender, + .state = PB_GS_NOINIT, + }; printf("i2c: registered puzzle module w/ address 0x%02x\n", msg->sender); } |