-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathOpenBCI_Radios_Definitions.h
More file actions
140 lines (116 loc) · 5.24 KB
/
OpenBCI_Radios_Definitions.h
File metadata and controls
140 lines (116 loc) · 5.24 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Name: OpenBCI_Radio_Definitions.h
* Date: 3/15/2016
* Purpose: This is the header file for the OpenBCI radios definitions.
*
* Author: Push The World LLC (AJ Keller)
* Much credit must also go to Joel Murphy who with Conor Russomanno and Leif
* Percifield created the original OpenBCI_32bit_Device.ino and
* OpenBCI_32bit_Host.ino files in the Summer of 2014. Much of this code base
* is inspired directly from their work.
*/
#ifndef __OpenBCI_Radio_Definitions__
#define __OpenBCI_Radio_Definitions__
// These are helpful maximums to reference nad use in the code
#define OPENBCI_MAX_DATA_BYTES_IN_PACKET 31
#define OPENBCI_MAX_PACKET_SIZE_BYTES 32
#define OPENBCI_MAX_PACKET_SIZE_STREAM_BYTES 33
#define OPENBCI_TIMEOUT_PACKET_NRML_uS 500 // The time to wait before determining a multipart packet is ready to be send
#define OPENBCI_TIMEOUT_PACKET_STREAM_uS 88 // Slightly longer than it takes to send a serial byte at 115200
#define OPENBCI_TIMEOUT_PACKET_POLL_MS 48 // Poll time out length for sending null packet from device to host
#define OPENBCI_TIMEOUT_COMMS_MS 270 // Comms failure time out length. Used only by Host.
// Stream byte stuff
#define OPENBCI_STREAM_BYTE_START 0xA0
#define OPENBCI_STREAM_BYTE_STOP 0xC0
// Max buffer lengths
#define OPENBCI_BUFFER_LENGTH_MULTI 528 // 16 * 33
// Number of buffers
#define OPENBCI_NUMBER_RADIO_BUFFERS 1
#define OPENBCI_NUMBER_SERIAL_BUFFERS 16
#define OPENBCI_NUMBER_STREAM_BUFFERS 25 // This should be at least one greater than poll time divided by packet interval to allow for the ack counter.
// These are the three different possible configuration modes for this library
#define OPENBCI_MODE_DEVICE 0
#define OPENBCI_MODE_HOST 1
#define OPENBCI_MODE_PASS_THRU 2
// Pins used by the Device
#define OPENBCI_PIN_DEVICE_PCG 5
// Pins used by the Host
#define OPENBCI_PIN_HOST_LED 2
#define OPENBCI_PIN_HOST_TIME 3
#define OPENBCI_PIN_HOST_RESET 6
// roles for the RFduinoGZLL
#define RFDUINOGZLL_ROLE_HOST HOST
#define RFDUINOGZLL_ROLE_DEVICE DEVICE0
// Channel limits
#define RFDUINOGZLL_CHANNEL_LIMIT_LOWER 0
#define RFDUINOGZLL_CHANNEL_LIMIT_UPPER 25
// flash memory address for RFdunioGZLL
#define RFDUINOGZLL_FLASH_MEM_ADDR 251
// Max number of packets on the TX buffer
#define RFDUINOGZLL_MAX_PACKETS_ON_TX_BUFFER 2
// radio errors
#define ERROR_RADIO_NONE 0x00
#define ERROR_RADIO_RESEND_LAST_PACKET 0x01
#define ERROR_RADIO_RESEND_LAST_PAGE 0x02
// Private Radio communications
// ORPM --> "OpenBCI Radio Private Message"
#define ORPM_INVALID_CODE_RECEIVED 0x00 // The other radio sent a 1 byte message that does not match any
#define ORPM_PACKET_PAGE_REJECT 0x01 // Could not load page
#define ORPM_PACKET_MISSED 0x02 // Missed a packet
#define ORPM_PACKET_INIT 0x03 // Init packet
#define ORPM_DEVICE_SERIAL_OVERFLOW 0x04 // The Device is being overflowed by Pic
#define ORPM_CHANGE_CHANNEL_HOST_REQUEST 0x05 // CCHR
#define ORPM_CHANGE_CHANNEL_DEVICE_READY 0x06 //
#define ORPM_CHANGE_POLL_TIME_HOST_REQUEST 0x07 //
#define ORPM_CHANGE_POLL_TIME_DEVICE_READY 0x08 //
#define ORPM_GET_POLL_TIME 0x09 //
// Used to determine what to send after a proccess out bound buffer
#define ACTION_RADIO_SEND_NONE 0x00
#define ACTION_RADIO_SEND_NORMAL 0x01
#define ACTION_RADIO_SEND_SINGLE_CHAR 0x02
// Used to determine the result of processing a packet
#define OPENBCI_PROCESS_RADIO_FAIL_SWITCH_LAST 0x00
#define OPENBCI_PROCESS_RADIO_FAIL_SWITCH_NOT_LAST 0x01
#define OPENBCI_PROCESS_RADIO_FAIL_MISSED_LAST 0x02
#define OPENBCI_PROCESS_RADIO_FAIL_MISSED_NOT_LAST 0x03
#define OPENBCI_PROCESS_RADIO_PASS_LAST_MULTI 0x04
#define OPENBCI_PROCESS_RADIO_PASS_LAST_SINGLE 0x05
#define OPENBCI_PROCESS_RADIO_PASS_NOT_LAST_FIRST 0x06
#define OPENBCI_PROCESS_RADIO_PASS_NOT_LAST_MIDDLE 0x07
#define OPENBCI_PROCESS_RADIO_PASS_SWITCH_LAST 0x08
#define OPENBCI_PROCESS_RADIO_PASS_SWITCH_NOT_LAST 0x09
// Byte id stuff
#define OPENBCI_BYTE_ID_RESEND 0xFF
// Stream packet EOTs
#define OPENBCI_STREAM_PACKET_HEAD 0x41
#define OPENBCI_STREAM_PACKET_TAIL 0xC0
// Special host codes
#define OPENBCI_HOST_TIME_SYNC '<'
#define OPENBCI_HOST_TIME_SYNC_ACK ','
// Commands
#define OPENBCI_HOST_PRIVATE_CMD_KEY 0xF0
#define OPENBCI_HOST_CMD_CHANNEL_GET 0x00
#define OPENBCI_HOST_CMD_CHANNEL_SET 0x01
#define OPENBCI_HOST_CMD_CHANNEL_SET_OVERIDE 0x02
#define OPENBCI_HOST_CMD_POLL_TIME_GET 0x03
#define OPENBCI_HOST_CMD_POLL_TIME_SET 0x04
#define OPENBCI_HOST_CMD_BAUD_DEFAULT 0x05
#define OPENBCI_HOST_CMD_BAUD_FAST 0x06
#define OPENBCI_HOST_CMD_SYS_UP 0x07
#define OPENBCI_HOST_CMD_TIME_PIN_HIGH 0x08
#define OPENBCI_HOST_CMD_TIME_PIN_LOW 0x09
#define OPENBCI_HOST_CMD_BAUD_HYPER 0x0A
// Raw data packet types/codes
#define OPENBCI_PACKET_TYPE_RAW_AUX = 3; // 0011
#define OPENBCI_PACKET_TYPE_STANDARD = 0; // 0000
#define OPENBCI_PACKET_TYPE_TIME_SYNCED = 1; // 0001
#define OPENBCI_PACKET_TYPE_USER_DEFINED = 2; // 0010
// Possible baud rates
#define OPENBCI_BAUD_RATE_DEFAULT 115200
#define OPENBCI_BAUD_RATE_FAST 230400
#define OPENBCI_BAUD_RATE_HYPER 921600
// Private Radio Places
#define OPENBCI_HOST_PRIVATE_POS_KEY 1
#define OPENBCI_HOST_PRIVATE_POS_CODE 2
#define OPENBCI_HOST_PRIVATE_POS_PAYLOAD 3
#endif