homework 7

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Committer:
gatedClock
Date:
Mon Sep 09 23:53:57 2013 +0000
Revision:
39:4e7e4d935a87
Parent:
38:b84a2cc772a4
Child:
40:7afff79f0d8b
adding actual temperature measurement.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gatedClock 0:fcca4db7b32a 1 /*----------------------------------------------//------------------------------
gatedClock 0:fcca4db7b32a 2 student : m-moore
gatedClock 0:fcca4db7b32a 3 class : rtos
gatedClock 10:2b0a9fc39109 4 directory : RTOS_HW_07
gatedClock 0:fcca4db7b32a 5 file : main.cpp
gatedClock 0:fcca4db7b32a 6 ----description---------------------------------//------------------------------
gatedClock 0:fcca4db7b32a 7 -----includes-----------------------------------//----------------------------*/
gatedClock 0:fcca4db7b32a 8 #include "mbed.h" // mbed class.
gatedClock 10:2b0a9fc39109 9 #include "rtos.h" // rtos class.
gatedClock 39:4e7e4d935a87 10 #include "LM75B.h" // thermometer class.
gatedClock 10:2b0a9fc39109 11 #include "C12832_lcd.h" // LCD class.
gatedClock 0:fcca4db7b32a 12 //---defines------------------------------------//------------------------------
gatedClock 9:cfdb9aa5857c 13 #define LCD1 lcd.locate(0, 0); // LCD line 1.
gatedClock 9:cfdb9aa5857c 14 #define LCD2 lcd.locate(0,11); // LCD line 2.
gatedClock 9:cfdb9aa5857c 15 #define LCD3 lcd.locate(0,22); // LCD line 3.
gatedClock 9:cfdb9aa5857c 16
gatedClock 10:2b0a9fc39109 17
gatedClock 19:92b11e30aaaf 18 #define DEBOUNCE 0.16 // debounce pause duration in S.
gatedClock 19:92b11e30aaaf 19 #define uS_TIMEOUT 100 // Timer uS timeout.
gatedClock 19:92b11e30aaaf 20 #define LBSIG 1 // left button signal code.
gatedClock 33:34c1bef3c4ff 21 #define PIPEuS 1000 // pipeline clock period.
gatedClock 19:92b11e30aaaf 22 #define SLOWCLOCKuS 500000 // slow-clock period.
gatedClock 39:4e7e4d935a87 23 #define TEMPCLOCKS 1 // temperature-measuring period in S.
gatedClock 26:bff592483cb1 24 #define PIPEDATASIZE 8 // dimension of tPipeData.
gatedClock 0:fcca4db7b32a 25 //--global_definitions--------------------------//------------------------------
gatedClock 26:bff592483cb1 26 struct tButtons // button ISR updates.
gatedClock 26:bff592483cb1 27 {
gatedClock 26:bff592483cb1 28 char cLeftButton; // cooktime +60S.
gatedClock 26:bff592483cb1 29 char cRightButton; // cooktime -60S.
gatedClock 26:bff592483cb1 30 char cTopButton; // start cook.
gatedClock 26:bff592483cb1 31 char cBottomButton; // stop cook.
gatedClock 26:bff592483cb1 32 char cCenterButton; // door toggle.
gatedClock 26:bff592483cb1 33 };
gatedClock 34:b449d2a7c786 34
gatedClock 34:b449d2a7c786 35 // below is the dimensioned pipeline data structure.
gatedClock 34:b449d2a7c786 36 // each pipeline stage's output is stored into this dimensioned structure
gatedClock 34:b449d2a7c786 37 // with dimension index equal to the pipeline segment number.
gatedClock 34:b449d2a7c786 38 // not all variables are needed in each segment, but of course they're all
gatedClock 34:b449d2a7c786 39 // present in each index of this structure. comments indicate which
gatedClock 34:b449d2a7c786 40 // segment a variable is first 'created' in. some variables may not be
gatedClock 34:b449d2a7c786 41 // needed in all of its subsequent segments, but they could be piped-through
gatedClock 34:b449d2a7c786 42 // for diagnostic purposes.
gatedClock 34:b449d2a7c786 43
gatedClock 34:b449d2a7c786 44
gatedClock 26:bff592483cb1 45 struct tPipeData // pipeline processor data.
gatedClock 19:92b11e30aaaf 46 {
gatedClock 34:b449d2a7c786 47 //--- // INTRODUCED IN SEGMENT 0.
gatedClock 34:b449d2a7c786 48
gatedClock 38:b84a2cc772a4 49 char cLeftButton; // cooktime +60S.
gatedClock 38:b84a2cc772a4 50 char cRightButton; // cooktime -60S.
gatedClock 38:b84a2cc772a4 51 char cTopButton; // start cook.
gatedClock 38:b84a2cc772a4 52 char cBottomButton; // stop cook.
gatedClock 38:b84a2cc772a4 53 char cCenterButton; // door toggle.
gatedClock 38:b84a2cc772a4 54 char cSlowClock; // slow-clock.
gatedClock 34:b449d2a7c786 55
gatedClock 34:b449d2a7c786 56 //--- // INTRODUCED IN SEGMENT 1.
gatedClock 34:b449d2a7c786 57
gatedClock 38:b84a2cc772a4 58 char cSlowClockRE; // slow-clock rising-edge.
gatedClock 38:b84a2cc772a4 59 char cLeftButtonRE; // rising-edge.
gatedClock 38:b84a2cc772a4 60 char cRightButtonRE; // rising-edge.
gatedClock 38:b84a2cc772a4 61 char cTopButtonRE; // rising-edge.
gatedClock 38:b84a2cc772a4 62 char cBottomButtonRE; // rising-edge.
gatedClock 38:b84a2cc772a4 63 char cCenterButtonRE; // rising-edge.
gatedClock 25:99745cd186ce 64
gatedClock 34:b449d2a7c786 65 //--- // INTRODUCED IN SEGMENT 2.
gatedClock 34:b449d2a7c786 66
gatedClock 38:b84a2cc772a4 67 int dTotalCookTimeSec; // total cook time in seconds.
gatedClock 38:b84a2cc772a4 68 char cCSFSMcookOn; // cook-state FSM cook-on.
gatedClock 38:b84a2cc772a4 69 char cCSFSMcookPause; // cook-state FSM cook-pause.
gatedClock 38:b84a2cc772a4 70 char cCSFSMcookOff; // cook-state FSM cook-off.
gatedClock 38:b84a2cc772a4 71 char cDoorOpen; // 1 if door open.
gatedClock 38:b84a2cc772a4 72 char cDoorOpenRE; // 1 if door open rising-edge.
gatedClock 38:b84a2cc772a4 73 char cCookTimeAdjust; // rising-edge of either left or right buttons.
gatedClock 37:5048fc1d6201 74
gatedClock 37:5048fc1d6201 75 // // INTRODUCED IN SEGMENT 3.
gatedClock 37:5048fc1d6201 76
gatedClock 38:b84a2cc772a4 77 char cCSFSMcookOnRE; // rising of cookOn state.
gatedClock 33:34c1bef3c4ff 78
gatedClock 34:b449d2a7c786 79 //--- // INTRODUCED IN SEGMENT 4.
gatedClock 34:b449d2a7c786 80
gatedClock 38:b84a2cc772a4 81 int dCookTimeRemainingSec; // cook-time remaining in seconds.
gatedClock 38:b84a2cc772a4 82 float fCelsius; // contrived food temperature.
gatedClock 34:b449d2a7c786 83
gatedClock 34:b449d2a7c786 84 //--- // INTRODUCED IN SEGMENT 5.
gatedClock 38:b84a2cc772a4 85 char cCookTimeRemainingZeroRE; // cook-time remaining is zero, rising-edge.
gatedClock 33:34c1bef3c4ff 86
gatedClock 34:b449d2a7c786 87 //---
gatedClock 19:92b11e30aaaf 88 };
gatedClock 0:fcca4db7b32a 89 //--global_variables----------------------------//------------------------------
gatedClock 26:bff592483cb1 90 char gcSignalWaitEnable; // 1 to wait on a signal.
gatedClock 26:bff592483cb1 91 char gcSlowClock; // slow-clock signal.
gatedClock 33:34c1bef3c4ff 92 char gcInitializePipeline; // 1 to initialize pipeline state.
gatedClock 39:4e7e4d935a87 93 float gfCelsius; // from thermometer.
gatedClock 26:bff592483cb1 94 tButtons gtButtons; // ISR button updates.
gatedClock 0:fcca4db7b32a 95 //--global_instances----------------------------//------------------------------
gatedClock 39:4e7e4d935a87 96 LM75B temperature(p28,p27); // on-board thermometer.
gatedClock 9:cfdb9aa5857c 97 C12832_LCD lcd; // LCD object.
gatedClock 39:4e7e4d935a87 98 DigitalOut led0(LED4);
gatedClock 39:4e7e4d935a87 99 DigitalOut led1(LED3);
gatedClock 39:4e7e4d935a87 100 DigitalOut led2(LED2);
gatedClock 39:4e7e4d935a87 101 DigitalOut led3(LED1);
gatedClock 0:fcca4db7b32a 102
gatedClock 0:fcca4db7b32a 103 InterruptIn iJoyStickUp (p15); // joystick up rising edge.
gatedClock 0:fcca4db7b32a 104 InterruptIn iJoyStickDown (p12); // joystick down rising edge.
gatedClock 0:fcca4db7b32a 105 InterruptIn iJoyStickLeft (p13); // joystick left rising edge.
gatedClock 0:fcca4db7b32a 106 InterruptIn iJoyStickRight (p16); // joystick right rising edge.
gatedClock 0:fcca4db7b32a 107 InterruptIn iJoyStickCenter(p14); // 1 if joystick middle pressed.
gatedClock 0:fcca4db7b32a 108
gatedClock 18:64fde599e645 109 Ticker tickerPipeline; // the main pipeline ticker.
gatedClock 19:92b11e30aaaf 110 Ticker tickerSlowClock; // generate a ~1Hz clock.
gatedClock 39:4e7e4d935a87 111 Ticker tickerTemperature; // measure temperature.
gatedClock 0:fcca4db7b32a 112 //-------prototypes-----------------------------//------------------------------
gatedClock 19:92b11e30aaaf 113 void pipelineProcessor(); // pipelined machine.
gatedClock 33:34c1bef3c4ff 114 void pipelineInitialize(tPipeData * pD); // initialize pipeline state.
gatedClock 19:92b11e30aaaf 115 void slowClock(); // 1Hz or thereabouts.
gatedClock 26:bff592483cb1 116 void segment_0(tPipeData * pD); // segment 0 logic.
gatedClock 26:bff592483cb1 117 void segment_1(tPipeData * pD); // segment 1 logic.
gatedClock 26:bff592483cb1 118 void segment_2(tPipeData * pD); // segment 2 logic.
gatedClock 26:bff592483cb1 119 void segment_3(tPipeData * pD); // segment 3 logic.
gatedClock 26:bff592483cb1 120 void segment_4(tPipeData * pD); // segment 4 logic.
gatedClock 26:bff592483cb1 121 void segment_5(tPipeData * pD); // segment 5 logic.
gatedClock 26:bff592483cb1 122 void segment_6(tPipeData * pD); // segment 6 logic.
gatedClock 26:bff592483cb1 123 void segment_7(tPipeData * pD); // segment 7 logic.
gatedClock 9:cfdb9aa5857c 124 void initialization(); // initialize settings.
gatedClock 13:21f27ba467c2 125
gatedClock 13:21f27ba467c2 126 void ISRleftButtonRising(); // cook-time increase.
gatedClock 13:21f27ba467c2 127 void ISRleftButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 128 void ISRrightButtonRising(); // cook-time decrease.
gatedClock 13:21f27ba467c2 129 void ISRrightButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 130 void ISRtopButtonRising(); // cook start.
gatedClock 13:21f27ba467c2 131 void ISRtopButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 132 void ISRbottomButtonRising(); // cook stop.
gatedClock 13:21f27ba467c2 133 void ISRbottomButtonFalling(); // button-release debounce.
gatedClock 13:21f27ba467c2 134 void ISRcenterButtonRising(); // door state toggle.
gatedClock 13:21f27ba467c2 135 void ISRcenterButtonFalling(); // button-release debounce.
gatedClock 16:db7f0b3b2605 136 void disableSignalWaiting(); // break from signal waiting.
gatedClock 39:4e7e4d935a87 137
gatedClock 39:4e7e4d935a87 138 void measureTemperature(); // temperature measurement.
gatedClock 0:fcca4db7b32a 139 //==============================================//==============================
gatedClock 0:fcca4db7b32a 140 int main(void)
gatedClock 0:fcca4db7b32a 141 {
gatedClock 16:db7f0b3b2605 142 char cLeftButtonState; // 1 means button was pressed.
gatedClock 16:db7f0b3b2605 143
gatedClock 16:db7f0b3b2605 144
gatedClock 16:db7f0b3b2605 145
gatedClock 14:d3bb343cd5b2 146 iJoyStickLeft.rise (&ISRleftButtonRising);
gatedClock 14:d3bb343cd5b2 147 iJoyStickLeft.fall (&ISRleftButtonFalling);
gatedClock 9:cfdb9aa5857c 148
gatedClock 14:d3bb343cd5b2 149 iJoyStickRight.rise(&ISRrightButtonRising);
gatedClock 14:d3bb343cd5b2 150 iJoyStickRight.fall(&ISRrightButtonFalling);
gatedClock 14:d3bb343cd5b2 151
gatedClock 14:d3bb343cd5b2 152 iJoyStickUp.rise (&ISRtopButtonRising);
gatedClock 14:d3bb343cd5b2 153 iJoyStickUp.fall (&ISRtopButtonFalling);
gatedClock 9:cfdb9aa5857c 154
gatedClock 14:d3bb343cd5b2 155 iJoyStickDown.rise (&ISRbottomButtonRising);
gatedClock 14:d3bb343cd5b2 156 iJoyStickDown.fall (&ISRbottomButtonFalling);
gatedClock 7:9fbd1d540863 157
gatedClock 14:d3bb343cd5b2 158 iJoyStickCenter.rise(&ISRcenterButtonRising);
gatedClock 14:d3bb343cd5b2 159 iJoyStickCenter.fall(&ISRcenterButtonFalling);
gatedClock 9:cfdb9aa5857c 160
gatedClock 33:34c1bef3c4ff 161 gcInitializePipeline = 1; // tell pipeline to initialize.
gatedClock 16:db7f0b3b2605 162
gatedClock 9:cfdb9aa5857c 163 initialization(); // initialize variables.
gatedClock 21:b794d189c36b 164 gcSlowClock = 0;
gatedClock 0:fcca4db7b32a 165
gatedClock 39:4e7e4d935a87 166 tickerPipeline. attach_us(&pipelineProcessor ,PIPEuS);
gatedClock 39:4e7e4d935a87 167 tickerSlowClock.attach_us(&slowClock ,SLOWCLOCKuS);
gatedClock 39:4e7e4d935a87 168 tickerTemperature.attach (&measureTemperature,TEMPCLOCKS);
gatedClock 19:92b11e30aaaf 169
gatedClock 14:d3bb343cd5b2 170
gatedClock 9:cfdb9aa5857c 171
gatedClock 14:d3bb343cd5b2 172 while(1)
gatedClock 0:fcca4db7b32a 173 {
gatedClock 18:64fde599e645 174 Thread::wait(10);
gatedClock 16:db7f0b3b2605 175
gatedClock 16:db7f0b3b2605 176
gatedClock 16:db7f0b3b2605 177
gatedClock 14:d3bb343cd5b2 178
gatedClock 0:fcca4db7b32a 179 }
gatedClock 19:92b11e30aaaf 180 }
gatedClock 19:92b11e30aaaf 181 /*----------------------------------------------//----------------------------*/
gatedClock 21:b794d189c36b 182 // the pipeline segments are processed from right to left,
gatedClock 21:b794d189c36b 183 // because each segment's inputs are generated by the previous clock's
gatedClock 21:b794d189c36b 184 // processing.
gatedClock 21:b794d189c36b 185
gatedClock 21:b794d189c36b 186 // each segment will store its outputs in the same index number of pD
gatedClock 21:b794d189c36b 187 // as its segment number.
gatedClock 21:b794d189c36b 188
gatedClock 19:92b11e30aaaf 189 void pipelineProcessor(void) // the pipeline processor.
gatedClock 19:92b11e30aaaf 190 {
gatedClock 26:bff592483cb1 191 static tPipeData iD[PIPEDATASIZE]; // static dataset.
gatedClock 26:bff592483cb1 192 static tPipeData * pD = NULL; // convenience pointer.
gatedClock 24:d39516e077ea 193
gatedClock 33:34c1bef3c4ff 194 if (!pD) pD = &(iD[0]); // equate pointer.
gatedClock 33:34c1bef3c4ff 195
gatedClock 33:34c1bef3c4ff 196 if (gcInitializePipeline) // one-time initialization.
gatedClock 33:34c1bef3c4ff 197 {
gatedClock 33:34c1bef3c4ff 198 pipelineInitialize(pD);
gatedClock 33:34c1bef3c4ff 199 gcInitializePipeline = 0;
gatedClock 33:34c1bef3c4ff 200 }
gatedClock 19:92b11e30aaaf 201
gatedClock 23:6877aecb2dd3 202
gatedClock 29:1c94ae95578f 203
gatedClock 32:189beaf57a5d 204 led0 = pD[7].cLeftButtonRE;
gatedClock 31:b9f7cfbd0dd2 205 led1 = pD[7].cRightButton;
gatedClock 31:b9f7cfbd0dd2 206 led2 = pD[7].cTopButton;
gatedClock 31:b9f7cfbd0dd2 207 led3 = pD[7].cBottomButton;
gatedClock 29:1c94ae95578f 208
gatedClock 28:089dace708cf 209 /*
gatedClock 28:089dace708cf 210 led0 = gtButtons.cLeftButton;
gatedClock 28:089dace708cf 211 led1 = gtButtons.cRightButton;
gatedClock 28:089dace708cf 212 led2 = gtButtons.cTopButton;
gatedClock 28:089dace708cf 213 led3 = gtButtons.cBottomButton;
gatedClock 29:1c94ae95578f 214 */
gatedClock 22:8c9dba7c55df 215
gatedClock 22:8c9dba7c55df 216
gatedClock 24:d39516e077ea 217
gatedClock 23:6877aecb2dd3 218
gatedClock 20:094c2009ee57 219 segment_7(pD); // process pipeline segment 7.
gatedClock 20:094c2009ee57 220 segment_6(pD); // process pipeline segment 6.
gatedClock 20:094c2009ee57 221 segment_5(pD); // process pipeline segment 5.
gatedClock 20:094c2009ee57 222 segment_4(pD); // process pipeline segment 4.
gatedClock 20:094c2009ee57 223 segment_3(pD); // process pipeline segment 3.
gatedClock 20:094c2009ee57 224 segment_2(pD); // process pipeline segment 2.
gatedClock 20:094c2009ee57 225 segment_1(pD); // process pipeline segment 1.
gatedClock 20:094c2009ee57 226 segment_0(pD); // process pipeline segment 0.
gatedClock 23:6877aecb2dd3 227
gatedClock 19:92b11e30aaaf 228 }
gatedClock 19:92b11e30aaaf 229 /*----------------------------------------------//----------------------------*/
gatedClock 33:34c1bef3c4ff 230 void pipelineInitialize(tPipeData * pD) // initialize pipeline state.
gatedClock 33:34c1bef3c4ff 231 {
gatedClock 33:34c1bef3c4ff 232
gatedClock 33:34c1bef3c4ff 233 pD[2].dTotalCookTimeSec = 0;
gatedClock 33:34c1bef3c4ff 234
gatedClock 33:34c1bef3c4ff 235 pD[2].cCSFSMcookOn = 0;
gatedClock 33:34c1bef3c4ff 236 pD[2].cCSFSMcookPause = 0;
gatedClock 33:34c1bef3c4ff 237 pD[2].cCSFSMcookOff = 1;
gatedClock 33:34c1bef3c4ff 238
gatedClock 33:34c1bef3c4ff 239
gatedClock 33:34c1bef3c4ff 240 }
gatedClock 33:34c1bef3c4ff 241 /*----------------------------------------------//----------------------------*/
gatedClock 19:92b11e30aaaf 242 void slowClock(void) // 1Hz or thereabouts.
gatedClock 19:92b11e30aaaf 243 {
gatedClock 24:d39516e077ea 244 gcSlowClock = !gcSlowClock; // toggle clock.
gatedClock 19:92b11e30aaaf 245 }
gatedClock 19:92b11e30aaaf 246 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 247 void segment_0(tPipeData * pD) // pipeline segment 0 logic.
gatedClock 20:094c2009ee57 248 {
gatedClock 27:a9610cc12c90 249 // feed-in front-end data.
gatedClock 26:bff592483cb1 250 pD[0].cLeftButton = gtButtons.cLeftButton;
gatedClock 26:bff592483cb1 251 pD[0].cRightButton = gtButtons.cRightButton;
gatedClock 26:bff592483cb1 252 pD[0].cTopButton = gtButtons.cTopButton;
gatedClock 26:bff592483cb1 253 pD[0].cBottomButton = gtButtons.cBottomButton;
gatedClock 26:bff592483cb1 254 pD[0].cCenterButton = gtButtons.cCenterButton;
gatedClock 26:bff592483cb1 255 pD[0].cSlowClock = gcSlowClock;
gatedClock 20:094c2009ee57 256 }
gatedClock 20:094c2009ee57 257 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 258 void segment_1(tPipeData * pD) // pipeline segment 1 logic.
gatedClock 24:d39516e077ea 259 {
gatedClock 27:a9610cc12c90 260
gatedClock 27:a9610cc12c90 261 // rising-edge detectors for
gatedClock 27:a9610cc12c90 262 // all front-end data.
gatedClock 27:a9610cc12c90 263 if (!pD[1].cLeftButton & pD[0].cLeftButton)
gatedClock 27:a9610cc12c90 264 pD[1].cLeftButtonRE = 1;
gatedClock 27:a9610cc12c90 265 else
gatedClock 27:a9610cc12c90 266 pD[1].cLeftButtonRE = 0;
gatedClock 27:a9610cc12c90 267
gatedClock 27:a9610cc12c90 268 if (!pD[1].cRightButton & pD[0].cRightButton)
gatedClock 27:a9610cc12c90 269 pD[1].cRightButtonRE = 1;
gatedClock 27:a9610cc12c90 270 else
gatedClock 27:a9610cc12c90 271 pD[1].cRightButtonRE = 0;
gatedClock 27:a9610cc12c90 272
gatedClock 27:a9610cc12c90 273
gatedClock 27:a9610cc12c90 274 if (!pD[1].cTopButton & pD[0].cTopButton)
gatedClock 27:a9610cc12c90 275 pD[1].cTopButtonRE = 1;
gatedClock 27:a9610cc12c90 276 else
gatedClock 27:a9610cc12c90 277 pD[1].cTopButtonRE = 0;
gatedClock 27:a9610cc12c90 278
gatedClock 27:a9610cc12c90 279
gatedClock 27:a9610cc12c90 280 if (!pD[1].cBottomButton & pD[0].cBottomButton)
gatedClock 27:a9610cc12c90 281 pD[1].cBottomButtonRE = 1;
gatedClock 27:a9610cc12c90 282 else
gatedClock 27:a9610cc12c90 283 pD[1].cBottomButtonRE = 0;
gatedClock 27:a9610cc12c90 284
gatedClock 27:a9610cc12c90 285 if (!pD[1].cCenterButton & pD[0].cCenterButton)
gatedClock 27:a9610cc12c90 286 pD[1].cCenterButtonRE = 1;
gatedClock 27:a9610cc12c90 287 else
gatedClock 27:a9610cc12c90 288 pD[1].cCenterButtonRE = 0;
gatedClock 27:a9610cc12c90 289
gatedClock 27:a9610cc12c90 290
gatedClock 27:a9610cc12c90 291 if (!pD[1].cSlowClock & pD[0].cSlowClock)
gatedClock 27:a9610cc12c90 292 pD[1].cSlowClockRE = 1;
gatedClock 27:a9610cc12c90 293 else
gatedClock 28:089dace708cf 294 pD[1].cSlowClockRE = 0;
gatedClock 28:089dace708cf 295
gatedClock 28:089dace708cf 296 // once the rising edges of
gatedClock 28:089dace708cf 297 // the buttons have been registered,
gatedClock 28:089dace708cf 298 // we can clear the button state
gatedClock 28:089dace708cf 299 // variables used by the ISRs.
gatedClock 32:189beaf57a5d 300
gatedClock 28:089dace708cf 301 if (pD[1].cLeftButton) gtButtons.cLeftButton = 0;
gatedClock 28:089dace708cf 302 if (pD[1].cRightButton) gtButtons.cRightButton = 0;
gatedClock 28:089dace708cf 303 if (pD[1].cTopButton) gtButtons.cTopButton = 0;
gatedClock 28:089dace708cf 304 if (pD[1].cBottomButton) gtButtons.cBottomButton = 0;
gatedClock 28:089dace708cf 305 if (pD[1].cCenterButton) gtButtons.cCenterButton = 0;
gatedClock 32:189beaf57a5d 306
gatedClock 24:d39516e077ea 307
gatedClock 21:b794d189c36b 308
gatedClock 27:a9610cc12c90 309 // pipeline front-end data.
gatedClock 27:a9610cc12c90 310 pD[1].cLeftButton = pD[0].cLeftButton;
gatedClock 27:a9610cc12c90 311 pD[1].cRightButton = pD[0].cRightButton;
gatedClock 27:a9610cc12c90 312 pD[1].cTopButton = pD[0].cTopButton;
gatedClock 27:a9610cc12c90 313 pD[1].cBottomButton = pD[0].cBottomButton;
gatedClock 27:a9610cc12c90 314 pD[1].cCenterButton = pD[0].cCenterButton;
gatedClock 27:a9610cc12c90 315 pD[1].cSlowClock = pD[0].cSlowClock;
gatedClock 20:094c2009ee57 316 }
gatedClock 20:094c2009ee57 317 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 318 void segment_2(tPipeData * pD) // pipeline segment 2 logic.
gatedClock 20:094c2009ee57 319 {
gatedClock 33:34c1bef3c4ff 320 //--- // TOTAL COOK-TIME COUNTER
gatedClock 20:094c2009ee57 321
gatedClock 33:34c1bef3c4ff 322 // react to mutually-exclusive buttons.
gatedClock 33:34c1bef3c4ff 323 if (pD[1].cLeftButton) pD[2].dTotalCookTimeSec += 60;
gatedClock 33:34c1bef3c4ff 324 if (pD[1].cRightButton) pD[2].dTotalCookTimeSec -= 60;
gatedClock 33:34c1bef3c4ff 325
gatedClock 33:34c1bef3c4ff 326 // saturate values.
gatedClock 33:34c1bef3c4ff 327 if (pD[2].dTotalCookTimeSec < 0) pD[2].dTotalCookTimeSec = 0;
gatedClock 33:34c1bef3c4ff 328 if (pD[2].dTotalCookTimeSec > 180) pD[2].dTotalCookTimeSec = 180;
gatedClock 33:34c1bef3c4ff 329
gatedClock 33:34c1bef3c4ff 330 //--- // COOK-STATE FSM
gatedClock 33:34c1bef3c4ff 331
gatedClock 33:34c1bef3c4ff 332 // to state cook-on if
gatedClock 33:34c1bef3c4ff 333 // * cook time remains, and
gatedClock 33:34c1bef3c4ff 334 // * the door is closed, and
gatedClock 33:34c1bef3c4ff 335 // * the cook-start button just pressed.
gatedClock 33:34c1bef3c4ff 336 if (pD[4].dCookTimeRemainingSec & !(pD[2].cDoorOpen) & pD[2].cTopButtonRE)
gatedClock 33:34c1bef3c4ff 337 {
gatedClock 33:34c1bef3c4ff 338 pD[2].cCSFSMcookOn = 1;
gatedClock 33:34c1bef3c4ff 339 pD[2].cCSFSMcookPause = 0;
gatedClock 33:34c1bef3c4ff 340 pD[2].cCSFSMcookOff = 0;
gatedClock 33:34c1bef3c4ff 341 }
gatedClock 33:34c1bef3c4ff 342 else
gatedClock 33:34c1bef3c4ff 343 // to state cook-pause if
gatedClock 33:34c1bef3c4ff 344 // * cook time remains, and
gatedClock 33:34c1bef3c4ff 345 // * the door is open, and
gatedClock 33:34c1bef3c4ff 346 // * we were previously cooking.
gatedClock 33:34c1bef3c4ff 347 if (pD[4].dCookTimeRemainingSec & pD[2].cDoorOpenRE & pD[2].cCSFSMcookOn)
gatedClock 33:34c1bef3c4ff 348 {
gatedClock 33:34c1bef3c4ff 349 pD[2].cCSFSMcookOn = 0;
gatedClock 33:34c1bef3c4ff 350 pD[2].cCSFSMcookPause = 1;
gatedClock 33:34c1bef3c4ff 351 pD[2].cCSFSMcookOff = 0;
gatedClock 33:34c1bef3c4ff 352 }
gatedClock 33:34c1bef3c4ff 353 else
gatedClock 33:34c1bef3c4ff 354 // to state cook-off if
gatedClock 33:34c1bef3c4ff 355 // * cook time hits zero, or
gatedClock 33:34c1bef3c4ff 356 // * stop button pressed.
gatedClock 33:34c1bef3c4ff 357 if (pD[5].cCookTimeRemainingZeroRE | pD[2].cBottomButtonRE)
gatedClock 33:34c1bef3c4ff 358 {
gatedClock 33:34c1bef3c4ff 359 pD[2].cCSFSMcookOn = 0;
gatedClock 33:34c1bef3c4ff 360 pD[2].cCSFSMcookPause = 0;
gatedClock 33:34c1bef3c4ff 361 pD[2].cCSFSMcookOff = 1;
gatedClock 33:34c1bef3c4ff 362 }
gatedClock 33:34c1bef3c4ff 363
gatedClock 33:34c1bef3c4ff 364
gatedClock 34:b449d2a7c786 365 //--- // DOOR-OPEN TOGGLE FF
gatedClock 33:34c1bef3c4ff 366
gatedClock 33:34c1bef3c4ff 367 // toggle door-open state.
gatedClock 33:34c1bef3c4ff 368 if (pD[1].cCenterButtonRE) pD[2].cDoorOpen = !pD[2].cDoorOpen;
gatedClock 36:07028e77b90d 369
gatedClock 36:07028e77b90d 370 //--- // COOK-TIME-ADJUSTMENT
gatedClock 36:07028e77b90d 371
gatedClock 36:07028e77b90d 372 pD[2].cCookTimeAdjust = pD[1].cLeftButtonRE | pD[1].cRightButton;
gatedClock 36:07028e77b90d 373
gatedClock 36:07028e77b90d 374
gatedClock 36:07028e77b90d 375 //--- // VARIABLE PIPE-THROUGH
gatedClock 22:8c9dba7c55df 376
gatedClock 25:99745cd186ce 377 pD[2].cLeftButton = pD[1].cLeftButton;
gatedClock 25:99745cd186ce 378 pD[2].cRightButton = pD[1].cRightButton;
gatedClock 25:99745cd186ce 379 pD[2].cTopButton = pD[1].cTopButton;
gatedClock 25:99745cd186ce 380 pD[2].cBottomButton = pD[1].cBottomButton;
gatedClock 25:99745cd186ce 381 pD[2].cCenterButton = pD[1].cCenterButton;
gatedClock 25:99745cd186ce 382 pD[2].cSlowClock = pD[1].cSlowClock;
gatedClock 25:99745cd186ce 383
gatedClock 25:99745cd186ce 384 pD[2].cLeftButtonRE = pD[1].cLeftButtonRE;
gatedClock 25:99745cd186ce 385 pD[2].cRightButtonRE = pD[1].cRightButtonRE;
gatedClock 25:99745cd186ce 386 pD[2].cTopButtonRE = pD[1].cTopButtonRE;
gatedClock 25:99745cd186ce 387 pD[2].cBottomButtonRE = pD[1].cBottomButtonRE;
gatedClock 25:99745cd186ce 388 pD[2].cCenterButtonRE = pD[1].cCenterButtonRE;
gatedClock 25:99745cd186ce 389 pD[2].cSlowClockRE = pD[1].cSlowClockRE;
gatedClock 22:8c9dba7c55df 390
gatedClock 20:094c2009ee57 391 }
gatedClock 20:094c2009ee57 392 /*----------------------------------------------//----------------------------*/
gatedClock 37:5048fc1d6201 393 void segment_3(tPipeData * pD) // pipeline segment 3 logic.
gatedClock 20:094c2009ee57 394 {
gatedClock 35:70155c53e671 395
gatedClock 37:5048fc1d6201 396 //--- // COOK STATE ON RISING EDGE
gatedClock 35:70155c53e671 397
gatedClock 37:5048fc1d6201 398 if (!pD[3].cCSFSMcookOn & pD[2].cCSFSMcookOn)
gatedClock 37:5048fc1d6201 399 pD[3].cCSFSMcookOnRE = 1;
gatedClock 37:5048fc1d6201 400 else
gatedClock 37:5048fc1d6201 401 pD[3].cCSFSMcookOnRE = 0;
gatedClock 37:5048fc1d6201 402
gatedClock 37:5048fc1d6201 403 //--- // VARIABLE PIPE-THROUGH
gatedClock 35:70155c53e671 404
gatedClock 35:70155c53e671 405 pD[3].dTotalCookTimeSec = pD[2].dTotalCookTimeSec;
gatedClock 35:70155c53e671 406 pD[3].cCSFSMcookOn = pD[2].cCSFSMcookOn;
gatedClock 35:70155c53e671 407 pD[3].cCSFSMcookPause = pD[2].cCSFSMcookPause;
gatedClock 35:70155c53e671 408 pD[3].cCSFSMcookOff = pD[2].cCSFSMcookOff;
gatedClock 35:70155c53e671 409 pD[3].cDoorOpen = pD[2].cDoorOpen;
gatedClock 35:70155c53e671 410 pD[3].cDoorOpenRE = pD[2].cDoorOpenRE;
gatedClock 35:70155c53e671 411 pD[3].cCookTimeAdjust = pD[2].cCookTimeAdjust;
gatedClock 35:70155c53e671 412
gatedClock 35:70155c53e671 413 pD[3].cLeftButton = pD[2].cLeftButton;
gatedClock 35:70155c53e671 414 pD[3].cRightButton = pD[2].cRightButton;
gatedClock 35:70155c53e671 415 pD[3].cTopButton = pD[2].cTopButton;
gatedClock 35:70155c53e671 416 pD[3].cBottomButton = pD[2].cBottomButton;
gatedClock 35:70155c53e671 417 pD[3].cCenterButton = pD[2].cCenterButton;
gatedClock 35:70155c53e671 418 pD[3].cSlowClock = pD[2].cSlowClock;
gatedClock 25:99745cd186ce 419
gatedClock 35:70155c53e671 420 pD[3].cLeftButtonRE = pD[2].cLeftButtonRE;
gatedClock 35:70155c53e671 421 pD[3].cRightButtonRE = pD[2].cRightButtonRE;
gatedClock 35:70155c53e671 422 pD[3].cTopButtonRE = pD[2].cTopButtonRE;
gatedClock 35:70155c53e671 423 pD[3].cBottomButtonRE = pD[2].cBottomButtonRE;
gatedClock 35:70155c53e671 424 pD[3].cCenterButtonRE = pD[2].cCenterButtonRE;
gatedClock 35:70155c53e671 425 pD[3].cSlowClockRE = pD[2].cSlowClockRE;
gatedClock 20:094c2009ee57 426 }
gatedClock 20:094c2009ee57 427 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 428 void segment_4(tPipeData * pD) // pipeline segment 4 logic.
gatedClock 20:094c2009ee57 429 {
gatedClock 35:70155c53e671 430
gatedClock 38:b84a2cc772a4 431 //--- // MICROWAVE TEMPERATURE
gatedClock 38:b84a2cc772a4 432
gatedClock 38:b84a2cc772a4 433 pD[4].fCelsius = 35.0; // placeholder.
gatedClock 38:b84a2cc772a4 434
gatedClock 38:b84a2cc772a4 435
gatedClock 38:b84a2cc772a4 436 //--- // REMAINING COOK TIME
gatedClock 38:b84a2cc772a4 437
gatedClock 38:b84a2cc772a4 438 // preload the total cook time if
gatedClock 38:b84a2cc772a4 439 // the total cook time has recently
gatedClock 38:b84a2cc772a4 440 // been altered.
gatedClock 38:b84a2cc772a4 441 if (pD[3].cCookTimeAdjust) pD[4].dCookTimeRemainingSec = pD[3].dTotalCookTimeSec;
gatedClock 38:b84a2cc772a4 442 else
gatedClock 38:b84a2cc772a4 443 // count-down if the cook time remaining
gatedClock 38:b84a2cc772a4 444 // is above zero and we are cooking and
gatedClock 38:b84a2cc772a4 445 // the slow-clock just ticked.
gatedClock 38:b84a2cc772a4 446 if (pD[4].dCookTimeRemainingSec & pD[3].cCSFSMcookOn & pD[3].cSlowClockRE)
gatedClock 38:b84a2cc772a4 447 pD[4].dCookTimeRemainingSec--;
gatedClock 38:b84a2cc772a4 448 else
gatedClock 38:b84a2cc772a4 449 // otherwise don't change remaining cook time.
gatedClock 38:b84a2cc772a4 450 pD[4].dCookTimeRemainingSec = pD[4].dCookTimeRemainingSec;
gatedClock 38:b84a2cc772a4 451
gatedClock 38:b84a2cc772a4 452
gatedClock 38:b84a2cc772a4 453 //--- // VARIABLE PIPE-THROUGH
gatedClock 38:b84a2cc772a4 454
gatedClock 37:5048fc1d6201 455 pD[4].cCSFSMcookOnRE = pD[3].cCSFSMcookOnRE;
gatedClock 37:5048fc1d6201 456
gatedClock 35:70155c53e671 457 pD[4].dTotalCookTimeSec = pD[3].dTotalCookTimeSec;
gatedClock 35:70155c53e671 458 pD[4].cCSFSMcookOn = pD[3].cCSFSMcookOn;
gatedClock 35:70155c53e671 459 pD[4].cCSFSMcookPause = pD[3].cCSFSMcookPause;
gatedClock 35:70155c53e671 460 pD[4].cCSFSMcookOff = pD[3].cCSFSMcookOff;
gatedClock 35:70155c53e671 461 pD[4].cDoorOpen = pD[3].cDoorOpen;
gatedClock 35:70155c53e671 462 pD[4].cDoorOpenRE = pD[3].cDoorOpenRE;
gatedClock 35:70155c53e671 463 pD[4].cCookTimeAdjust = pD[3].cCookTimeAdjust;
gatedClock 35:70155c53e671 464
gatedClock 35:70155c53e671 465
gatedClock 35:70155c53e671 466 pD[4].cLeftButton = pD[3].cLeftButton;
gatedClock 35:70155c53e671 467 pD[4].cRightButton = pD[3].cRightButton;
gatedClock 35:70155c53e671 468 pD[4].cTopButton = pD[3].cTopButton;
gatedClock 35:70155c53e671 469 pD[4].cBottomButton = pD[3].cBottomButton;
gatedClock 35:70155c53e671 470 pD[4].cCenterButton = pD[3].cCenterButton;
gatedClock 35:70155c53e671 471 pD[4].cSlowClock = pD[3].cSlowClock;
gatedClock 25:99745cd186ce 472
gatedClock 35:70155c53e671 473 pD[4].cLeftButtonRE = pD[3].cLeftButtonRE;
gatedClock 35:70155c53e671 474 pD[4].cRightButtonRE = pD[3].cRightButtonRE;
gatedClock 35:70155c53e671 475 pD[4].cTopButtonRE = pD[3].cTopButtonRE;
gatedClock 35:70155c53e671 476 pD[4].cBottomButtonRE = pD[3].cBottomButtonRE;
gatedClock 35:70155c53e671 477 pD[4].cCenterButtonRE = pD[3].cCenterButtonRE;
gatedClock 35:70155c53e671 478 pD[4].cSlowClockRE = pD[3].cSlowClockRE;
gatedClock 20:094c2009ee57 479 }
gatedClock 20:094c2009ee57 480 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 481 void segment_5(tPipeData * pD) // pipeline segment 5 logic.
gatedClock 20:094c2009ee57 482 {
gatedClock 35:70155c53e671 483
gatedClock 38:b84a2cc772a4 484 //--- // VARIABLE PIPE-THROUGH
gatedClock 38:b84a2cc772a4 485 pD[5].dCookTimeRemainingSec = pD[4].dCookTimeRemainingSec;
gatedClock 38:b84a2cc772a4 486 pD[5].fCelsius = pD[4].fCelsius;
gatedClock 38:b84a2cc772a4 487
gatedClock 38:b84a2cc772a4 488 pD[5].cCSFSMcookOnRE = pD[4].cCSFSMcookOnRE;
gatedClock 37:5048fc1d6201 489
gatedClock 38:b84a2cc772a4 490 pD[5].dTotalCookTimeSec = pD[4].dTotalCookTimeSec;
gatedClock 38:b84a2cc772a4 491 pD[5].cCSFSMcookOn = pD[4].cCSFSMcookOn;
gatedClock 38:b84a2cc772a4 492 pD[5].cCSFSMcookPause = pD[4].cCSFSMcookPause;
gatedClock 38:b84a2cc772a4 493 pD[5].cCSFSMcookOff = pD[4].cCSFSMcookOff;
gatedClock 38:b84a2cc772a4 494 pD[5].cDoorOpen = pD[4].cDoorOpen;
gatedClock 38:b84a2cc772a4 495 pD[5].cDoorOpenRE = pD[4].cDoorOpenRE;
gatedClock 38:b84a2cc772a4 496 pD[5].cCookTimeAdjust = pD[4].cCookTimeAdjust;
gatedClock 25:99745cd186ce 497
gatedClock 38:b84a2cc772a4 498 pD[5].cLeftButton = pD[4].cLeftButton;
gatedClock 38:b84a2cc772a4 499 pD[5].cRightButton = pD[4].cRightButton;
gatedClock 38:b84a2cc772a4 500 pD[5].cTopButton = pD[4].cTopButton;
gatedClock 38:b84a2cc772a4 501 pD[5].cBottomButton = pD[4].cBottomButton;
gatedClock 38:b84a2cc772a4 502 pD[5].cCenterButton = pD[4].cCenterButton;
gatedClock 38:b84a2cc772a4 503 pD[5].cSlowClock = pD[4].cSlowClock;
gatedClock 35:70155c53e671 504
gatedClock 38:b84a2cc772a4 505 pD[5].cLeftButtonRE = pD[4].cLeftButtonRE;
gatedClock 38:b84a2cc772a4 506 pD[5].cRightButtonRE = pD[4].cRightButtonRE;
gatedClock 38:b84a2cc772a4 507 pD[5].cTopButtonRE = pD[4].cTopButtonRE;
gatedClock 38:b84a2cc772a4 508 pD[5].cBottomButtonRE = pD[4].cBottomButtonRE;
gatedClock 38:b84a2cc772a4 509 pD[5].cCenterButtonRE = pD[4].cCenterButtonRE;
gatedClock 38:b84a2cc772a4 510 pD[5].cSlowClockRE = pD[4].cSlowClockRE;
gatedClock 20:094c2009ee57 511 }
gatedClock 20:094c2009ee57 512 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 513 void segment_6(tPipeData * pD) // pipeline segment 6 logic.
gatedClock 20:094c2009ee57 514 {
gatedClock 37:5048fc1d6201 515
gatedClock 38:b84a2cc772a4 516 //--- // VARIABLE PIPE-THROUGH
gatedClock 38:b84a2cc772a4 517 pD[6].dCookTimeRemainingSec = pD[5].dCookTimeRemainingSec;
gatedClock 38:b84a2cc772a4 518 pD[6].fCelsius = pD[5].fCelsius;
gatedClock 38:b84a2cc772a4 519
gatedClock 38:b84a2cc772a4 520 pD[6].cCSFSMcookOnRE = pD[5].cCSFSMcookOnRE;
gatedClock 37:5048fc1d6201 521
gatedClock 38:b84a2cc772a4 522 pD[6].dTotalCookTimeSec = pD[5].dTotalCookTimeSec;
gatedClock 38:b84a2cc772a4 523 pD[6].cCSFSMcookOn = pD[5].cCSFSMcookOn;
gatedClock 38:b84a2cc772a4 524 pD[6].cCSFSMcookPause = pD[5].cCSFSMcookPause;
gatedClock 38:b84a2cc772a4 525 pD[6].cCSFSMcookOff = pD[5].cCSFSMcookOff;
gatedClock 38:b84a2cc772a4 526 pD[6].cDoorOpen = pD[5].cDoorOpen;
gatedClock 38:b84a2cc772a4 527 pD[6].cDoorOpenRE = pD[5].cDoorOpenRE;
gatedClock 38:b84a2cc772a4 528 pD[6].cCookTimeAdjust = pD[5].cCookTimeAdjust;
gatedClock 25:99745cd186ce 529
gatedClock 38:b84a2cc772a4 530 pD[6].cLeftButton = pD[5].cLeftButton;
gatedClock 38:b84a2cc772a4 531 pD[6].cRightButton = pD[5].cRightButton;
gatedClock 38:b84a2cc772a4 532 pD[6].cTopButton = pD[5].cTopButton;
gatedClock 38:b84a2cc772a4 533 pD[6].cBottomButton = pD[5].cBottomButton;
gatedClock 38:b84a2cc772a4 534 pD[6].cCenterButton = pD[5].cCenterButton;
gatedClock 38:b84a2cc772a4 535 pD[6].cSlowClock = pD[5].cSlowClock;
gatedClock 35:70155c53e671 536
gatedClock 38:b84a2cc772a4 537 pD[6].cLeftButtonRE = pD[5].cLeftButtonRE;
gatedClock 38:b84a2cc772a4 538 pD[6].cRightButtonRE = pD[5].cRightButtonRE;
gatedClock 38:b84a2cc772a4 539 pD[6].cTopButtonRE = pD[5].cTopButtonRE;
gatedClock 38:b84a2cc772a4 540 pD[6].cBottomButtonRE = pD[5].cBottomButtonRE;
gatedClock 38:b84a2cc772a4 541 pD[6].cCenterButtonRE = pD[5].cCenterButtonRE;
gatedClock 38:b84a2cc772a4 542 pD[6].cSlowClockRE = pD[5].cSlowClockRE;
gatedClock 20:094c2009ee57 543 }
gatedClock 20:094c2009ee57 544 /*----------------------------------------------//----------------------------*/
gatedClock 38:b84a2cc772a4 545 void segment_7(tPipeData * pD) // pipeline segment 7 logic.
gatedClock 19:92b11e30aaaf 546 {
gatedClock 37:5048fc1d6201 547
gatedClock 38:b84a2cc772a4 548 //--- // VARIABLE PIPE-THROUGH
gatedClock 38:b84a2cc772a4 549 pD[7].dCookTimeRemainingSec = pD[6].dCookTimeRemainingSec;
gatedClock 38:b84a2cc772a4 550 pD[7].fCelsius = pD[6].fCelsius;
gatedClock 38:b84a2cc772a4 551
gatedClock 38:b84a2cc772a4 552
gatedClock 37:5048fc1d6201 553 pD[7].cCSFSMcookOnRE = pD[6].cCSFSMcookOnRE;
gatedClock 37:5048fc1d6201 554
gatedClock 35:70155c53e671 555 pD[7].dTotalCookTimeSec = pD[6].dTotalCookTimeSec;
gatedClock 35:70155c53e671 556 pD[7].cCSFSMcookOn = pD[6].cCSFSMcookOn;
gatedClock 35:70155c53e671 557 pD[7].cCSFSMcookPause = pD[6].cCSFSMcookPause;
gatedClock 35:70155c53e671 558 pD[7].cCSFSMcookOff = pD[6].cCSFSMcookOff;
gatedClock 35:70155c53e671 559 pD[7].cDoorOpen = pD[6].cDoorOpen;
gatedClock 35:70155c53e671 560 pD[7].cDoorOpenRE = pD[6].cDoorOpenRE;
gatedClock 35:70155c53e671 561 pD[7].cCookTimeAdjust = pD[6].cCookTimeAdjust;
gatedClock 25:99745cd186ce 562
gatedClock 35:70155c53e671 563 pD[7].cLeftButton = pD[6].cLeftButton;
gatedClock 35:70155c53e671 564 pD[7].cRightButton = pD[6].cRightButton;
gatedClock 35:70155c53e671 565 pD[7].cTopButton = pD[6].cTopButton;
gatedClock 35:70155c53e671 566 pD[7].cBottomButton = pD[6].cBottomButton;
gatedClock 35:70155c53e671 567 pD[7].cCenterButton = pD[6].cCenterButton;
gatedClock 35:70155c53e671 568 pD[7].cSlowClock = pD[6].cSlowClock;
gatedClock 35:70155c53e671 569
gatedClock 35:70155c53e671 570 pD[7].cLeftButtonRE = pD[6].cLeftButtonRE;
gatedClock 35:70155c53e671 571 pD[7].cRightButtonRE = pD[6].cRightButtonRE;
gatedClock 35:70155c53e671 572 pD[7].cTopButtonRE = pD[6].cTopButtonRE;
gatedClock 35:70155c53e671 573 pD[7].cBottomButtonRE = pD[6].cBottomButtonRE;
gatedClock 35:70155c53e671 574 pD[7].cCenterButtonRE = pD[6].cCenterButtonRE;
gatedClock 35:70155c53e671 575 pD[7].cSlowClockRE = pD[6].cSlowClockRE;
gatedClock 22:8c9dba7c55df 576
gatedClock 19:92b11e30aaaf 577
gatedClock 19:92b11e30aaaf 578 }
gatedClock 0:fcca4db7b32a 579 /*----------------------------------------------//----------------------------*/
gatedClock 0:fcca4db7b32a 580 void initialization(void) // program initializations.
gatedClock 0:fcca4db7b32a 581 {
gatedClock 16:db7f0b3b2605 582 gcSignalWaitEnable = 1;
gatedClock 0:fcca4db7b32a 583 }
gatedClock 0:fcca4db7b32a 584 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 585 void ISRleftButtonRising(void) // cooktime plus 60s.
gatedClock 1:9188d4668a88 586 {
gatedClock 11:9cae003da12b 587 __disable_irq(); // debounce start.
gatedClock 9:cfdb9aa5857c 588
gatedClock 26:bff592483cb1 589 gtButtons.cLeftButton = 1; // detect left button.
gatedClock 9:cfdb9aa5857c 590
gatedClock 9:cfdb9aa5857c 591 wait(DEBOUNCE); // debounce time.
gatedClock 9:cfdb9aa5857c 592
gatedClock 11:9cae003da12b 593 __enable_irq(); // debounce done.
gatedClock 11:9cae003da12b 594 }
gatedClock 1:9188d4668a88 595 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 596 void ISRleftButtonFalling(void) // button-release debounce.
gatedClock 1:9188d4668a88 597 {
gatedClock 11:9cae003da12b 598 __disable_irq(); // debounce start.
gatedClock 9:cfdb9aa5857c 599
gatedClock 11:9cae003da12b 600
gatedClock 9:cfdb9aa5857c 601
gatedClock 9:cfdb9aa5857c 602 wait(DEBOUNCE); // debounce time.
gatedClock 9:cfdb9aa5857c 603
gatedClock 11:9cae003da12b 604 __enable_irq(); // debounce done.
gatedClock 11:9cae003da12b 605 }
gatedClock 2:665ffa57031f 606 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 607 void ISRrightButtonRising(void) // cooktime -60s.
gatedClock 12:e40272e1fd8f 608 {
gatedClock 12:e40272e1fd8f 609 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 610
gatedClock 26:bff592483cb1 611 gtButtons.cRightButton = 1; // detect right button.
gatedClock 12:e40272e1fd8f 612
gatedClock 12:e40272e1fd8f 613 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 614
gatedClock 12:e40272e1fd8f 615 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 616 }
gatedClock 12:e40272e1fd8f 617 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 618 void ISRrightButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 619 {
gatedClock 12:e40272e1fd8f 620 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 621
gatedClock 12:e40272e1fd8f 622
gatedClock 12:e40272e1fd8f 623
gatedClock 12:e40272e1fd8f 624 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 625
gatedClock 12:e40272e1fd8f 626 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 627 }
gatedClock 12:e40272e1fd8f 628 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 629 void ISRtopButtonRising(void) // cook start.
gatedClock 12:e40272e1fd8f 630 {
gatedClock 12:e40272e1fd8f 631 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 632
gatedClock 26:bff592483cb1 633 gtButtons.cTopButton = 1; // detect top button.
gatedClock 12:e40272e1fd8f 634
gatedClock 12:e40272e1fd8f 635 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 636
gatedClock 12:e40272e1fd8f 637 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 638 }
gatedClock 12:e40272e1fd8f 639 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 640 void ISRtopButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 641 {
gatedClock 12:e40272e1fd8f 642 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 643
gatedClock 12:e40272e1fd8f 644
gatedClock 12:e40272e1fd8f 645
gatedClock 12:e40272e1fd8f 646 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 647
gatedClock 12:e40272e1fd8f 648 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 649 }
gatedClock 12:e40272e1fd8f 650 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 651 void ISRbottomButtonRising(void) // cook stop.
gatedClock 12:e40272e1fd8f 652 {
gatedClock 12:e40272e1fd8f 653 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 654
gatedClock 26:bff592483cb1 655 gtButtons.cBottomButton = 1; // detect bottom button.
gatedClock 12:e40272e1fd8f 656
gatedClock 12:e40272e1fd8f 657 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 658
gatedClock 12:e40272e1fd8f 659 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 660 }
gatedClock 12:e40272e1fd8f 661 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 662 void ISRbottomButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 663 {
gatedClock 12:e40272e1fd8f 664 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 665
gatedClock 12:e40272e1fd8f 666
gatedClock 12:e40272e1fd8f 667
gatedClock 12:e40272e1fd8f 668 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 669
gatedClock 12:e40272e1fd8f 670 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 671 }
gatedClock 12:e40272e1fd8f 672 /*----------------------------------------------//----------------------------*/
gatedClock 26:bff592483cb1 673 void ISRcenterButtonRising(void) // toggle door state.
gatedClock 12:e40272e1fd8f 674 {
gatedClock 12:e40272e1fd8f 675 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 676
gatedClock 26:bff592483cb1 677 gtButtons.cCenterButton = 1; // detect center button.
gatedClock 12:e40272e1fd8f 678
gatedClock 12:e40272e1fd8f 679 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 680
gatedClock 12:e40272e1fd8f 681 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 682 }
gatedClock 12:e40272e1fd8f 683 /*----------------------------------------------//----------------------------*/
gatedClock 15:5eaa2ab1d00d 684 void ISRcenterButtonFalling(void) // button-release debounce.
gatedClock 12:e40272e1fd8f 685 {
gatedClock 12:e40272e1fd8f 686 __disable_irq(); // debounce start.
gatedClock 12:e40272e1fd8f 687
gatedClock 12:e40272e1fd8f 688
gatedClock 12:e40272e1fd8f 689
gatedClock 12:e40272e1fd8f 690 wait(DEBOUNCE); // debounce time.
gatedClock 12:e40272e1fd8f 691
gatedClock 12:e40272e1fd8f 692 __enable_irq(); // debounce done.
gatedClock 12:e40272e1fd8f 693 }
gatedClock 12:e40272e1fd8f 694 /*----------------------------------------------//----------------------------*/
gatedClock 39:4e7e4d935a87 695 void measureTemperature(void) // temperature measurement.
gatedClock 39:4e7e4d935a87 696 {
gatedClock 39:4e7e4d935a87 697 gfCelsius = temperature.read(); // physical measurement.
gatedClock 39:4e7e4d935a87 698 }
gatedClock 39:4e7e4d935a87 699 /*----------------------------------------------//----------------------------*/