This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
#define adjust2dTableAxis 200 |
#define adjust2dTableCell 202 |
#define adjustMainTableCell 100 |
#define adjustMainTableLoadAxis 104 |
#define adjustMainTableRPMAxis 102 |
#define asyncDebugInfoPacket 15 |
#define asyncErrorCodePacket 13 |
#define burnBlockFromRamToFlash 8 |
#define CHTTransferTableLocationID 27 |
#define CLEAR_ALL_SOURCE_ID_FLAGS ZEROS |
Definition at line 66 of file commsCore.h.
Referenced by decodePacketAndBuildResponse(), and SCI0ISR().
#define COM_CLEAR_CAN0_INTERFACE_ID NBIT1 |
#define COM_CLEAR_SCI0_INTERFACE_ID NBIT0 |
#define COM_CLEAR_SPARE2_INTERFACE_ID NBIT2 |
#define COM_CLEAR_SPARE3_INTERFACE_ID NBIT3 |
#define COM_CLEAR_SPARE4_INTERFACE_ID NBIT4 |
#define COM_CLEAR_SPARE5_INTERFACE_ID NBIT5 |
#define COM_CLEAR_SPARE6_INTERFACE_ID NBIT6 |
#define COM_CLEAR_SPARE7_INTERFACE_ID NBIT7 |
#define COM_SET_CAN0_INTERFACE_ID BIT1 |
Definition at line 51 of file commsCore.h.
Referenced by checksumAndSend(), and resetReceiveState().
#define COM_SET_SCI0_INTERFACE_ID BIT0 |
Definition at line 50 of file commsCore.h.
Referenced by checksumAndSend(), decodePacketAndBuildResponse(), resetReceiveState(), and SCI0ISR().
#define COM_SET_SPARE2_INTERFACE_ID BIT2 |
#define COM_SET_SPARE3_INTERFACE_ID BIT3 |
#define COM_SET_SPARE4_INTERFACE_ID BIT4 |
#define COM_SET_SPARE5_INTERFACE_ID BIT5 |
#define COM_SET_SPARE6_INTERFACE_ID BIT6 |
#define COM_SET_SPARE7_INTERFACE_ID BIT7 |
#define EXTERN extern |
Definition at line 32 of file commsCore.h.
#define FixedConfig2LocationID 25 |
#define FixedConfigLocationID 24 |
#define forwardPacketOverCAN 400 |
#define forwardPacketOverUART 402 |
#define HEADER_HAS_ACK BIT1 |
#define HEADER_HAS_ADDRS BIT3 |
#define HEADER_HAS_LENGTH BIT4 |
#define HEADER_IS_NACK BIT2 |
Definition at line 130 of file commsCore.h.
#define HEADER_IS_PROTO BIT0 |
#define HEADER_USER_BIT_A BIT5 |
Definition at line 133 of file commsCore.h.
#define HEADER_USER_BIT_B BIT6 |
Definition at line 134 of file commsCore.h.
#define HEADER_USER_BIT_C BIT7 |
Definition at line 135 of file commsCore.h.
#define IATTransferTableLocationID 26 |
#define IgnitionAdvanceTableMainFlash2LocationID 9 |
#define IgnitionAdvanceTableMainFlashLocationID 8 |
#define IgnitionAdvanceTableSecondaryFlash2LocationID 11 |
#define IgnitionAdvanceTableSecondaryFlashLocationID 10 |
#define InjectionAdvanceTableMainFlash2LocationID 13 |
#define InjectionAdvanceTableMainFlashLocationID 12 |
#define InjectionAdvanceTableSecondaryFlash2LocationID 15 |
#define InjectionAdvanceTableSecondaryFlashLocationID 14 |
#define invalidFlashLocationID 406 |
Definition at line 192 of file commsCore.h.
#define invalidRAMLocationID 404 |
Definition at line 191 of file commsCore.h.
#define LambdaTableFlash2LocationID 7 |
#define LambdaTableFlashLocationID 6 |
#define MAFTransferTableLocationID 28 |
#define replace2dTableInRAM 204 |
#define replaceBlockInFlash 2 |
#define replaceBlockInRAM 0 |
#define requestAdjustableDatalog 302 |
#define requestBasicDatalog 300 |
#define requestEchoPacketReturn 6 |
#define requestFirmwareVersion 2 |
#define requestHardSystemReset 10 |
#define requestInterfaceVersion 0 |
#define requestMaxPacketSize 4 |
#define requestSoftSystemReset 8 |
#define retrieveBlockFromFlash 6 |
#define retrieveBlockFromRAM 4 |
#define RX_CLEAR_READY_TO_PROCESS NBIT1 |
#define RX_READY_TO_PROCESS BIT1 |
#define RX_SCI_ESCAPED_NEXT BIT2 |
#define RX_SCI_NOT_ESCAPED_NEXT NBIT2 |
#define SCICR2_RX_DISABLE NBIT2 |
#define SCICR2_RX_ENABLE BIT2 |
#define SCICR2_RX_ISR_DISABLE NBIT5 |
#define SCICR2_RX_ISR_ENABLE BIT5 |
Definition at line 92 of file commsCore.h.
Referenced by main(), resetReceiveState(), and SCI0ISR().
#define SCICR2_TX_DISABLE NBIT3 |
Definition at line 95 of file commsCore.h.
#define SCICR2_TX_ENABLE BIT3 |
Definition at line 91 of file commsCore.h.
#define SCICR2_TX_ISR_DISABLE NBIT7 |
#define SCICR2_TX_ISR_ENABLE BIT7 |
#define SmallTablesAFlash2LocationID 17 |
#define SmallTablesAFlashLocationID 16 |
#define SmallTablesBFlash2LocationID 19 |
#define SmallTablesBFlashLocationID 18 |
#define SmallTablesCFlash2LocationID 21 |
#define SmallTablesCFlashLocationID 20 |
#define SmallTablesDFlash2LocationID 23 |
#define SmallTablesDFlashLocationID 22 |
#define VETableMainFlash2LocationID 1 |
#define VETableMainFlashLocationID 0 |
#define VETableSecondaryFlash2LocationID 3 |
#define VETableSecondaryFlashLocationID 2 |
#define VETableTertiaryFlash2LocationID 5 |
#define VETableTertiaryFlashLocationID 4 |
EXTERN void decodePacketAndBuildResponse | ( | void | ) |
Definition at line 98 of file commsCore.c.
References _start(), adjust2dTableAxis, adjust2dTableCell, adjustMainTableCell, adjustMainTableLoadAxis, adjustMainTableRPMAxis, BIT0, burnBlockFromRamToFlash, checksumAndSend(), CLEAR_ALL_SOURCE_ID_FLAGS, COM_SET_SCI0_INTERFACE_ID, currentFuelRPage, firmwareVersion, fixedConfigs, blockDetails::FlashAddress, blockDetails::FlashPage, forwardPacketOverCAN, forwardPacketOverUART, hardReset(), HEADER_HAS_ACK, HEADER_HAS_ADDRS, HEADER_HAS_LENGTH, HEADER_IS_PROTO, interfaceVersionAndType, invalidFirmwarePayloadID, invalidMemoryActionForID, invalidProtocolPayloadID, invalidSourceAddress, lookupBlockDetails(), MAINTABLE_MAX_LOAD_LENGTH, MAINTABLE_MAX_MAIN_LENGTH, MAINTABLE_MAX_RPM_LENGTH, fixedConfig::networkAddress, payloadLengthHeaderMismatch, payloadLengthTypeMismatch, PORTB, PORTK, PPAGE, blockDetails::RAMAddress, blockDetails::RAMPage, replace2dTableInRAM, replaceBlockInFlash, replaceBlockInRAM, requestAdjustableDatalog, requestBasicDatalog, requestEchoPacketReturn, requestFirmwareVersion, requestHardSystemReset, requestInterfaceVersion, requestMaxPacketSize, requestSoftSystemReset, resetReceiveState(), retrieveBlockFromFlash, retrieveBlockFromRAM, RPAGE, RX_BUFFER_SIZE, RXBufferCurrentPosition, RXCalculatedPayloadLength, RXHeaderFlags, RXHeaderPayloadID, RXHeaderPayloadLength, RXHeaderSourceAddress, RXPacketLengthReceived, sendDebug(), sendError(), setPagedMainTableCellValue(), setPagedMainTableLoadValue(), setPagedMainTableRPMValue(), blockDetails::size, TXBufferCurrentPositionCAN0, TXBufferCurrentPositionHandler, TXBufferCurrentPositionSCI0, TXBufferInUseFlags, unimplementedFunction, unrecognisedFirmwarePayloadID, unrecognisedProtocolPayloadID, validateMainTable(), validateTwoDTable(), and writeAlignedBlock().
Referenced by main().
00098 { 00099 /* Extract and build up the header fields */ 00100 RXBufferCurrentPosition = (unsigned char*)&RXBuffer; 00101 TXBufferCurrentPositionHandler = (unsigned char*)&TXBuffer; 00102 00103 /* Initialised here such that override is possible */ 00104 TXBufferCurrentPositionSCI0 = (unsigned char*)&TXBuffer; 00105 TXBufferCurrentPositionCAN0 = (unsigned char*)&TXBuffer; 00106 00107 /* Start this off as full packet length and build down to the actual length */ 00108 RXCalculatedPayloadLength = RXPacketLengthReceived; 00109 00110 /* Grab the RX header flags out of the RX buffer */ 00111 RXHeaderFlags = *RXBufferCurrentPosition; 00112 RXBufferCurrentPosition++; 00113 RXCalculatedPayloadLength--; 00114 00115 /* Flag that we are transmitting! */ 00116 TXBufferInUseFlags |= COM_SET_SCI0_INTERFACE_ID; 00117 // SCI0 only for now... 00118 00119 /* Load a blank header into the TX buffer ready for masking */ 00120 unsigned char* TXHeaderFlags = TXBufferCurrentPositionHandler; 00121 *TXHeaderFlags = 0; 00122 TXBufferCurrentPositionHandler++; 00123 00124 /* Grab the payload ID for processing and load the return ID */ 00125 RXHeaderPayloadID = *((unsigned short*)RXBufferCurrentPosition); 00126 *((unsigned short*)TXBufferCurrentPositionHandler) = RXHeaderPayloadID + 1; 00127 RXBufferCurrentPosition += 2; 00128 TXBufferCurrentPositionHandler += 2; 00129 RXCalculatedPayloadLength -= 2; 00130 00131 /* If there is an ack, copy it to the return packet */ 00132 if(RXHeaderFlags & HEADER_HAS_ACK){ 00133 *TXBufferCurrentPositionHandler = *RXBufferCurrentPosition; 00134 *TXHeaderFlags |= HEADER_HAS_ACK; 00135 RXBufferCurrentPosition++; 00136 TXBufferCurrentPositionHandler++; 00137 RXCalculatedPayloadLength--; 00138 } 00139 00140 /* If the header has addresses, check them and if OK copy them */ 00141 if(RXHeaderFlags & HEADER_HAS_ADDRS){ 00142 /* Check the destination address against our address */ 00143 if(!(*RXBufferCurrentPosition == fixedConfigs.networkAddress)){ 00144 /* Addresses do not match, discard packet without error */ 00145 resetReceiveState(CLEAR_ALL_SOURCE_ID_FLAGS); 00146 TXBufferInUseFlags = 0; 00147 return; 00148 } 00149 RXBufferCurrentPosition++; 00150 00151 /* Save and check the source address */ 00152 RXHeaderSourceAddress = *RXBufferCurrentPosition; 00153 RXBufferCurrentPosition++; 00154 if(RXHeaderSourceAddress == 0){ 00155 sendError(invalidSourceAddress); 00156 resetReceiveState(CLEAR_ALL_SOURCE_ID_FLAGS); 00157 return; 00158 } 00159 00160 /* All is well, setup reply addresses */ 00161 *TXHeaderFlags |= HEADER_HAS_ADDRS; 00162 /* TX destination = RX source */ 00163 *TXBufferCurrentPositionHandler = RXHeaderSourceAddress; 00164 TXBufferCurrentPositionHandler++; 00165 /* TX source = our address */ 00166 *TXBufferCurrentPositionHandler = fixedConfigs.networkAddress; 00167 TXBufferCurrentPositionHandler++; 00168 /* Decrement for both at once to save a cycle */ 00169 RXCalculatedPayloadLength -= 2; 00170 } 00171 00172 /* Grab the length if available */ 00173 if(RXHeaderFlags & HEADER_HAS_LENGTH){ 00174 RXHeaderPayloadLength = *((unsigned short*)RXBufferCurrentPosition); 00175 RXBufferCurrentPosition += 2; 00176 RXCalculatedPayloadLength -= 2; 00177 /* Minus one for the checksum on the end ;-) */ 00178 if(RXHeaderPayloadLength != (RXCalculatedPayloadLength - 1)){ 00179 sendError(payloadLengthHeaderMismatch); 00180 resetReceiveState(CLEAR_ALL_SOURCE_ID_FLAGS); 00181 return; 00182 } 00183 } 00184 00185 /* Please Note : */ 00186 /* length (and it's flag) should be set by each return packet type handler if required or desired. */ 00187 /* If an ack has been requested, ensure the negative ack flag is set if the opration failed. */ 00188 00189 /* Perform the requested action based on payload ID */ 00190 if (RXHeaderFlags & HEADER_IS_PROTO){ /* Protocol payload types */ 00191 /* Set the return type to be protocol too */ 00192 *TXHeaderFlags |= HEADER_IS_PROTO; 00193 00194 switch (RXHeaderPayloadID){ 00195 case requestInterfaceVersion: 00196 /* Subtract one to exclude checksum */ 00197 if((RXCalculatedPayloadLength - 1) != 0){ 00198 sendError(payloadLengthTypeMismatch); 00199 break; 00200 } 00201 /* This type must have a length field, set that up */ 00202 *((unsigned short*)TXBufferCurrentPositionHandler) = sizeof(interfaceVersionAndType); 00203 *TXHeaderFlags |= HEADER_HAS_LENGTH; 00204 TXBufferCurrentPositionHandler += 2; 00205 /* Load the body into place */ 00206 memcpy((void*)TXBufferCurrentPositionHandler, (void*)&interfaceVersionAndType, sizeof(interfaceVersionAndType)); 00207 TXBufferCurrentPositionHandler += sizeof(interfaceVersionAndType); 00208 checksumAndSend(); 00209 break; 00210 case requestFirmwareVersion: 00211 /* Subtract one to exclude checksum */ 00212 if((RXCalculatedPayloadLength - 1) != 0){ 00213 sendError(payloadLengthTypeMismatch); 00214 break; 00215 } 00216 /* This type must have a length field, set that up */ 00217 *((unsigned short*)TXBufferCurrentPositionHandler) = sizeof(firmwareVersion); 00218 *TXHeaderFlags |= HEADER_HAS_LENGTH; 00219 TXBufferCurrentPositionHandler += 2; 00220 /* Load the body into place */ 00221 memcpy((void*)TXBufferCurrentPositionHandler, (void*)&firmwareVersion, sizeof(firmwareVersion)); 00222 TXBufferCurrentPositionHandler += sizeof(firmwareVersion); 00223 checksumAndSend(); 00224 break; 00225 case requestMaxPacketSize: 00226 /* Subtract one to exclude checksum */ 00227 if((RXCalculatedPayloadLength - 1) != 0){ 00228 sendError(payloadLengthTypeMismatch); 00229 break; 00230 } 00231 /* Load the size into place */ 00232 *((unsigned short*)TXBufferCurrentPositionHandler) = RX_BUFFER_SIZE; 00233 TXBufferCurrentPositionHandler += 2; 00234 checksumAndSend(); 00235 break; 00236 case requestEchoPacketReturn: 00237 /* This type must have a length field, set that up */ 00238 *((unsigned short*)TXBufferCurrentPositionHandler) = RXPacketLengthReceived; 00239 *TXHeaderFlags |= HEADER_HAS_LENGTH; 00240 TXBufferCurrentPositionHandler += 2; 00241 /* Load the body into place */ 00242 memcpy((void*)TXBufferCurrentPositionHandler, (void*)&RXBuffer, RXPacketLengthReceived); 00243 /* Note, there is no overflow check here because the TX buffer is slightly */ 00244 /* bigger than the RX buffer and there is overflow checking for receives anyway. */ 00245 TXBufferCurrentPositionHandler += RXPacketLengthReceived; 00246 checksumAndSend(); 00247 break; 00248 case requestSoftSystemReset: 00249 /* Subtract one to exclude checksum */ 00250 if((RXCalculatedPayloadLength - 1) != 0){ 00251 sendError(payloadLengthTypeMismatch); 00252 break; 00253 } 00254 /* Perform soft system reset */ 00255 _start(); 00256 case requestHardSystemReset: 00257 /* Subtract one to exclude checksum */ 00258 if((RXCalculatedPayloadLength - 1) != 0){ 00259 sendError(payloadLengthTypeMismatch); 00260 break; 00261 } 00262 /* Perform full hard system reset */ 00263 hardReset(); 00264 // Currently, corrupted memory instead of reset as of paged flash setup being introduced TODO FIXME this is broken... 00265 00266 /* 0xFFFE is the master reset vector. Using _start() */ 00267 /* only resets the app ignoring the monitor switch. */ 00268 /* It does not work properly because the location of */ 00269 /* _start is not the master reset vector location. */ 00270 default: 00271 if((RXHeaderPayloadID % 2) == 1){ 00272 sendError(invalidProtocolPayloadID); 00273 }else{ 00274 sendError(unrecognisedProtocolPayloadID); 00275 } 00276 } 00277 }else{ /* Otherwise firmware payload types */ 00278 switch (RXHeaderPayloadID) { 00279 case replaceBlockInRAM: 00280 { 00281 int id = PORTB; 00282 if(id < 16){ 00283 mainTable aTable; 00284 validateMainTable(&aTable); 00285 }else if(id > 27 && id < 50){ 00286 twoDTableUS aTable; 00287 validateTwoDTable(&aTable); 00288 } 00289 00290 00291 // /* Save page values for restore */ 00292 // unsigned char oldRamPage = RPAGE; 00293 // unsigned char oldFlashPage = PPAGE; 00294 // 00295 // 00296 // if((details->RAMPage == 0) || (details->RAMAddress == 0)){ 00297 // return bugInMemoryBlockCode; 00298 // } 00299 // /* Set the viewable ram page */ 00300 // RPAGE = details->RAMPage; 00301 // /* Copy from the RX buffer to the block of ram */ 00302 // memcpy(details->RAMAddress, RXBufferCurrentPosition, details->size); 00303 // 00304 // 00305 // /* Restore the original ram and flash pages */ 00306 // RPAGE = oldRamPage; 00307 // PPAGE = oldFlashPage; 00308 // 00309 00310 00311 // perform function TODO 00312 sendError(unimplementedFunction); 00313 break; 00314 } 00315 case replaceBlockInFlash: 00316 { 00317 // if 0 - 15 validate table 00318 mainTable aTable; 00319 validateMainTable(&aTable); 00320 // otherwise hope for the best 00321 00322 // check size > 0 and % 1024 != 0 same for ram to flash TODO 00323 00324 // /* Save page values for restore */ 00325 // unsigned char oldRamPage = RPAGE; 00326 // unsigned char oldFlashPage = PPAGE; 00327 // 00328 // 00329 // if((details->FlashPage == 0) || (details->FlashAddress == 0)){ 00330 // return bugInMemoryBlockCode; 00331 // } 00332 // /* Set the viewable flash page */ 00333 // PPAGE = details->FlashPage; 00334 // /* Copy from the RX buffer to the block of flash */ 00335 // error = writeAlignedBlock((unsigned short*)details->FlashAddress, (unsigned short*)RXBufferCurrentPosition); 00336 // /* If present in ram, update that too */ 00337 // if((details->RAMPage != 0) && (details->RAMAddress != 0)){ 00338 // /* Set the viewable ram page */ 00339 // RPAGE = details->RAMPage; 00340 // /* Copy from the RX buffer to the block of ram */ 00341 // memcpy(details->RAMAddress, RXBufferCurrentPosition, details->size); 00342 // } 00343 // 00344 // 00345 // /* Restore the original ram and flash pages */ 00346 // RPAGE = oldRamPage; 00347 // PPAGE = oldFlashPage; 00348 // 00349 00350 00351 // perform function TODO 00352 sendError(unimplementedFunction); 00353 break; 00354 } 00355 case retrieveBlockFromRAM: 00356 { 00357 /* Subtract one to exclude checksum */ 00358 if((RXCalculatedPayloadLength - 1) != 2){ 00359 sendError(payloadLengthTypeMismatch); 00360 break; 00361 } 00362 /* Extract the ram location ID from the received data */ 00363 unsigned short locationID = *((unsigned short*)RXBufferCurrentPosition); 00364 /* Store it back into the output data */ 00365 *(unsigned short*)TXBufferCurrentPositionHandler = locationID; 00366 TXBufferCurrentPositionHandler += 2; 00367 00368 /* If it's a main table we are returning, specify the limits explicitly */ 00369 if(locationID < 16){ 00370 /* Store it back into the output data */ 00371 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_RPM_LENGTH; 00372 TXBufferCurrentPositionHandler += 2; 00373 /* Store it back into the output data */ 00374 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_LOAD_LENGTH; 00375 TXBufferCurrentPositionHandler += 2; 00376 /* Store it back into the output data */ 00377 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_MAIN_LENGTH; 00378 TXBufferCurrentPositionHandler += 2; 00379 } 00380 00381 /* Look up the memory location details */ 00382 blockDetails details; 00383 lookupBlockDetails(locationID, &details); 00384 00385 if((details.RAMPage == 0) || (details.RAMAddress == 0)){ 00386 sendError(invalidMemoryActionForID); 00387 break; 00388 } 00389 00390 /* Save page value for restore and set the visible page */ 00391 unsigned char oldRamPage = RPAGE; 00392 RPAGE = details.RAMPage; 00393 00394 /* Copy the block of ram to the TX buffer */ 00395 memcpy(TXBufferCurrentPositionHandler, details.RAMAddress, details.size); 00396 TXBufferCurrentPositionHandler += details.size; 00397 00398 /* Restore the original ram and flash pages */ 00399 RPAGE = oldRamPage; 00400 00401 checksumAndSend(); 00402 break; 00403 } 00404 case retrieveBlockFromFlash: 00405 { 00406 /* Subtract one to exclude checksum */ 00407 if((RXCalculatedPayloadLength - 1) != 2){ 00408 sendError(payloadLengthTypeMismatch); 00409 break; 00410 } 00411 00412 /* Extract the flash location ID from the received data */ 00413 unsigned short locationID = *((unsigned short*)RXBufferCurrentPosition); 00414 /* Store it back into the output data */ 00415 *(unsigned short*)TXBufferCurrentPositionHandler = locationID; 00416 TXBufferCurrentPositionHandler += 2; 00417 00418 /* If it's a main table we are returning, specify the limits explicitly */ 00419 if(locationID < 16){ 00420 /* Store it back into the output data */ 00421 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_RPM_LENGTH; 00422 TXBufferCurrentPositionHandler += 2; 00423 /* Store it back into the output data */ 00424 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_LOAD_LENGTH; 00425 TXBufferCurrentPositionHandler += 2; 00426 /* Store it back into the output data */ 00427 *(unsigned short*)TXBufferCurrentPositionHandler = MAINTABLE_MAX_MAIN_LENGTH; 00428 TXBufferCurrentPositionHandler += 2; 00429 } 00430 00431 /* Look up the memory location details */ 00432 blockDetails details; 00433 lookupBlockDetails(locationID, &details); 00434 00435 if((details.FlashPage == 0) || (details.FlashAddress == 0)){ 00436 sendError(invalidMemoryActionForID); 00437 break; 00438 } 00439 00440 /* Save page value for restore and set the visible page */ 00441 unsigned char oldFlashPage = PPAGE; 00442 PPAGE = details.FlashPage; 00443 00444 /* Copy the block of flash to the TX buffer */ 00445 memcpy(TXBufferCurrentPositionHandler, details.FlashAddress, details.size); 00446 TXBufferCurrentPositionHandler += details.size; 00447 00448 /* Restore the original ram and flash pages */ 00449 PPAGE = oldFlashPage; 00450 00451 checksumAndSend(); 00452 break; 00453 } 00454 case burnBlockFromRamToFlash: 00455 { 00456 // perform function TODO 00457 writeAlignedBlock((unsigned short*)0x7c00, (unsigned short*)0xc000); 00458 00459 // unsigned char old = PPAGE; 00460 // PPAGE = BIGTABLES_PPAGE; 00461 // writeAlignedBlock((unsigned short*)&VETableMainFlash, (unsigned short*)0xC000); 00462 // PPAGE = old; 00463 //sendError(unimplementedFunction); 00464 // PORTB = ONES; 00465 00466 // check size > 0 and % 1024 != 0 same for ram to flash TODO 00467 00468 // /* Save page values for restore */ 00469 // unsigned char oldRamPage = RPAGE; 00470 // unsigned char oldFlashPage = PPAGE; 00471 // 00472 // 00473 // if((details->RAMPage == 0) || (details->RAMAddress == 0) || (details->FlashPage == 0) || (details->FlashAddress == 0)){ 00474 // return bugInMemoryBlockCode; 00475 // } 00476 // /* Set the viewable ram and flash pages */ 00477 // RPAGE = details->RAMPage; 00478 // PPAGE = details->FlashPage; 00479 // error = writeAlignedBlock((unsigned short*)details->FlashAddress, (unsigned short*)details->RAMAddress); 00480 // 00481 // 00482 // /* Restore the original ram and flash pages */ 00483 // RPAGE = oldRamPage; 00484 // PPAGE = oldFlashPage; 00485 00486 00487 00488 sendDebug("Burn Ran!"); 00489 break; 00490 } 00491 case adjustMainTableCell: 00492 { 00493 // extract id 00494 // extract value 00495 // extract indices x 2 00496 // lookup addresses 00497 mainTable aTable; 00498 validateMainTable(&aTable); 00499 /* Test */ 00500 setPagedMainTableCellValue(&TablesA.VETableMain, 0, 0, 32768, currentFuelRPage); 00501 // perform function TODO 00502 sendError(unimplementedFunction); 00503 break; 00504 } 00505 case adjustMainTableRPMAxis: 00506 { 00507 // extract id 00508 // extract value 00509 // extract index 00510 // lookup addresses 00511 mainTable aTable; 00512 validateMainTable(&aTable); 00513 /* Test */ 00514 setPagedMainTableRPMValue(&TablesA.VETableMain, 0, 0, currentFuelRPage); 00515 // perform function TODO 00516 sendError(unimplementedFunction); 00517 break; 00518 } 00519 case adjustMainTableLoadAxis: 00520 { 00521 // extract id 00522 // extract value 00523 // extract index 00524 // lookup addresses 00525 mainTable aTable; 00526 validateMainTable(&aTable); 00527 /* Test */ 00528 setPagedMainTableLoadValue(&TablesA.VETableMain, 0, 0, currentFuelRPage); 00529 // perform function TODO 00530 sendError(unimplementedFunction); 00531 break; 00532 } 00533 case adjust2dTableAxis: 00534 // extract id 00535 // extract value 00536 // extract index 00537 // lookup addresses 00538 00539 // perform function TODO 00540 sendError(unimplementedFunction); 00541 break; 00542 case adjust2dTableCell: 00543 // extract id 00544 // extract value 00545 // extract index 00546 // lookup addresses 00547 00548 // perform function TODO 00549 sendError(unimplementedFunction); 00550 break; 00551 case replace2dTableInRAM: 00552 { 00553 // extract id 00554 // lookup addresses 00555 twoDTableUS aTable; 00556 validateTwoDTable(&aTable); 00557 // perform function TODO 00558 sendError(unimplementedFunction); 00559 break; 00560 } 00561 case requestBasicDatalog: 00562 // perform function TODO 00563 sendError(unimplementedFunction); 00564 break; 00565 case requestAdjustableDatalog: 00566 // perform function TODO 00567 sendError(unimplementedFunction); 00568 break; 00569 case forwardPacketOverCAN: 00570 // perform function TODO 00571 sendError(unimplementedFunction); 00572 break; 00573 case forwardPacketOverUART: 00574 // perform function TODO 00575 sendError(unimplementedFunction); 00576 break; 00577 default: 00578 if((RXHeaderPayloadID % 2) == 1){ 00579 sendError(invalidFirmwarePayloadID); 00580 }else{ 00581 sendError(unrecognisedFirmwarePayloadID); 00582 } 00583 } 00584 } 00585 /* Switch reception back on now that we are done with the received data */ 00586 resetReceiveState(CLEAR_ALL_SOURCE_ID_FLAGS); 00587 PORTK |= BIT0; 00588 }
Here is the call graph for this function:
void hardReset | ( | void | ) |
Referenced by decodePacketAndBuildResponse().
EXTERN void lookupBlockDetails | ( | unsigned | short, | |
blockDetails * | ||||
) |
Definition at line 594 of file commsCore.c.
References BIGTABLES_PPAGE, CHTTransferTable, CHTTransferTableLocationID, FixedConfig2LocationID, FixedConfigLocationID, fixedConfigs, fixedConfigs2, blockDetails::FlashAddress, blockDetails::FlashPage, IATTransferTable, IATTransferTableLocationID, IgnitionAdvanceTableMainFlash, IgnitionAdvanceTableMainFlash2, IgnitionAdvanceTableMainFlash2LocationID, IgnitionAdvanceTableMainFlashLocationID, IgnitionAdvanceTableSecondaryFlash, IgnitionAdvanceTableSecondaryFlash2, IgnitionAdvanceTableSecondaryFlash2LocationID, IgnitionAdvanceTableSecondaryFlashLocationID, InjectionAdvanceTableMainFlash, InjectionAdvanceTableMainFlash2, InjectionAdvanceTableMainFlash2LocationID, InjectionAdvanceTableMainFlashLocationID, InjectionAdvanceTableSecondaryFlash, InjectionAdvanceTableSecondaryFlash2, InjectionAdvanceTableSecondaryFlash2LocationID, InjectionAdvanceTableSecondaryFlashLocationID, LambdaTableFlash, LambdaTableFlash2, LambdaTableFlash2LocationID, LambdaTableFlashLocationID, MAFTransferTable, MAFTransferTableLocationID, MAINTABLE_SIZE, PPAGE, blockDetails::RAMAddress, blockDetails::RAMPage, RPAGE_FUEL_ONE, RPAGE_FUEL_TWO, RPAGE_TIME_ONE, RPAGE_TIME_TWO, RPAGE_TUNE_ONE, RPAGE_TUNE_TWO, blockDetails::size, SmallTablesAFlash, SmallTablesAFlash2, SmallTablesAFlash2LocationID, SmallTablesAFlashLocationID, SmallTablesBFlash, SmallTablesBFlash2, SmallTablesBFlash2LocationID, SmallTablesBFlashLocationID, SmallTablesCFlash, SmallTablesCFlash2, SmallTablesCFlash2LocationID, SmallTablesCFlashLocationID, SmallTablesDFlash, SmallTablesDFlash2, SmallTablesDFlash2LocationID, SmallTablesDFlashLocationID, TransferTableSize, VETableMainFlash, VETableMainFlash2, VETableMainFlash2LocationID, VETableMainFlashLocationID, VETableSecondaryFlash, VETableSecondaryFlash2, VETableSecondaryFlash2LocationID, VETableSecondaryFlashLocationID, VETableTertiaryFlash, VETableTertiaryFlash2, VETableTertiaryFlash2LocationID, and VETableTertiaryFlashLocationID.
Referenced by decodePacketAndBuildResponse().
00594 { 00595 /* Initialise the four values needed for operations on memory at 0 for error checking */ 00596 details->RAMPage = 0; 00597 details->FlashPage = 0; 00598 details->RAMAddress = 0; 00599 details->FlashAddress = 0; 00600 00601 /* Initialise the block size to 1024 to save code space and increase readability */ 00602 details->size = MAINTABLE_SIZE; 00603 00604 /* Look up the locations and set non default sizes */ 00605 switch (locationID) { 00606 case FixedConfigLocationID: 00607 details->FlashPage = PPAGE; 00608 details->FlashAddress = (void*)&fixedConfigs; 00609 break; 00610 case FixedConfig2LocationID: 00611 details->FlashPage = PPAGE; 00612 details->FlashAddress = (void*)&fixedConfigs2; 00613 break; 00614 case IATTransferTableLocationID: 00615 details->size = TransferTableSize; 00616 details->FlashPage = PPAGE; 00617 details->FlashAddress = (void*)&IATTransferTable; 00618 break; 00619 case CHTTransferTableLocationID: 00620 details->size = TransferTableSize; 00621 details->FlashPage = PPAGE; 00622 details->FlashAddress = (void*)&CHTTransferTable; 00623 break; 00624 case MAFTransferTableLocationID: 00625 details->size = TransferTableSize; 00626 details->FlashPage = PPAGE; 00627 details->FlashAddress = (void*)&MAFTransferTable; 00628 break; 00629 case VETableMainFlashLocationID: 00630 details->RAMPage = RPAGE_FUEL_ONE; 00631 details->FlashPage = BIGTABLES_PPAGE; 00632 details->RAMAddress = (void*)&TablesA; 00633 details->FlashAddress = (void*)&VETableMainFlash; 00634 break; 00635 case VETableMainFlash2LocationID: 00636 details->RAMPage = RPAGE_FUEL_TWO; 00637 details->FlashPage = BIGTABLES_PPAGE; 00638 details->RAMAddress = (void*)&TablesA; 00639 details->FlashAddress = (void*)&VETableMainFlash2; 00640 break; 00641 case VETableSecondaryFlashLocationID: 00642 details->RAMPage = RPAGE_FUEL_ONE; 00643 details->FlashPage = BIGTABLES_PPAGE; 00644 details->RAMAddress = (void*)&TablesB; 00645 details->FlashAddress = (void*)&VETableSecondaryFlash; 00646 break; 00647 case VETableSecondaryFlash2LocationID: 00648 details->RAMPage = RPAGE_FUEL_TWO; 00649 details->FlashPage = BIGTABLES_PPAGE; 00650 details->RAMAddress = (void*)&TablesB; 00651 details->FlashAddress = (void*)&VETableSecondaryFlash2; 00652 break; 00653 case VETableTertiaryFlashLocationID: 00654 details->RAMPage = RPAGE_FUEL_ONE; 00655 details->FlashPage = BIGTABLES_PPAGE; 00656 details->RAMAddress = (void*)&TablesC; 00657 details->FlashAddress = (void*)&VETableTertiaryFlash; 00658 break; 00659 case VETableTertiaryFlash2LocationID: 00660 details->RAMPage = RPAGE_FUEL_TWO; 00661 details->FlashPage = BIGTABLES_PPAGE; 00662 details->RAMAddress = (void*)&TablesC; 00663 details->FlashAddress = (void*)&VETableTertiaryFlash2; 00664 break; 00665 case LambdaTableFlashLocationID: 00666 details->RAMPage = RPAGE_FUEL_ONE; 00667 details->FlashPage = BIGTABLES_PPAGE; 00668 details->RAMAddress = (void*)&TablesD; 00669 details->FlashAddress = (void*)&LambdaTableFlash; 00670 break; 00671 case LambdaTableFlash2LocationID: 00672 details->RAMPage = RPAGE_FUEL_TWO; 00673 details->FlashPage = BIGTABLES_PPAGE; 00674 details->RAMAddress = (void*)&TablesD; 00675 details->FlashAddress = (void*)&LambdaTableFlash2; 00676 break; 00677 case IgnitionAdvanceTableMainFlashLocationID: 00678 details->RAMPage = RPAGE_TIME_ONE; 00679 details->FlashPage = BIGTABLES_PPAGE; 00680 details->RAMAddress = (void*)&TablesA; 00681 details->FlashAddress = (void*)&IgnitionAdvanceTableMainFlash; 00682 break; 00683 case IgnitionAdvanceTableMainFlash2LocationID: 00684 details->RAMPage = RPAGE_TIME_TWO; 00685 details->FlashPage = BIGTABLES_PPAGE; 00686 details->RAMAddress = (void*)&TablesA; 00687 details->FlashAddress = (void*)&IgnitionAdvanceTableMainFlash2; 00688 break; 00689 case IgnitionAdvanceTableSecondaryFlashLocationID: 00690 details->RAMPage = RPAGE_TIME_ONE; 00691 details->FlashPage = BIGTABLES_PPAGE; 00692 details->RAMAddress = (void*)&TablesB; 00693 details->FlashAddress = (void*)&IgnitionAdvanceTableSecondaryFlash; 00694 break; 00695 case IgnitionAdvanceTableSecondaryFlash2LocationID: 00696 details->RAMPage = RPAGE_TIME_TWO; 00697 details->FlashPage = BIGTABLES_PPAGE; 00698 details->RAMAddress = (void*)&TablesB; 00699 details->FlashAddress = (void*)&IgnitionAdvanceTableSecondaryFlash2; 00700 break; 00701 case InjectionAdvanceTableMainFlashLocationID: 00702 details->RAMPage = RPAGE_TIME_ONE; 00703 details->FlashPage = BIGTABLES_PPAGE; 00704 details->RAMAddress = (void*)&TablesC; 00705 details->FlashAddress = (void*)&InjectionAdvanceTableMainFlash; 00706 break; 00707 case InjectionAdvanceTableMainFlash2LocationID: 00708 details->RAMPage = RPAGE_TIME_TWO; 00709 details->FlashPage = BIGTABLES_PPAGE; 00710 details->RAMAddress = (void*)&TablesC; 00711 details->FlashAddress = (void*)&InjectionAdvanceTableMainFlash2; 00712 break; 00713 case InjectionAdvanceTableSecondaryFlashLocationID: 00714 details->RAMPage = RPAGE_TIME_ONE; 00715 details->FlashPage = BIGTABLES_PPAGE; 00716 details->RAMAddress = (void*)&TablesD; 00717 details->FlashAddress = (void*)&InjectionAdvanceTableSecondaryFlash; 00718 break; 00719 case InjectionAdvanceTableSecondaryFlash2LocationID: 00720 details->RAMPage = RPAGE_TIME_TWO; 00721 details->FlashPage = BIGTABLES_PPAGE; 00722 details->RAMAddress = (void*)&TablesD; 00723 details->FlashAddress = (void*)&InjectionAdvanceTableSecondaryFlash2; 00724 break; 00725 case SmallTablesAFlashLocationID: 00726 details->RAMPage = RPAGE_TUNE_ONE; 00727 details->FlashPage = PPAGE; 00728 details->RAMAddress = (void*)&TablesA; 00729 details->FlashAddress = (void*)&SmallTablesAFlash; 00730 break; 00731 case SmallTablesAFlash2LocationID: 00732 details->RAMPage = RPAGE_TUNE_TWO; 00733 details->FlashPage = PPAGE; 00734 details->RAMAddress = (void*)&TablesA; 00735 details->FlashAddress = (void*)&SmallTablesAFlash2; 00736 break; 00737 case SmallTablesBFlashLocationID: 00738 details->RAMPage = RPAGE_TUNE_ONE; 00739 details->FlashPage = PPAGE; 00740 details->RAMAddress = (void*)&TablesB; 00741 details->FlashAddress = (void*)&SmallTablesBFlash; 00742 break; 00743 case SmallTablesBFlash2LocationID: 00744 details->RAMPage = RPAGE_TUNE_TWO; 00745 details->FlashPage = PPAGE; 00746 details->RAMAddress = (void*)&TablesB; 00747 details->FlashAddress = (void*)&SmallTablesBFlash2; 00748 break; 00749 case SmallTablesCFlashLocationID: 00750 details->RAMPage = RPAGE_TUNE_ONE; 00751 details->FlashPage = PPAGE; 00752 details->RAMAddress = (void*)&TablesC; 00753 details->FlashAddress = (void*)&SmallTablesCFlash; 00754 break; 00755 case SmallTablesCFlash2LocationID: 00756 details->RAMPage = RPAGE_TUNE_TWO; 00757 details->FlashPage = PPAGE; 00758 details->RAMAddress = (void*)&TablesC; 00759 details->FlashAddress = (void*)&SmallTablesCFlash2; 00760 break; 00761 case SmallTablesDFlashLocationID: 00762 details->RAMPage = RPAGE_TUNE_ONE; 00763 details->FlashPage = PPAGE; 00764 details->RAMAddress = (void*)&TablesD; 00765 details->FlashAddress = (void*)&SmallTablesDFlash; 00766 break; 00767 case SmallTablesDFlash2LocationID: 00768 details->RAMPage = RPAGE_TUNE_TWO; 00769 details->FlashPage = PPAGE; 00770 details->RAMAddress = (void*)&TablesD; 00771 details->FlashAddress = (void*)&SmallTablesDFlash2; 00772 break; 00773 } 00774 }
EXTERN void resetReceiveState | ( | unsigned | char | ) |
Definition at line 55 of file commsISRs.c.
References COM_SET_CAN0_INTERFACE_ID, COM_SET_SCI0_INTERFACE_ID, RXBufferContentSourceID, RXBufferCurrentPosition, RXCalculatedChecksum, RXPacketLengthReceived, RXStateFlags, SCI0CR2, SCICR2_RX_DISABLE, SCICR2_RX_ENABLE, SCICR2_RX_ISR_DISABLE, and SCICR2_RX_ISR_ENABLE.
Referenced by decodePacketAndBuildResponse(), and SCI0ISR().
00055 { // WRONG 00056 /* Set the receive buffer pointer to the beginning */ 00057 RXBufferCurrentPosition = (unsigned char*)&RXBuffer; 00058 00059 /* Zero the flags, buffer length and checksum */ 00060 RXPacketLengthReceived = 0; 00061 RXCalculatedChecksum = 0; 00062 RXStateFlags = 0; 00063 00064 /* Set the source ID state (clear all or all but one flag(s)) */ 00065 RXBufferContentSourceID = sourceIDState; 00066 00067 /* Which ever interface we are setting is the one we came from. By definition */ 00068 /* it must be on and we want it to stay on, so just turn off all the others. */ 00069 if(sourceIDState & COM_SET_SCI0_INTERFACE_ID){ 00070 /* Turn off all others here */ 00071 // TODO CAN0CTL1 &= CANCTL1_RX_DISABLE; 00072 // TODO CAN0CTL1 &= CANCTL1_RX_ISR_DISABLE; 00073 /* SPI ? I2C ? SCI1 ? */ 00074 }else if(sourceIDState & COM_SET_CAN0_INTERFACE_ID){ 00075 /* Turn off all others here */ 00076 /* Only SCI for now */ 00077 SCI0CR2 &= SCICR2_RX_DISABLE; 00078 SCI0CR2 &= SCICR2_RX_ISR_DISABLE; 00079 /* SPI ? I2C ? SCI1 ? */ 00080 }else{ /* If clearing all flags then enable RX on all interfaces */ 00081 /* Only SCI for now */ 00082 SCI0CR2 |= SCICR2_RX_ENABLE; 00083 SCI0CR2 |= SCICR2_RX_ISR_ENABLE; 00084 // TODO CAN0CTL1 |= CANCTL1_RX_ENABLE; 00085 // TODO CAN0CTL1 |= CANCTL1_RX_ISR_ENABLE; 00086 /* SPI ? I2C ? SCI1 ? */ 00087 } 00088 }
EXTERN unsigned char RXBufferContentSourceID |
EXTERN unsigned char* RXBufferCurrentPosition |
Definition at line 71 of file commsCore.h.
Referenced by decodePacketAndBuildResponse(), receiveAndIncrement(), resetReceiveState(), and SCI0ISR().
EXTERN unsigned short RXCalculatedPayloadLength |
EXTERN unsigned char RXHeaderFlags |
EXTERN unsigned short RXHeaderPayloadID |
EXTERN unsigned short RXHeaderPayloadLength |
EXTERN unsigned char RXHeaderSourceAddress |
EXTERN unsigned short RXPacketLengthReceived |
Definition at line 72 of file commsCore.h.
Referenced by decodePacketAndBuildResponse(), receiveAndIncrement(), resetReceiveState(), and SCI0ISR().
EXTERN unsigned char RXStateFlags |
Definition at line 70 of file commsCore.h.
Referenced by main(), resetReceiveState(), and SCI0ISR().
EXTERN unsigned char* TXBufferCurrentPositionCAN0 |
EXTERN unsigned char* TXBufferCurrentPositionHandler |
Definition at line 41 of file commsCore.h.
Referenced by checksumAndSend(), decodePacketAndBuildResponse(), sendDebug(), and sendError().
EXTERN unsigned char* TXBufferCurrentPositionSCI0 |
Definition at line 43 of file commsCore.h.
Referenced by decodePacketAndBuildResponse(), SCI0ISR(), and sendAndIncrement().
EXTERN unsigned char TXBufferInUseFlags |
Definition at line 47 of file commsCore.h.
Referenced by checksumAndSend(), decodePacketAndBuildResponse(), main(), and SCI0ISR().
EXTERN unsigned short TXPacketLengthToSendCAN0 |
EXTERN unsigned short TXPacketLengthToSendSCI0 |
Definition at line 40 of file commsCore.h.
Referenced by checksumAndSend(), SCI0ISR(), and sendAndIncrement().