System Management code

Dependencies:   CANBuffer mbed SystemManagement mbed-rtos

Dependents:   SystemManagement

System Management code for Penn Electric Racing

Functions:

Controls Fans and Pumps via instruction from CAN Messages, ramps them up over time to prevent damage

Turns on/off DC-DC converter via instruction from CAN Messages

Committer:
martydd3
Date:
Fri Oct 10 20:59:36 2014 +0000
Revision:
7:5f6e31faa08e
Parent:
6:6a04210a3f4f
PollSwitch code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martydd3 0:e516fcccccda 1 /*
martydd3 0:e516fcccccda 2 Reads CAN Messages and various data inputs, outputs using Xbee radio modules
martydd3 0:e516fcccccda 3
martydd3 0:e516fcccccda 4 Revised Sept 30, 2014: Began analyzing and commenting program, trying to figure out what the hell it does (Martin Deng)
martydd3 0:e516fcccccda 5 */
martydd3 0:e516fcccccda 6
martydd3 6:6a04210a3f4f 7 #include "SysMngmt.h"
martydd3 6:6a04210a3f4f 8 #include "Get_IMD.h"
martydd3 6:6a04210a3f4f 9 #include "PollSwitch.h"
martydd3 6:6a04210a3f4f 10 #include "TemperatureRead.h"
martydd3 6:6a04210a3f4f 11 #include "Store_RTC.h"
martydd3 6:6a04210a3f4f 12 #include "XBee_Lib.h"
martydd3 6:6a04210a3f4f 13 #include "CANBuffer.h"
martydd3 0:e516fcccccda 14
martydd3 6:6a04210a3f4f 15 #include "mbed.h"
martydd3 6:6a04210a3f4f 16 #include "rtos.h"
martydd3 6:6a04210a3f4f 17
martydd3 6:6a04210a3f4f 18 #include "Watchdog.cpp"
martydd3 6:6a04210a3f4f 19 #include "FanPump.h"
martydd3 6:6a04210a3f4f 20 #include "DC_DC.h"
martydd3 7:5f6e31faa08e 21 #include "PollSwitch.h"
martydd3 0:e516fcccccda 22
martydd3 0:e516fcccccda 23 //Possible problems in IMD coz change of counter
martydd3 0:e516fcccccda 24 //Possible problems in BatteryStatus coz change in library
martydd3 0:e516fcccccda 25
martydd3 0:e516fcccccda 26 /*
martydd3 0:e516fcccccda 27
martydd3 0:e516fcccccda 28 Attach Ticker every 10msec to
martydd3 0:e516fcccccda 29 Get IMD
martydd3 0:e516fcccccda 30 Poll Switches
martydd3 0:e516fcccccda 31 Temperature Read
martydd3 0:e516fcccccda 32 Get Battery State
martydd3 0:e516fcccccda 33 End Ticker Send message through CAN
martydd3 0:e516fcccccda 34
martydd3 0:e516fcccccda 35 CAN interrupt Rx Interrupt
martydd3 0:e516fcccccda 36 Recieve CAN message into a buffer. Return
martydd3 0:e516fcccccda 37 Buffer values(as long as !empty) -> SD Card, Xbee -> remove element
martydd3 0:e516fcccccda 38
martydd3 0:e516fcccccda 39 extern "C" void CAN_IRQHandler(void)
martydd3 0:e516fcccccda 40 {
martydd3 0:e516fcccccda 41 CANMessage Rxmsg;
martydd3 0:e516fcccccda 42 CAN_SysM.read(Rxmsg);
martydd3 0:e516fcccccda 43 RecieveBuffer.add(Rxmsg);
martydd3 0:e516fcccccda 44 }
martydd3 0:e516fcccccda 45
martydd3 1:e02eb179aed3 46 http://developer.mbed.org/users/AjK/notebook/getting-closer-to-the-hardware/
martydd3 1:e02eb179aed3 47
martydd3 1:e02eb179aed3 48 extern "C" means this is linked assuming it's C code
martydd3 1:e02eb179aed3 49 C++ linker appearently adds extra crap with the function arguments keeping functions of this kind from linking properly
martydd3 1:e02eb179aed3 50
martydd3 1:e02eb179aed3 51 Interrupt handler, This is probably linked to the Timer 2 interrupt request somewhere by the libraries
martydd3 2:baeb80c778f7 52
martydd3 0:e516fcccccda 53 extern "C" void TIMER2_IRQHandler(void)
martydd3 0:e516fcccccda 54 {
martydd3 0:e516fcccccda 55 if((LPC_TIM2->IR & 0x01) == 0x01) // if MR0 interrupt
martydd3 0:e516fcccccda 56 {
martydd3 1:e02eb179aed3 57 // This probably shouldn't be here, never have a printf() in an interrupt, locks up the main thread
martydd3 1:e02eb179aed3 58 // printf("Every 1ms\n\r");
martydd3 1:e02eb179aed3 59
martydd3 0:e516fcccccda 60 LPC_TIM2->IR |= 1 << 0; // Clear MR0 interrupt flag
martydd3 0:e516fcccccda 61
martydd3 1:e02eb179aed3 62 // gonna hope all these calculations are correct
martydd3 1:e02eb179aed3 63 // writes to RTC store, but there's no read code here
martydd3 1:e02eb179aed3 64 // 2 misleading things. First, RTC store writes to a general purpose register
martydd3 1:e02eb179aed3 65 // secondly, no code reads from this register in this .cpp, but maybe some other code does
martydd3 1:e02eb179aed3 66
martydd3 0:e516fcccccda 67 Bat_I_Ratio=BatISense.read();
martydd3 0:e516fcccccda 68 BATA_msec=(((Bat_I_Ratio*3.3) - BAT_ISENSE_OFFSET_V)/BAT_ISENSE_INCREMENT);
martydd3 0:e516fcccccda 69 BATmA_Hr+=(BATA_msec*MSEC_HRS);
martydd3 0:e516fcccccda 70 store.write(BATmA_Hr,0);
martydd3 0:e516fcccccda 71
martydd3 0:e516fcccccda 72 DC_I_Ratio=DCSense.read();
martydd3 0:e516fcccccda 73 DCA_msec=(((DC_I_Ratio*3.3) - DC_DC_ISENSE_OFFSET_V)/DC_DC_ISENSE_INCREMENT);
martydd3 0:e516fcccccda 74 store.write(DCA_msec,1);
martydd3 0:e516fcccccda 75
martydd3 0:e516fcccccda 76 LPC_TIM2->TCR |= (1<<1); //Reset Timer1
martydd3 1:e02eb179aed3 77 LPC_TIM2->TCR &= ~(1<<1); //Re Enable Timer1
martydd3 0:e516fcccccda 78 }
martydd3 0:e516fcccccda 79 }
martydd3 0:e516fcccccda 80
martydd3 1:e02eb179aed3 81 Appears to read a whole bunch of DigitalOut pins in void PollSwitch(), store the value in uint16_t Rxpoll,
martydd3 1:e02eb179aed3 82 and write the result to the CAN bus
martydd3 2:baeb80c778f7 83
martydd3 0:e516fcccccda 84 void Poll()
martydd3 0:e516fcccccda 85 {
martydd3 0:e516fcccccda 86 uint16_t Rxpoll;
martydd3 0:e516fcccccda 87 uint16_t recv,temp,i=0; //Test
martydd3 0:e516fcccccda 88 char Result[4]={0};
martydd3 0:e516fcccccda 89 Rxpoll=PollSwitch();
martydd3 0:e516fcccccda 90
martydd3 0:e516fcccccda 91 Result[0]=(char)(Rxpoll&0x00ff);
martydd3 0:e516fcccccda 92 Result[1]=(char)((Rxpoll&0xff00)>>8);
martydd3 0:e516fcccccda 93 CANMessage Txmsg(410,Result,sizeof(Result));
martydd3 0:e516fcccccda 94 CAN_SysM.write(Txmsg);
martydd3 0:e516fcccccda 95
martydd3 0:e516fcccccda 96 //Test
martydd3 0:e516fcccccda 97 recv=(((uint16_t)Txmsg.data[1]<<8) | (0x00ff&(uint16_t)Txmsg.data[0]));
martydd3 0:e516fcccccda 98 printf("Recv:%d\n\r",recv);
martydd3 0:e516fcccccda 99
martydd3 0:e516fcccccda 100 while(i <= 12)
martydd3 0:e516fcccccda 101 {
martydd3 0:e516fcccccda 102 temp=recv;
martydd3 0:e516fcccccda 103 if(((temp & (1 << i))>>i)==1)
martydd3 0:e516fcccccda 104 pc.printf("Switch OFF:%d\n\r",i);
martydd3 0:e516fcccccda 105 ++i;
martydd3 0:e516fcccccda 106 }
martydd3 0:e516fcccccda 107 }
martydd3 0:e516fcccccda 108
martydd3 0:e516fcccccda 109
martydd3 0:e516fcccccda 110 void Temp()
martydd3 0:e516fcccccda 111 {
martydd3 0:e516fcccccda 112 float DC_DC_Temperature, Coolant1_Temperature, Coolant2_Temperature, ChargerFET_Temperature;
martydd3 0:e516fcccccda 113 float Resistance;
martydd3 0:e516fcccccda 114 float Vadc;
martydd3 0:e516fcccccda 115 int i;
martydd3 0:e516fcccccda 116 ftc send, recv;
martydd3 0:e516fcccccda 117 recv.FLOAT=0.0;
martydd3 0:e516fcccccda 118 send.FLOAT=0.0;
martydd3 0:e516fcccccda 119
martydd3 0:e516fcccccda 120 Vadc=DC_DC.read()*VDD;
martydd3 0:e516fcccccda 121 Resistance=((float)R10K*Vadc)/((float)VDD + Vadc);
martydd3 0:e516fcccccda 122 DC_DC_Temperature=ReadTemp(TR_NXFT15XH103FA_Map, Resistance, TABLE_SIZE_NXFT15XH103FA);
martydd3 0:e516fcccccda 123 send.FLOAT=DC_DC_Temperature;
martydd3 0:e516fcccccda 124 CANMessage Txmsg_DC_DC(450,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 125 CAN_SysM.write(Txmsg_DC_DC);
martydd3 0:e516fcccccda 126
martydd3 0:e516fcccccda 127 for(i=0; i<4;i++)
martydd3 0:e516fcccccda 128 recv.C_FLOAT[i]=Txmsg_DC_DC.data[i];
martydd3 0:e516fcccccda 129 pc.printf("DC_DC:%f\n\r",recv.FLOAT);
martydd3 0:e516fcccccda 130
martydd3 0:e516fcccccda 131 Vadc=ChargerFET.read()*VDD;
martydd3 0:e516fcccccda 132 Resistance=((float)R10K*Vadc)/((float)VDD + Vadc);
martydd3 0:e516fcccccda 133 ChargerFET_Temperature=ReadTemp(TR_NXFT15XH103FA_Map, Resistance, TABLE_SIZE_NXFT15XH103FA);
martydd3 0:e516fcccccda 134 send.FLOAT=ChargerFET_Temperature;
martydd3 0:e516fcccccda 135 CANMessage Txmsg_ChargerFET(451,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 136 CAN_SysM.write(Txmsg_ChargerFET);
martydd3 0:e516fcccccda 137
martydd3 0:e516fcccccda 138 for(i=0; i<4;i++)
martydd3 0:e516fcccccda 139 recv.C_FLOAT[i]=Txmsg_ChargerFET.data[i];
martydd3 0:e516fcccccda 140 pc.printf("ChargerFET:%f\n\r",recv.FLOAT);
martydd3 0:e516fcccccda 141
martydd3 0:e516fcccccda 142 Vadc=Coolant1.read()*VDD;
martydd3 0:e516fcccccda 143 Resistance=((float)R10K*Vadc)/((float)VDD + Vadc);
martydd3 0:e516fcccccda 144 Coolant1_Temperature=ReadTemp(TR_NTCLP00E3103H_Map, Resistance, TABLE_SIZE_NTCLP00E3103H);
martydd3 0:e516fcccccda 145 send.FLOAT=Coolant1_Temperature;
martydd3 0:e516fcccccda 146 CANMessage Txmsg_Coolant1(452,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 147 CAN_SysM.write(Txmsg_Coolant1);
martydd3 0:e516fcccccda 148 //Control Fans
martydd3 0:e516fcccccda 149
martydd3 0:e516fcccccda 150 for(i=0; i<4;i++)
martydd3 0:e516fcccccda 151 recv.C_FLOAT[i]=Txmsg_Coolant1.data[i];
martydd3 0:e516fcccccda 152 pc.printf("Coolant1:%f\n\r",recv.FLOAT);
martydd3 0:e516fcccccda 153
martydd3 0:e516fcccccda 154 Vadc=Coolant2.read()*VDD;
martydd3 0:e516fcccccda 155 Resistance=((float)R10K*Vadc)/((float)VDD + Vadc);
martydd3 0:e516fcccccda 156 Coolant2_Temperature=ReadTemp(TR_NTCLP00E3103H_Map, Resistance, TABLE_SIZE_NTCLP00E3103H);
martydd3 0:e516fcccccda 157 send.FLOAT=Coolant2_Temperature;
martydd3 0:e516fcccccda 158 CANMessage Txmsg_Coolant2(453,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 159 CAN_SysM.write(Txmsg_Coolant2);
martydd3 0:e516fcccccda 160 //Control Fans
martydd3 0:e516fcccccda 161
martydd3 0:e516fcccccda 162 for(i=0; i<4;i++)
martydd3 0:e516fcccccda 163 recv.C_FLOAT[i]=Txmsg_Coolant2.data[i];
martydd3 0:e516fcccccda 164 pc.printf("Coolant2:%f\n\r",recv.FLOAT);
martydd3 0:e516fcccccda 165 }
martydd3 0:e516fcccccda 166
martydd3 0:e516fcccccda 167 void IMD()
martydd3 0:e516fcccccda 168 {
martydd3 0:e516fcccccda 169 IMD_Measurement_Output IMD_Signal;
martydd3 0:e516fcccccda 170 char status[4];
martydd3 0:e516fcccccda 171 ftc send;
martydd3 0:e516fcccccda 172
martydd3 0:e516fcccccda 173 IMD_Signal=Get_Measurement();
martydd3 0:e516fcccccda 174 send.FLOAT=IMD_Signal.Frequency;
martydd3 0:e516fcccccda 175 CANMessage Txmsg_Frequency(421,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 176 CAN_SysM.write(Txmsg_Frequency);
martydd3 0:e516fcccccda 177
martydd3 0:e516fcccccda 178 send.FLOAT=IMD_Signal.Duty_Cycle;
martydd3 0:e516fcccccda 179 CANMessage Txmsg_DutyCycle(422,send.C_FLOAT,sizeof(send.C_FLOAT));
martydd3 0:e516fcccccda 180 CAN_SysM.write(Txmsg_DutyCycle);
martydd3 0:e516fcccccda 181
martydd3 0:e516fcccccda 182 status[0]=Result.Encoded_Status;
martydd3 0:e516fcccccda 183 CANMessage Txmsg_Status(423,status,sizeof(status));
martydd3 0:e516fcccccda 184 CAN_SysM.write(Txmsg_Status);
martydd3 0:e516fcccccda 185 }
martydd3 5:9258b685fea6 186 */
martydd3 0:e516fcccccda 187
martydd3 5:9258b685fea6 188 /*
martydd3 0:e516fcccccda 189 Activates a whole crapload of functions and pins on the chip
martydd3 2:baeb80c778f7 190
martydd3 0:e516fcccccda 191 void Init()
martydd3 0:e516fcccccda 192 {
martydd3 2:baeb80c778f7 193
martydd3 0:e516fcccccda 194 Timers to call various functions at different intervals
martydd3 0:e516fcccccda 195 These things behave weirdly when wait(ms) is involved. Probably have to rewrite
martydd3 2:baeb80c778f7 196
martydd3 0:e516fcccccda 197
martydd3 0:e516fcccccda 198 //ReadIMD.attach(&IMD,0.1);
martydd3 0:e516fcccccda 199 //PollSDSwitch.attach(&Poll,0.1);
martydd3 0:e516fcccccda 200
martydd3 0:e516fcccccda 201 //ReadTemperature.attach(&Temp,0.1);
martydd3 0:e516fcccccda 202 //ReadBatteryState.attach(&Battery,0.1);
martydd3 0:e516fcccccda 203
martydd3 2:baeb80c778f7 204
martydd3 0:e516fcccccda 205 Initialize Timer2 for Battery State
martydd3 0:e516fcccccda 206
martydd3 0:e516fcccccda 207 LPC_SC 0x400F C000 (System Control)
martydd3 0:e516fcccccda 208 ->PCONP 0x400F C0C4 (Power Control for Peripherals Register)
martydd3 0:e516fcccccda 209 |= (1<<22) 22 Bit (Timer 2 power/clock control bit)
martydd3 0:e516fcccccda 210
martydd3 0:e516fcccccda 211 ->PCLKSEL1 Peripheral Clock Selection register 1 (controls rate of clock signal supplied to peripheral)
martydd3 0:e516fcccccda 212 |= ((1<<12) | (1<<13)); 12:13 Bits (Peripheral Clock Selection for TIMER2)
martydd3 0:e516fcccccda 213
martydd3 0:e516fcccccda 214 LPC_TIM2 0x4009 0000 (Timer 2)
martydd3 0:e516fcccccda 215 ->TCR 0x4009 0004 (Timer Control Register)
martydd3 0:e516fcccccda 216 |= (1<<0); 0 Bit (Counter Enable)
martydd3 0:e516fcccccda 217
martydd3 0:e516fcccccda 218 ->MR0 0x4009 0018 (Match Register)
martydd3 0:e516fcccccda 219
martydd3 1:e02eb179aed3 220 ->MCR 0x4009 0014 (Match Control Register) What to do when Match Register matches the Timer Counter
martydd3 1:e02eb179aed3 221 |= (1<<0); 0 Bit (Interrupt on MR0, interrupt generated when MR0 matches the value in TC)
martydd3 0:e516fcccccda 222
martydd3 2:baeb80c778f7 223
martydd3 0:e516fcccccda 224 LPC_SC->PCONP |= (1<<22); //PoewerOn Timer/Counter2
martydd3 0:e516fcccccda 225 LPC_SC->PCLKSEL1 |= ((1<<12) | (1<<13)); //Prescale Timer2 CCLK/8
martydd3 0:e516fcccccda 226 LPC_TIM2->TCR |= (1<<0); //Enable Timer2
martydd3 0:e516fcccccda 227 LPC_TIM2->MR0 = 11999; // 1msec
martydd3 0:e516fcccccda 228 LPC_TIM2->MCR |= (1<<0);
martydd3 2:baeb80c778f7 229
martydd3 1:e02eb179aed3 230 Nested Vectored Interrupt Controller (NVIC)
martydd3 1:e02eb179aed3 231
martydd3 1:e02eb179aed3 232 NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
martydd3 1:e02eb179aed3 233 sets priority of an interrupt
martydd3 1:e02eb179aed3 234
martydd3 1:e02eb179aed3 235 IRQn_Type
martydd3 1:e02eb179aed3 236 Interrupt number definitions
martydd3 1:e02eb179aed3 237 Interrupt Request (IRQ)
martydd3 1:e02eb179aed3 238
martydd3 1:e02eb179aed3 239 NVIC_EnableIRQ(IRQn_Type IRQn)
martydd3 1:e02eb179aed3 240 Enable external interrupt (in this case, the TIMER2_IRQHandler(void) function above gets called every time
martydd3 1:e02eb179aed3 241 Timer2 generates an interrupt signal)
martydd3 1:e02eb179aed3 242
martydd3 2:baeb80c778f7 243
martydd3 0:e516fcccccda 244 NVIC_SetPriority(TIMER0_IRQn,200); //IMD Capture Interrupt
martydd3 0:e516fcccccda 245 NVIC_SetPriority(TIMER1_IRQn,200); //IMD 1msec sampling Interrupt
martydd3 0:e516fcccccda 246 NVIC_SetPriority(TIMER2_IRQn,1); //Battery 1msec sampling Interrupt
martydd3 0:e516fcccccda 247 NVIC_SetPriority(TIMER3_IRQn,255); //mbed Timer/Ticker/Wait Interrupt
martydd3 0:e516fcccccda 248 NVIC_SetPriority(CAN_IRQn,2);
martydd3 0:e516fcccccda 249
martydd3 0:e516fcccccda 250 NVIC_EnableIRQ(TIMER2_IRQn); //Enable TIMER2 IRQ
martydd3 0:e516fcccccda 251
martydd3 0:e516fcccccda 252 CAN_SysM.mode(CAN::GlobalTest);
martydd3 2:baeb80c778f7 253
martydd3 2:baeb80c778f7 254
martydd3 0:e516fcccccda 255 //NVIC_EnableIRQ(CAN_IRQn);
martydd3 0:e516fcccccda 256 //NVIC_EnableIRQ(CANActivity_IRQn);
martydd3 0:e516fcccccda 257 }
martydd3 0:e516fcccccda 258
martydd3 2:baeb80c778f7 259
martydd3 0:e516fcccccda 260 Main Loop: Currently reads CANMessages from Can interface (Pins: rd = p30, td = p29)
martydd3 0:e516fcccccda 261 Send CANMessage data through XBee radio transmitters
martydd3 2:baeb80c778f7 262 */
martydd3 2:baeb80c778f7 263
martydd3 2:baeb80c778f7 264
martydd3 2:baeb80c778f7 265 CANBuffer rxBuffer(CAN1, MEDIUM);
martydd3 2:baeb80c778f7 266 XBee250x XbeeTx;
martydd3 6:6a04210a3f4f 267 Serial pc1(USBTX,USBRX);
martydd3 2:baeb80c778f7 268
martydd3 4:e31528929150 269 char sys_src_id = 4; // source address of system management
martydd3 2:baeb80c778f7 270
martydd3 0:e516fcccccda 271 int main() {
martydd3 7:5f6e31faa08e 272 CANMessage rx_msg;
martydd3 7:5f6e31faa08e 273 Watchdog wdt;
martydd3 7:5f6e31faa08e 274
martydd3 6:6a04210a3f4f 275 wdt.kick(10.0);
martydd3 6:6a04210a3f4f 276 pc1.baud(115200);
martydd3 3:1345f882d8f3 277
martydd3 6:6a04210a3f4f 278 FanPump fanPump(&rxBuffer);
martydd3 6:6a04210a3f4f 279 DC dc_dc(&fanPump, &rxBuffer);
martydd3 7:5f6e31faa08e 280 PollSwitch pollSwitch(&rxBuffer);
martydd3 6:6a04210a3f4f 281
martydd3 6:6a04210a3f4f 282 fanPump.start_update();
martydd3 7:5f6e31faa08e 283 dc_dc.start_update();
martydd3 7:5f6e31faa08e 284 pollSwitch.start_update();
martydd3 5:9258b685fea6 285
martydd3 0:e516fcccccda 286 while(1)
martydd3 0:e516fcccccda 287 {
martydd3 4:e31528929150 288 if(rxBuffer.rxRead(rx_msg)){
martydd3 4:e31528929150 289 char src_addr = (rx_msg.id & 0x0700) >> 8; // get bits 10:8
martydd3 4:e31528929150 290
martydd3 4:e31528929150 291 if(src_addr == sys_src_id){
martydd3 4:e31528929150 292 char cont_id = (rx_msg.id & 0x00FF); // get bits 7:0
martydd3 2:baeb80c778f7 293
martydd3 4:e31528929150 294 // only control fans of dc_dc converter is on
martydd3 6:6a04210a3f4f 295 if(cont_id == RX_FAN_ID && dc_dc.is_on())
martydd3 4:e31528929150 296 {
martydd3 6:6a04210a3f4f 297 fanPump.set_fan((FanSelect)rx_msg.data[0], rx_msg.data[1]);
martydd3 2:baeb80c778f7 298 }
martydd3 2:baeb80c778f7 299
martydd3 6:6a04210a3f4f 300 if(cont_id == RX_DC_DC_ID){
martydd3 6:6a04210a3f4f 301 dc_dc.set(rx_msg.data[0]);
martydd3 4:e31528929150 302 }
martydd3 4:e31528929150 303 } // check for correct src_addr
martydd3 4:e31528929150 304 } // check CANBuffer
martydd3 6:6a04210a3f4f 305
martydd3 6:6a04210a3f4f 306 wdt.kick();
martydd3 4:e31528929150 307 } // main while loop
martydd3 0:e516fcccccda 308 }