Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Final351CW_FINAL by
main.cpp@10:098c2fa0a1a6, 2018-01-09 (annotated)
- Committer:
- liam_grazier
- Date:
- Tue Jan 09 11:33:14 2018 +0000
- Revision:
- 10:098c2fa0a1a6
- Parent:
- 9:e27b3f34de24
fin commented
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| liam_grazier | 10:098c2fa0a1a6 | 1 | /* ELEC351 COURSEWORK 2018 |
| liam_grazier | 10:098c2fa0a1a6 | 2 | DESIGNED USING MBED ONLINE COMPILER IMPORTED TO KEIL |
| liam_grazier | 10:098c2fa0a1a6 | 3 | LIAM GRAZIER // DOUG TILLEY // ALEX BARON |
| liam_grazier | 10:098c2fa0a1a6 | 4 | */ |
| liam_grazier | 5:9b4844128e09 | 5 | #include "components.hpp" |
| liam_grazier | 5:9b4844128e09 | 6 | #include "mbed.h" |
| liam_grazier | 7:dd303488e55d | 7 | #include "network.hpp" |
| liam_grazier | 5:9b4844128e09 | 8 | #include "lglcd.h" |
| liam_grazier | 8:582ac4c5a524 | 9 | #include "stx.hpp" |
| liam_grazier | 10:098c2fa0a1a6 | 10 | //voids for ticker attached tasks |
| liam_grazier | 10:098c2fa0a1a6 | 11 | void inter1(); |
| liam_grazier | 10:098c2fa0a1a6 | 12 | void inter2(); |
| liam_grazier | 10:098c2fa0a1a6 | 13 | void inter3(); |
| liam_grazier | 10:098c2fa0a1a6 | 14 | void inter4(); |
| liam_grazier | 10:098c2fa0a1a6 | 15 | void inter5(); |
| liam_grazier | 10:098c2fa0a1a6 | 16 | //thread initalised with priorities |
| liam_grazier | 7:dd303488e55d | 17 | Thread samplesThread(osPriorityNormal); |
| liam_grazier | 9:e27b3f34de24 | 18 | Thread sdThread(osPriorityHigh); |
| liam_grazier | 8:582ac4c5a524 | 19 | Thread sdRemoveThread(osPriorityHigh); |
| liam_grazier | 8:582ac4c5a524 | 20 | Thread timebuttonThread(osPriorityNormal); |
| liam_grazier | 8:582ac4c5a524 | 21 | Thread stxThread(osPriorityLow); |
| liam_grazier | 7:dd303488e55d | 22 | Thread netThread(osPriorityRealtime); |
| liam_grazier | 10:098c2fa0a1a6 | 23 | //interrupt assign |
| liam_grazier | 10:098c2fa0a1a6 | 24 | InterruptIn sdex(USER_BUTTON); |
| liam_grazier | 10:098c2fa0a1a6 | 25 | //ticker assigns |
| liam_grazier | 7:dd303488e55d | 26 | Ticker samples; |
| liam_grazier | 7:dd303488e55d | 27 | Ticker remov; |
| liam_grazier | 7:dd303488e55d | 28 | Ticker storage; |
| liam_grazier | 7:dd303488e55d | 29 | Ticker netTick; |
| liam_grazier | 8:582ac4c5a524 | 30 | Ticker serielTick; |
| liam_grazier | 10:098c2fa0a1a6 | 31 | //sd card attached signal flag task |
| liam_grazier | 10:098c2fa0a1a6 | 32 | void inter1() |
| liam_grazier | 10:098c2fa0a1a6 | 33 | { |
| liam_grazier | 10:098c2fa0a1a6 | 34 | sdcheck(); |
| liam_grazier | 10:098c2fa0a1a6 | 35 | samplesThread.signal_set(SIG_READY); |
| liam_grazier | 7:dd303488e55d | 36 | } |
| liam_grazier | 10:098c2fa0a1a6 | 37 | //sampling attached signal flag task |
| liam_grazier | 10:098c2fa0a1a6 | 38 | void inter2() |
| liam_grazier | 10:098c2fa0a1a6 | 39 | { |
| liam_grazier | 10:098c2fa0a1a6 | 40 | sdThread.signal_set(SIG_READY2); |
| liam_grazier | 7:dd303488e55d | 41 | } |
| liam_grazier | 10:098c2fa0a1a6 | 42 | //sd card remove attached signal flag task |
| liam_grazier | 10:098c2fa0a1a6 | 43 | void inter3() |
| liam_grazier | 10:098c2fa0a1a6 | 44 | { |
| liam_grazier | 10:098c2fa0a1a6 | 45 | if(sdex == 1)//checks if remove button *USER BUTTON triggered by interrupt has been flagged to indicated remove |
| liam_grazier | 10:098c2fa0a1a6 | 46 | { |
| liam_grazier | 10:098c2fa0a1a6 | 47 | sdRemoveThread.signal_set(SIG_REMOVE); |
| liam_grazier | 10:098c2fa0a1a6 | 48 | } |
| liam_grazier | 7:dd303488e55d | 49 | } |
| liam_grazier | 10:098c2fa0a1a6 | 50 | //network attached signal flag task |
| liam_grazier | 10:098c2fa0a1a6 | 51 | void inter4() |
| liam_grazier | 10:098c2fa0a1a6 | 52 | { |
| liam_grazier | 10:098c2fa0a1a6 | 53 | netThread.signal_set(SIG_NET); |
| liam_grazier | 8:582ac4c5a524 | 54 | } |
| liam_grazier | 10:098c2fa0a1a6 | 55 | //setial comms attached signal flag task |
| liam_grazier | 10:098c2fa0a1a6 | 56 | void inter5() |
| liam_grazier | 10:098c2fa0a1a6 | 57 | { |
| liam_grazier | 10:098c2fa0a1a6 | 58 | stxThread.signal_set(SIG_SX); |
| liam_grazier | 10:098c2fa0a1a6 | 59 | } |
| liam_grazier | 10:098c2fa0a1a6 | 60 | int main() |
| liam_grazier | 10:098c2fa0a1a6 | 61 | { |
| liam_grazier | 10:098c2fa0a1a6 | 62 | lglcd mylcd(D7,D6,D5,D4,D3,D2);//setup lcd |
| liam_grazier | 10:098c2fa0a1a6 | 63 | setuptime();//setup time to default |
| liam_grazier | 10:098c2fa0a1a6 | 64 | sdrun(); //init sd |
| liam_grazier | 10:098c2fa0a1a6 | 65 | lcdstart();//run lcd start code |
| liam_grazier | 10:098c2fa0a1a6 | 66 | welcomemsg(); //display welcome msg in the terminal |
| liam_grazier | 10:098c2fa0a1a6 | 67 | sdThread.start(sdwrite); |
| liam_grazier | 10:098c2fa0a1a6 | 68 | storage.attach(&inter2,1); //attached the storage SD ticker to the allocated flag task, this triggers every 1secs |
| liam_grazier | 10:098c2fa0a1a6 | 69 | samplesThread.start(runanalysis); |
| liam_grazier | 10:098c2fa0a1a6 | 70 | samples.attach(&inter1,1); //attached the samples ticker to the allocated flag task, this triggers every 1secs |
| liam_grazier | 10:098c2fa0a1a6 | 71 | sdRemoveThread.start(sdremove); |
| liam_grazier | 10:098c2fa0a1a6 | 72 | remov.attach(&inter3,3);//attached the SD Remove ticker to the allocated flag task, this triggers every 3secs |
| liam_grazier | 10:098c2fa0a1a6 | 73 | netThread.start(networksend); |
| liam_grazier | 10:098c2fa0a1a6 | 74 | netTick.attach(&inter4,0.01);//attached the network ticker to the allocated flag task, this triggers every 0.01secs |
| liam_grazier | 10:098c2fa0a1a6 | 75 | stxThread.start(useseriel);// |
| liam_grazier | 10:098c2fa0a1a6 | 76 | serielTick.attach(&inter5,0.1);//attached the serial ticker to the allocated flag task, this triggers every 0.1secs |
| liam_grazier | 7:dd303488e55d | 77 | } |
