Karpova Lab fork of stateScript
Dependencies: SMARTWAV SOMO_II mbed
Fork of stateScript_v2_karpova by
mbedInterface/mbedInterface.h@1:3a050d26d4f6, 2015-06-03 (annotated)
- Committer:
- mkarlsso
- Date:
- Wed Jun 03 22:54:25 2015 +0000
- Revision:
- 1:3a050d26d4f6
- Parent:
- 0:8dbd6bd9167f
fixing digital in interrupt pausing during update. Not a working version.
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 | 0:8dbd6bd9167f | 20 | |
mkarlsso | 0:8dbd6bd9167f | 21 | |
mkarlsso | 0:8dbd6bd9167f | 22 | /* |
mkarlsso | 0:8dbd6bd9167f | 23 | class MBEDTimer : public sTimer |
mkarlsso | 0:8dbd6bd9167f | 24 | { |
mkarlsso | 0:8dbd6bd9167f | 25 | public: |
mkarlsso | 0:8dbd6bd9167f | 26 | sTimer(); |
mkarlsso | 0:8dbd6bd9167f | 27 | virtual void init() = 0; |
mkarlsso | 0:8dbd6bd9167f | 28 | virtual void timeout_callback() = 0; |
mkarlsso | 0:8dbd6bd9167f | 29 | |
mkarlsso | 0:8dbd6bd9167f | 30 | }; |
mkarlsso | 0:8dbd6bd9167f | 31 | |
mkarlsso | 0:8dbd6bd9167f | 32 | class MBEDExternalSync : public sExternalSync |
mkarlsso | 0:8dbd6bd9167f | 33 | { |
mkarlsso | 0:8dbd6bd9167f | 34 | public: |
mkarlsso | 0:8dbd6bd9167f | 35 | MBEDExternalSync(); |
mkarlsso | 0:8dbd6bd9167f | 36 | void init(); |
mkarlsso | 0:8dbd6bd9167f | 37 | void interrupt_callback(); |
mkarlsso | 0:8dbd6bd9167f | 38 | void reset_callback(); |
mkarlsso | 0:8dbd6bd9167f | 39 | |
mkarlsso | 0:8dbd6bd9167f | 40 | };*/ |
mkarlsso | 0:8dbd6bd9167f | 41 | |
mkarlsso | 0:8dbd6bd9167f | 42 | |
mkarlsso | 0:8dbd6bd9167f | 43 | |
mkarlsso | 0:8dbd6bd9167f | 44 | class MBEDDigitalOut : public sDigitalOut |
mkarlsso | 0:8dbd6bd9167f | 45 | { |
mkarlsso | 0:8dbd6bd9167f | 46 | public: |
mkarlsso | 0:8dbd6bd9167f | 47 | MBEDDigitalOut(); |
mkarlsso | 0:8dbd6bd9167f | 48 | |
mkarlsso | 0:8dbd6bd9167f | 49 | void init(int pin); |
mkarlsso | 0:8dbd6bd9167f | 50 | void write(int value); |
mkarlsso | 0:8dbd6bd9167f | 51 | int read(); |
mkarlsso | 0:8dbd6bd9167f | 52 | |
mkarlsso | 0:8dbd6bd9167f | 53 | private: |
mkarlsso | 0:8dbd6bd9167f | 54 | DigitalOut *outpin; |
mkarlsso | 0:8dbd6bd9167f | 55 | |
mkarlsso | 0:8dbd6bd9167f | 56 | }; |
mkarlsso | 0:8dbd6bd9167f | 57 | |
mkarlsso | 0:8dbd6bd9167f | 58 | class MBEDDigitalIn : public sDigitalIn |
mkarlsso | 0:8dbd6bd9167f | 59 | { |
mkarlsso | 0:8dbd6bd9167f | 60 | public: |
mkarlsso | 0:8dbd6bd9167f | 61 | MBEDDigitalIn(); |
mkarlsso | 0:8dbd6bd9167f | 62 | |
mkarlsso | 0:8dbd6bd9167f | 63 | void init(int pin); |
mkarlsso | 0:8dbd6bd9167f | 64 | int read(); |
mkarlsso | 0:8dbd6bd9167f | 65 | void interrupt_up_callback(); |
mkarlsso | 0:8dbd6bd9167f | 66 | void interrupt_down_callback(); |
mkarlsso | 0:8dbd6bd9167f | 67 | protected: |
mkarlsso | 1:3a050d26d4f6 | 68 | |
mkarlsso | 1:3a050d26d4f6 | 69 | |
mkarlsso | 0:8dbd6bd9167f | 70 | |
mkarlsso | 0:8dbd6bd9167f | 71 | private: |
mkarlsso | 0:8dbd6bd9167f | 72 | DigitalIn *inpin; |
mkarlsso | 0:8dbd6bd9167f | 73 | InterruptIn *inpin_interrupt; |
mkarlsso | 0:8dbd6bd9167f | 74 | |
mkarlsso | 0:8dbd6bd9167f | 75 | }; |
mkarlsso | 0:8dbd6bd9167f | 76 | |
mkarlsso | 0:8dbd6bd9167f | 77 | class MBEDSerialPort : public sSerialPort |
mkarlsso | 0:8dbd6bd9167f | 78 | { |
mkarlsso | 0:8dbd6bd9167f | 79 | public: |
mkarlsso | 0:8dbd6bd9167f | 80 | MBEDSerialPort(); |
mkarlsso | 0:8dbd6bd9167f | 81 | |
mkarlsso | 0:8dbd6bd9167f | 82 | void init(); |
mkarlsso | 0:8dbd6bd9167f | 83 | bool readable(); |
mkarlsso | 0:8dbd6bd9167f | 84 | char readChar(); |
mkarlsso | 0:8dbd6bd9167f | 85 | void writeChar(char s); |
mkarlsso | 0:8dbd6bd9167f | 86 | Serial *serialToPC; |
mkarlsso | 0:8dbd6bd9167f | 87 | |
mkarlsso | 0:8dbd6bd9167f | 88 | private: |
mkarlsso | 0:8dbd6bd9167f | 89 | //Serial communication |
mkarlsso | 1:3a050d26d4f6 | 90 | |
mkarlsso | 0:8dbd6bd9167f | 91 | |
mkarlsso | 0:8dbd6bd9167f | 92 | }; |
mkarlsso | 0:8dbd6bd9167f | 93 | |
mkarlsso | 0:8dbd6bd9167f | 94 | class MBEDSound: public sSound |
mkarlsso | 0:8dbd6bd9167f | 95 | { |
mkarlsso | 0:8dbd6bd9167f | 96 | public: |
mkarlsso | 0:8dbd6bd9167f | 97 | MBEDSound(); |
mkarlsso | 0:8dbd6bd9167f | 98 | void execute(); |
mkarlsso | 0:8dbd6bd9167f | 99 | |
mkarlsso | 0:8dbd6bd9167f | 100 | private: |
mkarlsso | 0:8dbd6bd9167f | 101 | |
mkarlsso | 0:8dbd6bd9167f | 102 | }; |
mkarlsso | 0:8dbd6bd9167f | 103 | |
mkarlsso | 0:8dbd6bd9167f | 104 | class MBEDSystem: public sSystem |
mkarlsso | 0:8dbd6bd9167f | 105 | { |
mkarlsso | 0:8dbd6bd9167f | 106 | public: |
mkarlsso | 0:8dbd6bd9167f | 107 | MBEDSystem(); |
mkarlsso | 0:8dbd6bd9167f | 108 | void timerinit(); |
mkarlsso | 0:8dbd6bd9167f | 109 | void setStandAloneClock(); |
mkarlsso | 0:8dbd6bd9167f | 110 | void setSlaveClock(); |
mkarlsso | 0:8dbd6bd9167f | 111 | sDigitalOut* getDigitalOutPtr(int portNum); |
mkarlsso | 0:8dbd6bd9167f | 112 | sDigitalIn* getDigitalInPtr(int portNum); |
mkarlsso | 0:8dbd6bd9167f | 113 | sSound* createNewSoundAction(); |
mkarlsso | 1:3a050d26d4f6 | 114 | void pauseInterrupts(); |
mkarlsso | 1:3a050d26d4f6 | 115 | void resumeInterrupts(); |
mkarlsso | 0:8dbd6bd9167f | 116 | void incrementClock(); |
mkarlsso | 0:8dbd6bd9167f | 117 | void externalClockReset(); //needs to reset harware timer before calling immediateClockReset(); |
mkarlsso | 0:8dbd6bd9167f | 118 | void mainLoopToDo(); |
mkarlsso | 1:3a050d26d4f6 | 119 | |
mkarlsso | 0:8dbd6bd9167f | 120 | protected: |
mkarlsso | 1:3a050d26d4f6 | 121 | |
mkarlsso | 0:8dbd6bd9167f | 122 | //Pins for clock syncing |
mkarlsso | 0:8dbd6bd9167f | 123 | InterruptIn clockResetInt; |
mkarlsso | 0:8dbd6bd9167f | 124 | InterruptIn clockExternalIncrement; |
mkarlsso | 1:3a050d26d4f6 | 125 | |
mkarlsso | 0:8dbd6bd9167f | 126 | private: |
mkarlsso | 0:8dbd6bd9167f | 127 | MBEDDigitalIn dIn[NUMPORTS]; |
mkarlsso | 0:8dbd6bd9167f | 128 | MBEDDigitalOut dOut[NUMPORTS]; |
mkarlsso | 0:8dbd6bd9167f | 129 | }; |
mkarlsso | 0:8dbd6bd9167f | 130 | |
mkarlsso | 0:8dbd6bd9167f | 131 | #endif // MBEDINTERFACE_H |