Karpova Lab fork of stateScript
Dependencies: SMARTWAV SOMO_II mbed
Fork of stateScript_v2_karpova by
mbedInterface/mbedInterface.h@3:d7b0a0890d96, 2015-10-10 (annotated)
- Committer:
- mkarlsso
- Date:
- Sat Oct 10 22:37:17 2015 +0000
- Revision:
- 3:d7b0a0890d96
- Parent:
- 0:8dbd6bd9167f
- Child:
- 5:abee20c0bf2a
Changes ports for new PCB board
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:8dbd6bd9167f | 18 | #define NUMPORTS 9 //the number of ports available on this hardware |
mkarlsso | 0:8dbd6bd9167f | 19 | |
mkarlsso | 3:d7b0a0890d96 | 20 | #define NUMEVENTS 50 |
mkarlsso | 3:d7b0a0890d96 | 21 | #define NUMCONDITIONS 150 |
mkarlsso | 3:d7b0a0890d96 | 22 | #define NUMINTCOMPARE 150 |
mkarlsso | 3:d7b0a0890d96 | 23 | #define NUMACTIONS 150 |
mkarlsso | 3:d7b0a0890d96 | 24 | #define NUMPORTMESSAGES 150 |
mkarlsso | 3:d7b0a0890d96 | 25 | #define NUMINTOPERATIONS 150 |
mkarlsso | 3:d7b0a0890d96 | 26 | #define NUMDISPLAYACTIONS 30 |
mkarlsso | 3:d7b0a0890d96 | 27 | #define NUMTRIGGERACTIONS 30 |
mkarlsso | 3:d7b0a0890d96 | 28 | #define NUMFUNCTIONS 50 |
mkarlsso | 3:d7b0a0890d96 | 29 | #define INPUTCHARBUFFERSIZE 3072 |
mkarlsso | 3:d7b0a0890d96 | 30 | |
mkarlsso | 0:8dbd6bd9167f | 31 | |
mkarlsso | 0:8dbd6bd9167f | 32 | |
mkarlsso | 0:8dbd6bd9167f | 33 | /* |
mkarlsso | 0:8dbd6bd9167f | 34 | class MBEDTimer : public sTimer |
mkarlsso | 0:8dbd6bd9167f | 35 | { |
mkarlsso | 0:8dbd6bd9167f | 36 | public: |
mkarlsso | 0:8dbd6bd9167f | 37 | sTimer(); |
mkarlsso | 0:8dbd6bd9167f | 38 | virtual void init() = 0; |
mkarlsso | 0:8dbd6bd9167f | 39 | virtual void timeout_callback() = 0; |
mkarlsso | 0:8dbd6bd9167f | 40 | |
mkarlsso | 0:8dbd6bd9167f | 41 | }; |
mkarlsso | 0:8dbd6bd9167f | 42 | |
mkarlsso | 0:8dbd6bd9167f | 43 | class MBEDExternalSync : public sExternalSync |
mkarlsso | 0:8dbd6bd9167f | 44 | { |
mkarlsso | 0:8dbd6bd9167f | 45 | public: |
mkarlsso | 0:8dbd6bd9167f | 46 | MBEDExternalSync(); |
mkarlsso | 0:8dbd6bd9167f | 47 | void init(); |
mkarlsso | 0:8dbd6bd9167f | 48 | void interrupt_callback(); |
mkarlsso | 0:8dbd6bd9167f | 49 | void reset_callback(); |
mkarlsso | 0:8dbd6bd9167f | 50 | |
mkarlsso | 0:8dbd6bd9167f | 51 | };*/ |
mkarlsso | 0:8dbd6bd9167f | 52 | |
mkarlsso | 0:8dbd6bd9167f | 53 | |
mkarlsso | 0:8dbd6bd9167f | 54 | |
mkarlsso | 0:8dbd6bd9167f | 55 | class MBEDDigitalOut : public sDigitalOut |
mkarlsso | 0:8dbd6bd9167f | 56 | { |
mkarlsso | 0:8dbd6bd9167f | 57 | public: |
mkarlsso | 0:8dbd6bd9167f | 58 | MBEDDigitalOut(); |
mkarlsso | 0:8dbd6bd9167f | 59 | |
mkarlsso | 0:8dbd6bd9167f | 60 | void init(int pin); |
mkarlsso | 0:8dbd6bd9167f | 61 | void write(int value); |
mkarlsso | 0:8dbd6bd9167f | 62 | int read(); |
mkarlsso | 0:8dbd6bd9167f | 63 | |
mkarlsso | 0:8dbd6bd9167f | 64 | private: |
mkarlsso | 0:8dbd6bd9167f | 65 | DigitalOut *outpin; |
mkarlsso | 0:8dbd6bd9167f | 66 | |
mkarlsso | 0:8dbd6bd9167f | 67 | }; |
mkarlsso | 0:8dbd6bd9167f | 68 | |
mkarlsso | 0:8dbd6bd9167f | 69 | class MBEDDigitalIn : public sDigitalIn |
mkarlsso | 0:8dbd6bd9167f | 70 | { |
mkarlsso | 0:8dbd6bd9167f | 71 | public: |
mkarlsso | 0:8dbd6bd9167f | 72 | MBEDDigitalIn(); |
mkarlsso | 0:8dbd6bd9167f | 73 | |
mkarlsso | 0:8dbd6bd9167f | 74 | void init(int pin); |
mkarlsso | 0:8dbd6bd9167f | 75 | int read(); |
mkarlsso | 0:8dbd6bd9167f | 76 | void interrupt_up_callback(); |
mkarlsso | 0:8dbd6bd9167f | 77 | void interrupt_down_callback(); |
mkarlsso | 0:8dbd6bd9167f | 78 | protected: |
mkarlsso | 3:d7b0a0890d96 | 79 | |
mkarlsso | 3:d7b0a0890d96 | 80 | |
mkarlsso | 0:8dbd6bd9167f | 81 | |
mkarlsso | 0:8dbd6bd9167f | 82 | private: |
mkarlsso | 0:8dbd6bd9167f | 83 | DigitalIn *inpin; |
mkarlsso | 0:8dbd6bd9167f | 84 | InterruptIn *inpin_interrupt; |
mkarlsso | 0:8dbd6bd9167f | 85 | |
mkarlsso | 0:8dbd6bd9167f | 86 | }; |
mkarlsso | 0:8dbd6bd9167f | 87 | |
mkarlsso | 0:8dbd6bd9167f | 88 | class MBEDSerialPort : public sSerialPort |
mkarlsso | 0:8dbd6bd9167f | 89 | { |
mkarlsso | 0:8dbd6bd9167f | 90 | public: |
mkarlsso | 0:8dbd6bd9167f | 91 | MBEDSerialPort(); |
mkarlsso | 0:8dbd6bd9167f | 92 | |
mkarlsso | 0:8dbd6bd9167f | 93 | void init(); |
mkarlsso | 0:8dbd6bd9167f | 94 | bool readable(); |
mkarlsso | 0:8dbd6bd9167f | 95 | char readChar(); |
mkarlsso | 0:8dbd6bd9167f | 96 | void writeChar(char s); |
mkarlsso | 3:d7b0a0890d96 | 97 | int requestToWriteString(char *s, int numBytes); |
mkarlsso | 0:8dbd6bd9167f | 98 | Serial *serialToPC; |
mkarlsso | 0:8dbd6bd9167f | 99 | |
mkarlsso | 0:8dbd6bd9167f | 100 | private: |
mkarlsso | 0:8dbd6bd9167f | 101 | //Serial communication |
mkarlsso | 3:d7b0a0890d96 | 102 | |
mkarlsso | 0:8dbd6bd9167f | 103 | |
mkarlsso | 0:8dbd6bd9167f | 104 | }; |
mkarlsso | 0:8dbd6bd9167f | 105 | |
mkarlsso | 0:8dbd6bd9167f | 106 | class MBEDSound: public sSound |
mkarlsso | 0:8dbd6bd9167f | 107 | { |
mkarlsso | 0:8dbd6bd9167f | 108 | public: |
mkarlsso | 0:8dbd6bd9167f | 109 | MBEDSound(); |
mkarlsso | 0:8dbd6bd9167f | 110 | void execute(); |
mkarlsso | 0:8dbd6bd9167f | 111 | |
mkarlsso | 0:8dbd6bd9167f | 112 | private: |
mkarlsso | 0:8dbd6bd9167f | 113 | |
mkarlsso | 0:8dbd6bd9167f | 114 | }; |
mkarlsso | 0:8dbd6bd9167f | 115 | |
mkarlsso | 0:8dbd6bd9167f | 116 | class MBEDSystem: public sSystem |
mkarlsso | 0:8dbd6bd9167f | 117 | { |
mkarlsso | 0:8dbd6bd9167f | 118 | public: |
mkarlsso | 0:8dbd6bd9167f | 119 | MBEDSystem(); |
mkarlsso | 0:8dbd6bd9167f | 120 | void timerinit(); |
mkarlsso | 0:8dbd6bd9167f | 121 | void setStandAloneClock(); |
mkarlsso | 0:8dbd6bd9167f | 122 | void setSlaveClock(); |
mkarlsso | 0:8dbd6bd9167f | 123 | sDigitalOut* getDigitalOutPtr(int portNum); |
mkarlsso | 0:8dbd6bd9167f | 124 | sDigitalIn* getDigitalInPtr(int portNum); |
mkarlsso | 0:8dbd6bd9167f | 125 | sSound* createNewSoundAction(); |
mkarlsso | 3:d7b0a0890d96 | 126 | void pauseInterrupts(); |
mkarlsso | 3:d7b0a0890d96 | 127 | void resumeInterrupts(); |
mkarlsso | 0:8dbd6bd9167f | 128 | void incrementClock(); |
mkarlsso | 0:8dbd6bd9167f | 129 | void externalClockReset(); //needs to reset harware timer before calling immediateClockReset(); |
mkarlsso | 0:8dbd6bd9167f | 130 | void mainLoopToDo(); |
mkarlsso | 3:d7b0a0890d96 | 131 | |
mkarlsso | 0:8dbd6bd9167f | 132 | protected: |
mkarlsso | 3:d7b0a0890d96 | 133 | |
mkarlsso | 0:8dbd6bd9167f | 134 | //Pins for clock syncing |
mkarlsso | 0:8dbd6bd9167f | 135 | InterruptIn clockResetInt; |
mkarlsso | 0:8dbd6bd9167f | 136 | InterruptIn clockExternalIncrement; |
mkarlsso | 3:d7b0a0890d96 | 137 | |
mkarlsso | 0:8dbd6bd9167f | 138 | private: |
mkarlsso | 0:8dbd6bd9167f | 139 | MBEDDigitalIn dIn[NUMPORTS]; |
mkarlsso | 0:8dbd6bd9167f | 140 | MBEDDigitalOut dOut[NUMPORTS]; |
mkarlsso | 0:8dbd6bd9167f | 141 | }; |
mkarlsso | 0:8dbd6bd9167f | 142 | |
mkarlsso | 0:8dbd6bd9167f | 143 | #endif // MBEDINTERFACE_H |