puzzlebox
Loading...
Searching...
No Matches
pb-types.h
1#pragma once
2
3#include <stdbool.h>
4#include <stddef.h>
5#include <stdint.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
20#ifdef __GNUC__
21#define __weak __attribute__((weak))
22#endif
23#ifndef __weak
24#error Could not determine weak attribute for current compiler
26#define __weak
27#endif
28
30typedef uint16_t i2c_addr_t;
31
64
71
79
85static const char pb_cmd_magic_req[] = {0x70, 0x75, 0x7a, 0x62, 0x75, 0x73};
91static const char pb_cmd_magic_res[] = {0x67, 0x61, 0x6d, 0x69, 0x6e, 0x67};
92
121
123typedef struct {
124 uint8_t propid;
125 uint8_t * value;
126 size_t _value_size;
128
133
135typedef struct {
136 char * magic;
137 size_t _magic_size;
139
141
142#ifdef __cplusplus
143}
144#endif
pb_cmd_id_t
Puzzle bus command types.
Definition pb-types.h:33
pb_action_t
Puzzle bus command action types.
Definition pb-types.h:66
pb_global_state_t
Puzzle module global states.
Definition pb-types.h:73
static const char pb_cmd_magic_req[]
Magic sent from main controller to puzzle module (="puzbus")
Definition pb-types.h:85
static const char pb_cmd_magic_res[]
Magic reply from puzzle module back to main controller (="gaming")
Definition pb-types.h:91
uint16_t i2c_addr_t
I²C address (10 or 7 bit)
Definition pb-types.h:30
@ PB_CMD_MAGIC
magic (handshake) (REQ, RES)
Definition pb-types.h:62
@ PB_CMD_PROP
puzzle module property (REQ, RES, SET)
Definition pb-types.h:42
@ PB_CMD_STATE
puzzle module global state variable (REQ, RES, SET)
Definition pb-types.h:53
@ PB_ACTION_RES
response
Definition pb-types.h:68
@ PB_ACTION_REQ
request
Definition pb-types.h:67
@ PB_ACTION_SET
(over)write
Definition pb-types.h:69
@ PB_GS_SOLVED
puzzle completed
Definition pb-types.h:77
@ PB_GS_IDLE
puzzle not started yet
Definition pb-types.h:75
@ PB_GS_PLAYING
puzzle actively being solved
Definition pb-types.h:76
@ PB_GS_NOINIT
uninitialized (only used by puzzle modules)
Definition pb-types.h:74
PB_CMD_MAGIC data
Definition pb-types.h:135
char * magic
magic value
Definition pb-types.h:136
PB_CMD_PROP data
Definition pb-types.h:123
uint8_t * value
new or current value
Definition pb-types.h:125
uint8_t propid
id of state property
Definition pb-types.h:124
PB_CMD_STATE data
Definition pb-types.h:130
pb_global_state_t state
global state
Definition pb-types.h:131
puzzle bus message header / container (shared by all commands)
Definition pb-types.h:94
void * cmd
Command data (dependent on type)
Definition pb-types.h:119
i2c_addr_t sender
I²C address of sender.
Definition pb-types.h:113
pb_cmd_id_t type
Command type (see pb_cmd_id_t)
Definition pb-types.h:100
pb_action_t action
Command action (see pb_action_t)
Definition pb-types.h:106