forked from OpenBCI/OpenBCI_WIFI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenBCI_Wifi.h
77 lines (65 loc) · 1.97 KB
/
OpenBCI_Wifi.h
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
/**
* Name: OpenBCI_Wifi.h
* Date: 8/30/2016
* Purpose: This is the header file for the OpenBCI radios. Let us define two
* over arching paradigms: Host and Device, where:
* Host is connected to PC via USB VCP (FTDI).
* Device is connectedd to uC (PIC32MX250F128B with UDB32-MX2-DIP).
*
* Author: Push The World LLC (AJ Keller)
*/
#ifndef __OpenBCI_Wifi__
#define __OpenBCI_Wifi__
#include <Arduino.h>
#include "OpenBCI_Wifi_Definitions.h"
class OpenBCI_Wifi_Class {
public:
// ENUMS
typedef enum STREAM_STATE {
STREAM_STATE_INIT,
STREAM_STATE_STORING,
STREAM_STATE_TAIL,
STREAM_STATE_READY
};
// STRUCTS
typedef struct {
uint8_t typeByte;
char data[OPENBCI_MAX_PACKET_SIZE_BYTES];
uint8_t bytesIn;
STREAM_STATE state;
} StreamPacketBuffer;
// Functions and Methods
OpenBCI_Wifi_Class();
void begin(void);
void bufferStreamAddChar(StreamPacketBuffer *, char);
boolean bufferStreamAddData(char *);
void bufferStreamFlush(StreamPacketBuffer *);
void bufferStreamFlushBuffers(void);
boolean bufferStreamReadyToSend(StreamPacketBuffer *);
void bufferStreamReset(void);
void bufferStreamReset(StreamPacketBuffer *);
boolean bufferStreamTimeout(void);
byte byteIdGetStreamPacketType(uint8_t);
boolean dataReady(void);
void initialize(void);
void initializeSPISlave(boolean debug);
boolean isATailByte(uint8_t);
byte outputGetStopByteFromByteId(char);
byte xfer(byte);
// Variables
uint8_t packetBuffer[OPENBCI_NUMBER_STREAM_BUFFERS][OPENBCI_MAX_PACKET_SIZE_BYTES];
uint8_t lastChipSelectLevel;
uint8_t bufSpi[WIFI_BUFFER_LENGTH];
uint8_t bufUdp[WIFI_BUFFER_LENGTH];
uint8_t bufferTxPosition;
uint8_t streamPacketBufferHead;
uint8_t streamPacketBufferTail;
unsigned long lastTimeSpiRead;
private:
void initArduino(void);
void initArrays(void);
void initObjects(void);
void initVariables(void);
};
extern OpenBCI_Wifi_Class OpenBCI_Wifi;
#endif // OPENBCI_WIFI_H