f211
Fork of OBD21121 by
Diff: main.cpp
- Revision:
- 16:02f94a84e211
- Parent:
- 15:47abd7926beb
- Child:
- 17:8c76a8b1f46f
--- a/main.cpp Sun Aug 06 11:14:39 2017 +0000 +++ b/main.cpp Mon Aug 07 14:11:10 2017 +0000 @@ -57,7 +57,7 @@ const int incomingDataInOBDSize=256; int incomingDataInOBDCounter=0; const int waitTimeForOBDComm=2000; -const int sleepTime=25000; +const int sleepTime=10000; const int powerSaveTime=30; int OBDCmdReceived=0; int interfaceCmdReceived=0; @@ -152,8 +152,6 @@ //Serial serialPorts[2] = {Serial(P0_11,P0_13),Serial(P0_15,P0_14)}; initPins(); - serialPorts[interFace]->baud(9600); - serialPorts[debug]->baud(9600); serialPorts[debug]->puts("f2120\r\n"); incomingDataInInterFace=(char *)malloc(incomingDataInInterFaceSize*sizeof(char)); incomingDataInOBD=(char *)malloc(incomingDataInOBDSize*sizeof(char)); @@ -432,7 +430,7 @@ *canDisableKey=1; // LPC_SYSCON->SYSAHBCLKCTRL1 |= (1<<7); -// LPC_SWM->PINASSIGN0 = 0xffffffffUL; + LPC_SWM->PINASSIGN0 = 0xffffffffUL; LPC_SWM->PINASSIGN1 = 0xffffffffUL; LPC_SWM->PINASSIGN2 = 0xffffffffUL; LPC_SWM->PINASSIGN3 = 0xffffffffUL; @@ -528,14 +526,21 @@ #if sendDebugMessage serialPorts[debug]->puts("K-Line Check\r\n"); #endif + LPC_SWM->PINASSIGN2 = 0xffffffffUL; *klineWakeup=1; wait_ms(25); *klineWakeup=0; wait_ms(25); *klineWakeup=1; wait_ms(25); - delete klineWakeup; - kLineUART=new Serial(P0_28,P0_27); + //delete klineWakeup; + LPC_SWM->PINASSIGN2 = 0x1B1CFFFFUL; +#if sendDebugMessage + serialPorts[debug]->puts("Bitbang done\r\n"); + serialPorts[debug]->printf("%X",LPC_SWM->PINASSIGN2 ); +#endif + // klineWakeup = new DigitalOut(P0_28); + clearOBDCommand(); kLineUART->baud(10400); kLineUART->attach(&readKLine); @@ -553,7 +558,17 @@ if(incomingDataInOBD[5]!='\0') { currentOBDProtocol=protkLine14230; } - kLineUART->attach(NULL); + +#if sendDebugMessage + serialPorts[debug]->puts("K-Line Check2\r\n"); +#endif + kLineUART->attach(NULL); + /*if(currentOBDProtocol!=protkLine14230){ + delete kLineUART; + kLineUART=NULL; + LPC_SWM->PINASSIGN2 = 0xffffffffUL; + klineWakeup = new DigitalOut(P0_28); + }*/ return 0; } @@ -767,11 +782,14 @@ LPC_SWM->PINASSIGN5 = 0xffffffffUL; LPC_SWM->PINASSIGN8 = 0xffffffffUL; // LPC_SYSCON->SYSAHBCLKCTRL1 |= (0<<7); - serialPorts[0] = new Serial(P0_11,P0_13); - serialPorts[1] = new Serial(P0_15,P0_14); - /* serialPorts[0] = new Serial(P0_16,P0_12); - serialPorts[1] = new Serial(USBTX,USBRX);*/ + /* serialPorts[0] = new Serial(P0_11,P0_13); + serialPorts[1] = new Serial(P0_15,P0_14);*/ + serialPorts[0] = new Serial(P0_16,P0_12); + serialPorts[1] = new Serial(USBTX,USBRX); klineWakeup = new DigitalOut(P0_28); canBus = new CAN(P0_22, P0_23); canDisableKey=new DigitalOut(P0_0,0); + kLineUART=new Serial(P0_28,P0_27); + serialPorts[interFace]->baud(9600); + serialPorts[debug]->baud(9600); } \ No newline at end of file