Alex Borisevich
/
OpenBCI
main.cpp@1:4683702d7ad8, 2017-01-22 (annotated)
- Committer:
- akpc806a
- Date:
- Sun Jan 22 04:10:11 2017 +0000
- Revision:
- 1:4683702d7ad8
- Parent:
- 0:2cb59ea20ace
OpenBCI 32bit board variation with STM32L476 mircocontroller and mbed support. Version V2 of firmware, forked from the same official version for the PIC32 board.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akpc806a | 0:2cb59ea20ace | 1 | #include "mbed.h" |
akpc806a | 0:2cb59ea20ace | 2 | |
akpc806a | 0:2cb59ea20ace | 3 | #define USE_PRINTF (1) |
akpc806a | 0:2cb59ea20ace | 4 | |
akpc806a | 0:2cb59ea20ace | 5 | DigitalOut led_blue(PB_5); |
akpc806a | 0:2cb59ea20ace | 6 | |
akpc806a | 0:2cb59ea20ace | 7 | |
akpc806a | 1:4683702d7ad8 | 8 | //#include <DSPI.h> |
akpc806a | 1:4683702d7ad8 | 9 | #include "OpenBCI_32bit_Library.h" |
akpc806a | 1:4683702d7ad8 | 10 | #include "Definitions.h" |
akpc806a | 0:2cb59ea20ace | 11 | |
akpc806a | 1:4683702d7ad8 | 12 | void setup() { |
akpc806a | 1:4683702d7ad8 | 13 | // Bring up the OpenBCI Board |
akpc806a | 1:4683702d7ad8 | 14 | board.begin(); |
akpc806a | 0:2cb59ea20ace | 15 | } |
akpc806a | 0:2cb59ea20ace | 16 | |
akpc806a | 0:2cb59ea20ace | 17 | void loop() { |
akpc806a | 0:2cb59ea20ace | 18 | |
akpc806a | 1:4683702d7ad8 | 19 | if (board.streaming) { |
akpc806a | 1:4683702d7ad8 | 20 | if (board.channelDataAvailable) { |
akpc806a | 1:4683702d7ad8 | 21 | // Read from the ADS(s), store data, set channelDataAvailable flag to false |
akpc806a | 1:4683702d7ad8 | 22 | board.updateChannelData(); |
akpc806a | 0:2cb59ea20ace | 23 | |
akpc806a | 1:4683702d7ad8 | 24 | if (board.timeSynced) { |
akpc806a | 1:4683702d7ad8 | 25 | // Send time synced packet with channel data, current board time, and an accel reading |
akpc806a | 1:4683702d7ad8 | 26 | // X axis is sent on sampleCounter % 10 == 7 |
akpc806a | 1:4683702d7ad8 | 27 | // Y axis is sent on sampleCounter % 10 == 8 |
akpc806a | 1:4683702d7ad8 | 28 | // Z axis is sent on sampleCounter % 10 == 9 |
akpc806a | 1:4683702d7ad8 | 29 | board.sendChannelDataWithTimeAndAccel(); |
akpc806a | 0:2cb59ea20ace | 30 | } else { |
akpc806a | 1:4683702d7ad8 | 31 | // Send standard packet with channel data |
akpc806a | 1:4683702d7ad8 | 32 | board.sendChannelDataWithAccel(); |
akpc806a | 0:2cb59ea20ace | 33 | } |
akpc806a | 1:4683702d7ad8 | 34 | /* |
akpc806a | 1:4683702d7ad8 | 35 | if (board.timeSynced) { |
akpc806a | 1:4683702d7ad8 | 36 | board.sendChannelDataWithTimeAndRawAux(); |
akpc806a | 1:4683702d7ad8 | 37 | } else { |
akpc806a | 1:4683702d7ad8 | 38 | // Send standard packet with channel data |
akpc806a | 1:4683702d7ad8 | 39 | board.sendChannelDataWithRawAux(); |
akpc806a | 1:4683702d7ad8 | 40 | } |
akpc806a | 1:4683702d7ad8 | 41 | */ |
akpc806a | 0:2cb59ea20ace | 42 | } |
akpc806a | 0:2cb59ea20ace | 43 | } |
akpc806a | 1:4683702d7ad8 | 44 | // Check the serial port for new data |
akpc806a | 1:4683702d7ad8 | 45 | if (board.hasDataSerial0()) { |
akpc806a | 1:4683702d7ad8 | 46 | // Read one char and process it |
akpc806a | 1:4683702d7ad8 | 47 | board.processChar(board.getCharSerial0()); |
akpc806a | 0:2cb59ea20ace | 48 | } |
akpc806a | 0:2cb59ea20ace | 49 | } |
akpc806a | 0:2cb59ea20ace | 50 | |
akpc806a | 0:2cb59ea20ace | 51 | |
akpc806a | 0:2cb59ea20ace | 52 | |
akpc806a | 0:2cb59ea20ace | 53 | int main() |
akpc806a | 1:4683702d7ad8 | 54 | { |
akpc806a | 0:2cb59ea20ace | 55 | setup(); |
akpc806a | 0:2cb59ea20ace | 56 | |
akpc806a | 0:2cb59ea20ace | 57 | while (1) loop(); |
akpc806a | 0:2cb59ea20ace | 58 | } |
akpc806a | 0:2cb59ea20ace | 59 |