]> mj.ucw.cz Git - home-hw.git/blob - bsb/firmware/interface.h
BSB: More interface definitions
[home-hw.git] / bsb / firmware / interface.h
1 /*
2  *      Boiler System Bus Gateway -- Interface Definitions
3  *
4  *      (c) 2020 Martin Mareš <mj@ucw.cz>
5  */
6
7 #define BSB_USB_VENDOR 0x4242
8 #define BSB_USB_PRODUCT 0x0003
9 #define BSB_USB_VERSION 0x0100
10
11 // Status sent on the interrupt endpoint
12 enum bsb_tx_result {
13         TX_RESULT_NONE,
14         TX_RESULT_OK,
15         TX_RESULT_OVERRUN,
16         TX_RESULT_MALFORMED,
17         TX_RESULT_FORBIDDEN,
18         TX_RESULT_TIMEOUT,
19         TX_RESULT_TOO_MANY_RETRIES,
20 };
21
22 // Sent via USB in little-endian format
23 struct bsb_stats {
24         u32 rx_noise;
25         u32 rx_errors;
26         u32 rx_invalid;
27         u32 rx_overruns;
28         u32 rx_timeouts;
29         u32 rx_bad_crc;
30         u32 rx_ok;
31         u32 tx_overruns;
32         u32 tx_rejects;
33         u32 tx_timeouts;
34         u32 tx_collisions;
35         u32 tx_ok;
36 };
37
38 /*
39  *      Structure of BSB frames
40  *
41  *              start of frame (0xdc)
42  *              source address XOR 0x80
43  *              destination address
44  *              length
45  *              operation
46  *              <parameters depending on operation>
47  *              16-bit CRC
48  */
49
50 enum bsb_address {
51         BSB_ADDR_BOILER = 0,
52         BSB_ADDR_EXT_BOARD = 3,
53         BSB_ADDR_ROOM1 = 6,
54         BSB_ADDR_ROOM2 = 7,
55         BSB_ADDR_GATEWAY = 0x42,
56         BSB_ADDR_BROADCAST = 0x7f,
57 };
58
59 enum bsb_op {
60         BSB_OP_REQUEST_INFO = 1,
61         BSB_OP_INFO = 2,
62         BSB_OP_SET = 3,
63         BSB_OP_ACK = 4,
64         BSB_OP_NACK = 5,
65         BSB_OP_QUERY = 6,
66         BSB_OP_ANSWER = 7,
67         BSB_OP_ERROR = 8,
68         BSB_OP_QUERY_DEFAULT = 0x0f,
69         BSB_OP_ANSWER_DEFAULT = 0x10,
70 };