Treehouse Mbed Team / Mbed 2 deprecated APS_1U5x

Dependencies:   mbed

Committer:
mfwic
Date:
Fri Dec 07 20:42:41 2018 +0000
Revision:
11:01dcfb29fbc4
Parent:
10:6c3233b03658
Child:
12:fd1fd1857628
Cleaned up code, reduced global variables, deleted commented out lines and stale sections.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfwic 0:44a3005d4f20 1 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 2 //
mfwic 0:44a3005d4f20 3 // Treehouse Designs Inc.
mfwic 0:44a3005d4f20 4 // Colorado Springs, Colorado
mfwic 0:44a3005d4f20 5 //
mfwic 0:44a3005d4f20 6 // Copyright (c) 2016 by Treehouse Designs Inc.
mfwic 0:44a3005d4f20 7 // Copyright (c) 2018 by Agility Power Systems Inc.
mfwic 0:44a3005d4f20 8 //
mfwic 0:44a3005d4f20 9 // This code is the property of Treehouse Designs, Inc. (Treehouse) and
mfwic 0:44a3005d4f20 10 // Agility Power Systems Inc. (Agility) and may not be redistributed
mfwic 0:44a3005d4f20 11 // in any form without prior written permission from
mfwic 0:44a3005d4f20 12 // both copyright holders, Treehouse and Agility.
mfwic 0:44a3005d4f20 13 //
mfwic 0:44a3005d4f20 14 // The above copyright notice and this permission notice shall be included in
mfwic 0:44a3005d4f20 15 // all copies or substantial portions of the Software.
mfwic 0:44a3005d4f20 16 //
mfwic 0:44a3005d4f20 17 //
mfwic 0:44a3005d4f20 18 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 19 //
mfwic 0:44a3005d4f20 20 // REVISION HISTORY:
mfwic 0:44a3005d4f20 21 //
mfwic 0:44a3005d4f20 22 // $Author: $
mfwic 0:44a3005d4f20 23 // $Rev: $
mfwic 0:44a3005d4f20 24 // $Date: $
mfwic 0:44a3005d4f20 25 // $URL: $
mfwic 0:44a3005d4f20 26 //
mfwic 0:44a3005d4f20 27 //-------------------------------------------------------------------------------
mfwic 0:44a3005d4f20 28
mfwic 0:44a3005d4f20 29 #include "mbed.h"
mfwic 0:44a3005d4f20 30 #include "globals.h"
mfwic 0:44a3005d4f20 31 #include "parameters.h"
mfwic 0:44a3005d4f20 32 #include "all_io.h"
mfwic 0:44a3005d4f20 33 #include "stdio.h"
mfwic 0:44a3005d4f20 34 #include "stdlib.h"
mfwic 0:44a3005d4f20 35 #include "serial.h"
mfwic 0:44a3005d4f20 36 #include "adc.h"
mfwic 2:46faae84b8b0 37 #include "menu.h"
mfwic 1:9f8583ba2431 38 #include "boards.h"
mfwic 8:d3d7dca419b3 39 #include "command.h"
mfwic 1:9f8583ba2431 40
mfwic 6:39442d493098 41 unsigned int en_out_code;
mfwic 6:39442d493098 42 unsigned int wr_out_code;
mfwic 6:39442d493098 43 unsigned short my12=0;
mfwic 6:39442d493098 44 volatile bool updateReady = FALSE;
mfwic 6:39442d493098 45 unsigned int loopTime = 0;
mfwic 8:d3d7dca419b3 46 bool raw = FALSE;
mfwic 11:01dcfb29fbc4 47 bool running = FALSE;
mfwic 6:39442d493098 48
mfwic 6:39442d493098 49 Timer masterTimer;
mfwic 0:44a3005d4f20 50
mfwic 0:44a3005d4f20 51 int main()
mfwic 0:44a3005d4f20 52 {
mfwic 7:860b3a8275cb 53 myled = 0;
mfwic 0:44a3005d4f20 54 extchlat = OFF;
mfwic 6:39442d493098 55 wr_out_code = setBoardEnables(ALLOFF);
mfwic 11:01dcfb29fbc4 56 en_out_code = setBoardWeights(ALLOFF); // RK: Maybe? Use hex value for boardWeights to highlight that it's an encoded value.
mfwic 7:860b3a8275cb 57 running = FALSE;
mfwic 11:01dcfb29fbc4 58
mfwic 7:860b3a8275cb 59 initSerial();
mfwic 3:d8948c5b2951 60
mfwic 7:860b3a8275cb 61 initDRT(); // Display Refresh Timer
mfwic 7:860b3a8275cb 62
mfwic 0:44a3005d4f20 63 initADC();
mfwic 11:01dcfb29fbc4 64
mfwic 11:01dcfb29fbc4 65 struct adcValues avals = getADCresults();
mfwic 7:860b3a8275cb 66
mfwic 8:d3d7dca419b3 67 splash_screen();
mfwic 8:d3d7dca419b3 68 sprintf(strbuf, "\r\nPress Enter to continue");
mfwic 8:d3d7dca419b3 69 sendSerial(strbuf);
mfwic 11:01dcfb29fbc4 70 while(waitCommand()){ // Wait for user to press Enter
mfwic 8:d3d7dca419b3 71 }
mfwic 8:d3d7dca419b3 72
mfwic 8:d3d7dca419b3 73 menuRedraw(WITH_PROMPT);
mfwic 11:01dcfb29fbc4 74
mfwic 0:44a3005d4f20 75 while (1)
mfwic 0:44a3005d4f20 76 {
mfwic 0:44a3005d4f20 77 processCommand();
mfwic 11:01dcfb29fbc4 78
mfwic 11:01dcfb29fbc4 79 avals = getADCresults();
mfwic 6:39442d493098 80
mfwic 6:39442d493098 81 if(updateReady){
mfwic 6:39442d493098 82 updateReady = FALSE;
mfwic 11:01dcfb29fbc4 83 updateTerminal(avals); // May want to gate this call when we run a headless system.
mfwic 7:860b3a8275cb 84 //loopTime = masterTimer.read_ms();// - loopTime;
mfwic 7:860b3a8275cb 85 myled = !myled;
mfwic 9:816b9a4e4f21 86 //sprintf(strbuf, "\r\nupdateControls ran %d times.\r\n", count);
mfwic 9:816b9a4e4f21 87 //sendSerial(strbuf);
mfwic 9:816b9a4e4f21 88 //count=0;
mfwic 6:39442d493098 89 }
mfwic 6:39442d493098 90
mfwic 4:db38665c3727 91 if(running){
mfwic 11:01dcfb29fbc4 92 updateControls(avals.i12);
mfwic 9:816b9a4e4f21 93 //count++;
mfwic 6:39442d493098 94 }else{
mfwic 10:6c3233b03658 95 updateControls(my12);
mfwic 4:db38665c3727 96 }
mfwic 11:01dcfb29fbc4 97 }//end while(1)
mfwic 11:01dcfb29fbc4 98 }//end void main(void)
mfwic 0:44a3005d4f20 99