-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPI interface.txt
53 lines (39 loc) · 1.66 KB
/
SPI interface.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
SPI interface
=============
This file describes proposed X10 interface over SPI.
Requests and responses share common size and structure.
// Maximum is 31 due to tail size, but RAM restricts it further.
// 24 is reasonable minimum due to extended command full size
// being 22*2+6+62*2=174 bits
#define X10_BITSTREAM_OCTETS 24
typedef struct _x10_bitstream {
uint8_t data[X10_BITSTREAM_OCTETS];
uint8_t tail; // pointer to the bit after the stream
} x10_bitstream_t;
typedef struct _spi_message {
uint8_t rr_code;
uint8_t rr_id;
x10_bitstream_t x10_data;
uint16_t crc16;
} spi_message_t;
#define REQUEST_POLL 0
#define REQUEST_CANCEL 1
#define REQUEST_TRANSMIT 2
#define RESPONSE_SEEN 1
#define RESPONSE_INPROGRESS 2
#define RESPONSE_COMPLETE 3
Note that when SPI is not working, host will likely receive 0xFF in response.
The module will transmit 0xFE when it's busy.
A request should be sent from host to module until the host receive
ack for this request (code 1, 2 or 3). Module checks incoming request's
integrity using CRC. Then the request is dispatched to processing.
If it's ID is equal to the ID of last request, the request is ignored.
If ID is different, then it is a new request.
If there is a request in progress, then the new 'TRANSMIT' request is
postponed, though response code 'SEEN' is sent. This allows for chaining
several X10 transmissions seamlessly.
'POLL' request is receive-only transaction. All of transmitted message,
excluding the rr_code, is ignored by module.
All other requests will overwrite and replace a postponed request, if any.
'CANCEL' request not only overwrites any postponed request, but also
interrupts any ongoing transmission.