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