Karpova Lab fork of stateScript

Dependencies:   SMARTWAV SOMO_II mbed

Fork of stateScript_v2_karpova by Andy Lustig

Committer:
mkarlsso
Date:
Fri Jan 15 22:13:23 2016 +0000
Revision:
5:abee20c0bf2a
Parent:
3:d7b0a0890d96
Child:
8:436cf2ab961c
Fixed an issue where syntax errors caused the program to crash instead of just reporting the syntax error.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mkarlsso 0:8dbd6bd9167f 1 #ifndef MBEDINTERFACE_H
mkarlsso 0:8dbd6bd9167f 2 #define MBEDINTERFACE_H
mkarlsso 0:8dbd6bd9167f 3
mkarlsso 0:8dbd6bd9167f 4 #include "hardwareInterface.h"
mkarlsso 0:8dbd6bd9167f 5 #include "mbed.h"
mkarlsso 0:8dbd6bd9167f 6 #include <stdint.h>
mkarlsso 0:8dbd6bd9167f 7 #include "SMARTWAV.h"
mkarlsso 0:8dbd6bd9167f 8 #include <string.h>
mkarlsso 0:8dbd6bd9167f 9 #include <string>
mkarlsso 0:8dbd6bd9167f 10 #include <vector>
mkarlsso 0:8dbd6bd9167f 11 #include <queue>
mkarlsso 0:8dbd6bd9167f 12 #include <sstream>
mkarlsso 0:8dbd6bd9167f 13
mkarlsso 0:8dbd6bd9167f 14
mkarlsso 0:8dbd6bd9167f 15 //#define MBED_RF
mkarlsso 0:8dbd6bd9167f 16
mkarlsso 0:8dbd6bd9167f 17
mkarlsso 5:abee20c0bf2a 18 #define NUMPORTS 10 //the number of ports available on this hardware
mkarlsso 5:abee20c0bf2a 19 #define NUMINPORTS 9
mkarlsso 5:abee20c0bf2a 20 #define NUMOUTPORTS 10
mkarlsso 0:8dbd6bd9167f 21
mkarlsso 3:d7b0a0890d96 22 #define NUMEVENTS 50
mkarlsso 3:d7b0a0890d96 23 #define NUMCONDITIONS 150
mkarlsso 3:d7b0a0890d96 24 #define NUMINTCOMPARE 150
mkarlsso 3:d7b0a0890d96 25 #define NUMACTIONS 150
mkarlsso 3:d7b0a0890d96 26 #define NUMPORTMESSAGES 150
mkarlsso 3:d7b0a0890d96 27 #define NUMINTOPERATIONS 150
mkarlsso 3:d7b0a0890d96 28 #define NUMDISPLAYACTIONS 30
mkarlsso 3:d7b0a0890d96 29 #define NUMTRIGGERACTIONS 30
mkarlsso 3:d7b0a0890d96 30 #define NUMFUNCTIONS 50
mkarlsso 3:d7b0a0890d96 31 #define INPUTCHARBUFFERSIZE 3072
mkarlsso 3:d7b0a0890d96 32
mkarlsso 0:8dbd6bd9167f 33
mkarlsso 0:8dbd6bd9167f 34
mkarlsso 0:8dbd6bd9167f 35 /*
mkarlsso 0:8dbd6bd9167f 36 class MBEDTimer : public sTimer
mkarlsso 0:8dbd6bd9167f 37 {
mkarlsso 0:8dbd6bd9167f 38 public:
mkarlsso 0:8dbd6bd9167f 39 sTimer();
mkarlsso 0:8dbd6bd9167f 40 virtual void init() = 0;
mkarlsso 0:8dbd6bd9167f 41 virtual void timeout_callback() = 0;
mkarlsso 0:8dbd6bd9167f 42
mkarlsso 0:8dbd6bd9167f 43 };
mkarlsso 0:8dbd6bd9167f 44
mkarlsso 0:8dbd6bd9167f 45 class MBEDExternalSync : public sExternalSync
mkarlsso 0:8dbd6bd9167f 46 {
mkarlsso 0:8dbd6bd9167f 47 public:
mkarlsso 0:8dbd6bd9167f 48 MBEDExternalSync();
mkarlsso 0:8dbd6bd9167f 49 void init();
mkarlsso 0:8dbd6bd9167f 50 void interrupt_callback();
mkarlsso 0:8dbd6bd9167f 51 void reset_callback();
mkarlsso 0:8dbd6bd9167f 52
mkarlsso 0:8dbd6bd9167f 53 };*/
mkarlsso 0:8dbd6bd9167f 54
mkarlsso 0:8dbd6bd9167f 55
mkarlsso 0:8dbd6bd9167f 56
mkarlsso 0:8dbd6bd9167f 57 class MBEDDigitalOut : public sDigitalOut
mkarlsso 0:8dbd6bd9167f 58 {
mkarlsso 0:8dbd6bd9167f 59 public:
mkarlsso 0:8dbd6bd9167f 60 MBEDDigitalOut();
mkarlsso 0:8dbd6bd9167f 61
mkarlsso 0:8dbd6bd9167f 62 void init(int pin);
mkarlsso 0:8dbd6bd9167f 63 void write(int value);
mkarlsso 0:8dbd6bd9167f 64 int read();
mkarlsso 0:8dbd6bd9167f 65
mkarlsso 0:8dbd6bd9167f 66 private:
mkarlsso 0:8dbd6bd9167f 67 DigitalOut *outpin;
mkarlsso 5:abee20c0bf2a 68 bool pinExists;
mkarlsso 0:8dbd6bd9167f 69
mkarlsso 0:8dbd6bd9167f 70 };
mkarlsso 0:8dbd6bd9167f 71
mkarlsso 0:8dbd6bd9167f 72 class MBEDDigitalIn : public sDigitalIn
mkarlsso 0:8dbd6bd9167f 73 {
mkarlsso 0:8dbd6bd9167f 74 public:
mkarlsso 0:8dbd6bd9167f 75 MBEDDigitalIn();
mkarlsso 0:8dbd6bd9167f 76
mkarlsso 0:8dbd6bd9167f 77 void init(int pin);
mkarlsso 0:8dbd6bd9167f 78 int read();
mkarlsso 0:8dbd6bd9167f 79 void interrupt_up_callback();
mkarlsso 0:8dbd6bd9167f 80 void interrupt_down_callback();
mkarlsso 0:8dbd6bd9167f 81 protected:
mkarlsso 3:d7b0a0890d96 82
mkarlsso 3:d7b0a0890d96 83
mkarlsso 0:8dbd6bd9167f 84
mkarlsso 0:8dbd6bd9167f 85 private:
mkarlsso 0:8dbd6bd9167f 86 DigitalIn *inpin;
mkarlsso 0:8dbd6bd9167f 87 InterruptIn *inpin_interrupt;
mkarlsso 5:abee20c0bf2a 88 bool pinExists;
mkarlsso 0:8dbd6bd9167f 89
mkarlsso 0:8dbd6bd9167f 90 };
mkarlsso 0:8dbd6bd9167f 91
mkarlsso 0:8dbd6bd9167f 92 class MBEDSerialPort : public sSerialPort
mkarlsso 0:8dbd6bd9167f 93 {
mkarlsso 0:8dbd6bd9167f 94 public:
mkarlsso 0:8dbd6bd9167f 95 MBEDSerialPort();
mkarlsso 0:8dbd6bd9167f 96
mkarlsso 0:8dbd6bd9167f 97 void init();
mkarlsso 0:8dbd6bd9167f 98 bool readable();
mkarlsso 0:8dbd6bd9167f 99 char readChar();
mkarlsso 0:8dbd6bd9167f 100 void writeChar(char s);
mkarlsso 3:d7b0a0890d96 101 int requestToWriteString(char *s, int numBytes);
mkarlsso 0:8dbd6bd9167f 102 Serial *serialToPC;
mkarlsso 0:8dbd6bd9167f 103
mkarlsso 0:8dbd6bd9167f 104 private:
mkarlsso 0:8dbd6bd9167f 105 //Serial communication
mkarlsso 3:d7b0a0890d96 106
mkarlsso 0:8dbd6bd9167f 107
mkarlsso 0:8dbd6bd9167f 108 };
mkarlsso 0:8dbd6bd9167f 109
mkarlsso 0:8dbd6bd9167f 110 class MBEDSound: public sSound
mkarlsso 0:8dbd6bd9167f 111 {
mkarlsso 0:8dbd6bd9167f 112 public:
mkarlsso 0:8dbd6bd9167f 113 MBEDSound();
mkarlsso 0:8dbd6bd9167f 114 void execute();
mkarlsso 0:8dbd6bd9167f 115
mkarlsso 0:8dbd6bd9167f 116 private:
mkarlsso 0:8dbd6bd9167f 117
mkarlsso 0:8dbd6bd9167f 118 };
mkarlsso 0:8dbd6bd9167f 119
mkarlsso 0:8dbd6bd9167f 120 class MBEDSystem: public sSystem
mkarlsso 0:8dbd6bd9167f 121 {
mkarlsso 0:8dbd6bd9167f 122 public:
mkarlsso 0:8dbd6bd9167f 123 MBEDSystem();
mkarlsso 0:8dbd6bd9167f 124 void timerinit();
mkarlsso 0:8dbd6bd9167f 125 void setStandAloneClock();
mkarlsso 0:8dbd6bd9167f 126 void setSlaveClock();
mkarlsso 0:8dbd6bd9167f 127 sDigitalOut* getDigitalOutPtr(int portNum);
mkarlsso 0:8dbd6bd9167f 128 sDigitalIn* getDigitalInPtr(int portNum);
mkarlsso 0:8dbd6bd9167f 129 sSound* createNewSoundAction();
mkarlsso 3:d7b0a0890d96 130 void pauseInterrupts();
mkarlsso 3:d7b0a0890d96 131 void resumeInterrupts();
mkarlsso 0:8dbd6bd9167f 132 void incrementClock();
mkarlsso 0:8dbd6bd9167f 133 void externalClockReset(); //needs to reset harware timer before calling immediateClockReset();
mkarlsso 0:8dbd6bd9167f 134 void mainLoopToDo();
mkarlsso 3:d7b0a0890d96 135
mkarlsso 0:8dbd6bd9167f 136 protected:
mkarlsso 3:d7b0a0890d96 137
mkarlsso 0:8dbd6bd9167f 138 //Pins for clock syncing
mkarlsso 0:8dbd6bd9167f 139 InterruptIn clockResetInt;
mkarlsso 0:8dbd6bd9167f 140 InterruptIn clockExternalIncrement;
mkarlsso 3:d7b0a0890d96 141
mkarlsso 0:8dbd6bd9167f 142 private:
mkarlsso 0:8dbd6bd9167f 143 MBEDDigitalIn dIn[NUMPORTS];
mkarlsso 0:8dbd6bd9167f 144 MBEDDigitalOut dOut[NUMPORTS];
mkarlsso 0:8dbd6bd9167f 145 };
mkarlsso 0:8dbd6bd9167f 146
mkarlsso 0:8dbd6bd9167f 147 #endif // MBEDINTERFACE_H