Mike Moore / Mbed 2 deprecated RTOS_HW_07

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Committer:
gatedClock
Date:
Mon Sep 09 23:41:19 2013 +0000
Revision:
38:b84a2cc772a4
Parent:
37:5048fc1d6201
Child:
39:4e7e4d935a87
segment 4 largely done, but it has a placeholder for the temperature.

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