diff options
Diffstat (limited to 'shared/pb')
-rw-r--r-- | shared/pb/driver.c | 2 | ||||
-rw-r--r-- | shared/pb/driver.h | 4 | ||||
-rw-r--r-- | shared/pb/types.h | 12 |
3 files changed, 12 insertions, 6 deletions
diff --git a/shared/pb/driver.c b/shared/pb/driver.c index 2552b61..6b675ca 100644 --- a/shared/pb/driver.c +++ b/shared/pb/driver.c @@ -7,7 +7,7 @@ __weak bool pbdrv_hook_cmd() { __weak void pbdrv_i2c_recv(uint16_t addr, const char * buf, size_t sz) { if (sz == 0) return; - enum pb_cmd cmd = (enum pb_cmd) buf[0]; + pb_cmd_t cmd = (enum pb_cmd) buf[0]; // shift buffer pointer to only contain the puzzle bus message buf buf++; diff --git a/shared/pb/driver.h b/shared/pb/driver.h index 1c9c3a3..b5b2784 100644 --- a/shared/pb/driver.h +++ b/shared/pb/driver.h @@ -13,8 +13,8 @@ extern "C" { void pbdrv_i2c_recv(uint16_t addr, const char * buf, size_t sz); void pbdrv_i2c_send(uint16_t addr, const char * buf, size_t sz); -void pbdrv_hook_state(enum pb_global_state * state, bool rw); -bool pbdrv_hook_cmd(enum pb_cmd cmd, const char * buf, size_t sz); +void pbdrv_hook_state(pb_state_t * state, bool rw); +bool pbdrv_hook_cmd(pb_cmd_t cmd, const char * buf, size_t sz); void pbdrv_handle_read(const char * buf, size_t sz); diff --git a/shared/pb/types.h b/shared/pb/types.h index 8150194..93e2f0c 100644 --- a/shared/pb/types.h +++ b/shared/pb/types.h @@ -24,18 +24,24 @@ extern "C" { * The first byte of a puzzle bus message's data indicates the command type. */ enum __packed pb_cmd { - PB_CMD_READ, //!< read a puzzle module property - PB_CMD_WRITE, //!< write to a puzzle module property + PB_CMD_READ, //!< read a puzzle module property + PB_CMD_WRITE, //!< write to a puzzle module property // PB_CMD_UPDATE, //!< request an update + PB_CMD_MAGIC = 0x69, //!< magic message }; +typedef enum pb_cmd pb_cmd_t; + +static const char pb_magic_msg[] = { 0x70, 0x75, 0x7a, 0x62, 0x75, 0x73 }; +static const char pb_magic_res[] = { 0x67, 0x61, 0x6d, 0x69, 0x6e, 0x67 }; /** \brief Puzzle bus global states */ -enum __packed pb_global_state { +enum __packed pb_state { PB_GS_NOINIT, //!< uninitialized (only used by puzzle modules) PB_GS_IDLE, //!< puzzle not started yet PB_GS_PLAYING, //!< puzzle actively being solved PB_GS_SOLVED, //!< puzzle completed }; +typedef enum pb_state pb_state_t; typedef struct __packed { uint8_t address; |