FreeEMS
0.2.0-SNAPSHOT-282-g9efc524
|
Go to the source code of this file.
Macros | |
#define | EXTERN extern |
#define | TX_MAX_PAYLOAD_SIZE (TX_BUFFER_SIZE - 32) |
#define | START_BYTE 0xAA |
#define | ESCAPE_BYTE 0xBB |
#define | STOP_BYTE 0xCC |
#define | ESCAPED_START_BYTE 0x55 |
#define | ESCAPED_ESCAPE_BYTE 0x44 |
#define | ESCAPED_STOP_BYTE 0x33 |
#define | COM_SET_SCI0_INTERFACE_ID BIT0 |
#define | COM_SET_CAN0_INTERFACE_ID BIT1 |
#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 | COM_CLEAR_SCI0_INTERFACE_ID NBIT0 |
#define | COM_CLEAR_CAN0_INTERFACE_ID NBIT1 |
#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 | CLEAR_ALL_SOURCE_ID_FLAGS ZEROS |
#define | RX_READY_TO_PROCESS BIT1 |
#define | RX_SCI_ESCAPED_NEXT BIT2 |
#define | RX_CLEAR_READY_TO_PROCESS NBIT1 |
#define | RX_SCI_NOT_ESCAPED_NEXT NBIT2 |
#define | SCICR2_RX_ENABLE BIT2 |
#define | SCICR2_TX_ENABLE BIT3 |
#define | SCICR2_RX_ISR_ENABLE BIT5 |
#define | SCICR2_TX_ISR_ENABLE BIT7 |
#define | SCICR2_RX_DISABLE NBIT2 |
#define | SCICR2_TX_DISABLE NBIT3 |
#define | SCICR2_RX_ISR_DISABLE NBIT5 |
#define | SCICR2_TX_ISR_DISABLE NBIT7 |
#define | HEADER_HAS_LENGTH BIT0 |
#define | HEADER_IS_NACK BIT1 |
#define | HEADER_HAS_SEQUENCE BIT2 |
#define | HEADER_RESERVED_E BIT3 |
#define | HEADER_RESERVED_D BIT4 |
#define | HEADER_RESERVED_C BIT5 |
#define | HEADER_RESERVED_B BIT6 |
#define | HEADER_RESERVED_A BIT7 |
#define | asyncDatalogOff 0x00 |
Logs by polling only, reduces CPU load a little but gives much lower data rate. | |
#define | asyncDatalogBasic 0x01 |
Good old default log, always contains the normal stuff, good for most people, most of the time. | |
#define | asyncDatalogScratchPad 0x02 |
User log of anything, any subset of a block allowed, start offset, size, content pointers/flags. | |
#define | asyncDatalogStructs 0x03 |
Key structs, or subsets of them, or chunk to chunk, streamed, more efficient than scratch pad and bigger if needed. | |
#define | asyncDatalogPosition 0x04 |
Record a buffer of position information, send when full: http://forum.diyefi.org/viewtopic.php?f=8&t=1339. | |
#define | asyncDatalogBlockBytes 0x05 |
Populate a large block with bytes as fast as possible, send when full. | |
#define | asyncDatalogBlockWords 0x06 |
Populate a large block with bytes as fast as possible, send when full. | |
#define | asyncDatalogBlockLongs 0x07 |
Populate a large block with bytes as fast as possible, send when full. | |
#define | asyncDatalogStreamByte 0x08 |
Send out a single byte as often as possible, ~1kHz with occasional ~3ms gaps from math running instead. | |
#define | asyncDatalogStreamWord 0x09 |
Send out a single word as often as possible, ~1kHz with occasional ~3ms gaps from math running instead. | |
#define | asyncDatalogStreamLong 0x0A |
Send out a single long as often as possible, ~1kHz with occasional ~3ms gaps from math running instead. | |
#define | asyncDatalogLastType asyncDatalogStreamLong |
Functions | |
void | decodePacketAndRespond (void) TEXT |
Decode a packet and respond. | |
void | resetReceiveState (unsigned char) FPAGE_FE |
Reset Receive State. | |
void | finaliseAndSend (unsigned short) FPAGE_FE |
Finalise a packet and send it. | |
unsigned short | populateBasicDatalog (void) FPAGE_FE |
Populate a basic datalog packet. |
Variables | |
EXTERN unsigned char * | TXBufferCurrentPositionHandler |
EXTERN unsigned char * | TXBufferCurrentPositionCAN0 |
EXTERN unsigned char * | TXBufferCurrentPositionSCI0 |
EXTERN unsigned char | TXBufferInUseFlags |
EXTERN unsigned char | RXBufferContentSourceID |
EXTERN unsigned char | RXStateFlags |
EXTERN unsigned char * | RXBufferCurrentPosition |
EXTERN unsigned short | RXCalculatedPayloadLength |
EXTERN unsigned char | RXHeaderFlags |
EXTERN unsigned char * | TXHeaderFlags |
EXTERN unsigned short | RXHeaderPayloadID |
EXTERN unsigned short | RXHeaderPayloadLength |
TODO. |
Definition in file commsCore.h.
#define EXTERN extern |
Definition at line 48 of file commsCore.h.
#define TX_MAX_PAYLOAD_SIZE (TX_BUFFER_SIZE - 32) |
Definition at line 53 of file commsCore.h.
Referenced by decodePacketAndRespond().
#define START_BYTE 0xAA |
Definition at line 78 of file commsCore.h.
Referenced by finaliseAndSend(), and SCI0ISR().
#define ESCAPE_BYTE 0xBB |
Definition at line 79 of file commsCore.h.
Referenced by SCI0ISR().
#define STOP_BYTE 0xCC |
Definition at line 80 of file commsCore.h.
Referenced by SCI0ISR().
#define ESCAPED_START_BYTE 0x55 |
Definition at line 82 of file commsCore.h.
Referenced by SCI0ISR().
#define ESCAPED_ESCAPE_BYTE 0x44 |
Definition at line 83 of file commsCore.h.
Referenced by SCI0ISR().
#define ESCAPED_STOP_BYTE 0x33 |
Definition at line 84 of file commsCore.h.
Referenced by SCI0ISR().
#define COM_SET_SCI0_INTERFACE_ID BIT0 |
Definition at line 88 of file commsCore.h.
Referenced by decodePacketAndRespond(), finaliseAndSend(), main(), resetReceiveState(), and SCI0ISR().
#define COM_SET_CAN0_INTERFACE_ID BIT1 |
Definition at line 89 of file commsCore.h.
Referenced by finaliseAndSend(), and resetReceiveState().
#define COM_SET_SPARE2_INTERFACE_ID BIT2 |
Definition at line 90 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_SET_SPARE3_INTERFACE_ID BIT3 |
Definition at line 91 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_SET_SPARE4_INTERFACE_ID BIT4 |
Definition at line 92 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_SET_SPARE5_INTERFACE_ID BIT5 |
Definition at line 93 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_SET_SPARE6_INTERFACE_ID BIT6 |
Definition at line 94 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_SET_SPARE7_INTERFACE_ID BIT7 |
Definition at line 95 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SCI0_INTERFACE_ID NBIT0 |
Definition at line 96 of file commsCore.h.
Referenced by SCI0ISR().
#define COM_CLEAR_CAN0_INTERFACE_ID NBIT1 |
Definition at line 97 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE2_INTERFACE_ID NBIT2 |
Definition at line 98 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE3_INTERFACE_ID NBIT3 |
Definition at line 99 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE4_INTERFACE_ID NBIT4 |
Definition at line 100 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE5_INTERFACE_ID NBIT5 |
Definition at line 101 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE6_INTERFACE_ID NBIT6 |
Definition at line 102 of file commsCore.h.
Referenced by finaliseAndSend().
#define COM_CLEAR_SPARE7_INTERFACE_ID NBIT7 |
Definition at line 103 of file commsCore.h.
Referenced by finaliseAndSend().
#define CLEAR_ALL_SOURCE_ID_FLAGS ZEROS |
Definition at line 104 of file commsCore.h.
Referenced by decodePacketAndRespond(), and SCI0ISR().
#define RX_READY_TO_PROCESS BIT1 |
Definition at line 113 of file commsCore.h.
#define RX_SCI_ESCAPED_NEXT BIT2 |
Definition at line 114 of file commsCore.h.
Referenced by SCI0ISR().
#define RX_CLEAR_READY_TO_PROCESS NBIT1 |
Definition at line 117 of file commsCore.h.
Referenced by main().
#define RX_SCI_NOT_ESCAPED_NEXT NBIT2 |
Definition at line 118 of file commsCore.h.
Referenced by SCI0ISR().
#define SCICR2_RX_ENABLE BIT2 |
Definition at line 127 of file commsCore.h.
#define SCICR2_TX_ENABLE BIT3 |
Definition at line 128 of file commsCore.h.
Referenced by finaliseAndSend().
#define SCICR2_RX_ISR_ENABLE BIT5 |
Definition at line 129 of file commsCore.h.
Referenced by resetReceiveState(), and SCI0ISR().
#define SCICR2_TX_ISR_ENABLE BIT7 |
Definition at line 130 of file commsCore.h.
Referenced by finaliseAndSend(), and SCI0ISR().
#define SCICR2_RX_DISABLE NBIT2 |
Definition at line 131 of file commsCore.h.
#define SCICR2_TX_DISABLE NBIT3 |
Definition at line 132 of file commsCore.h.
Referenced by SCI0ISR().
#define SCICR2_RX_ISR_DISABLE NBIT5 |
Definition at line 133 of file commsCore.h.
Referenced by resetReceiveState(), and SCI0ISR().
#define SCICR2_TX_ISR_DISABLE NBIT7 |
Definition at line 134 of file commsCore.h.
Referenced by SCI0ISR().
#define HEADER_HAS_LENGTH BIT0 |
Definition at line 157 of file commsCore.h.
Referenced by decodePacketAndRespond(), and main().
#define HEADER_IS_NACK BIT1 |
Definition at line 158 of file commsCore.h.
Referenced by finaliseAndSend().
#define HEADER_HAS_SEQUENCE BIT2 |
Definition at line 159 of file commsCore.h.
Referenced by decodePacketAndRespond().
#define HEADER_RESERVED_E BIT3 |
Definition at line 160 of file commsCore.h.
#define HEADER_RESERVED_D BIT4 |
Definition at line 161 of file commsCore.h.
#define HEADER_RESERVED_C BIT5 |
Definition at line 162 of file commsCore.h.
#define HEADER_RESERVED_B BIT6 |
Definition at line 163 of file commsCore.h.
#define HEADER_RESERVED_A BIT7 |
Definition at line 164 of file commsCore.h.
#define asyncDatalogOff 0x00 |
Logs by polling only, reduces CPU load a little but gives much lower data rate.
Definition at line 167 of file commsCore.h.
Referenced by main().
#define asyncDatalogBasic 0x01 |
Good old default log, always contains the normal stuff, good for most people, most of the time.
Definition at line 168 of file commsCore.h.
Referenced by main().
#define asyncDatalogScratchPad 0x02 |
User log of anything, any subset of a block allowed, start offset, size, content pointers/flags.
Definition at line 169 of file commsCore.h.
Referenced by main().
#define asyncDatalogStructs 0x03 |
Key structs, or subsets of them, or chunk to chunk, streamed, more efficient than scratch pad and bigger if needed.
Definition at line 170 of file commsCore.h.
Referenced by main().
#define asyncDatalogPosition 0x04 |
Record a buffer of position information, send when full: http://forum.diyefi.org/viewtopic.php?f=8&t=1339.
Definition at line 171 of file commsCore.h.
Referenced by main().
#define asyncDatalogBlockBytes 0x05 |
Populate a large block with bytes as fast as possible, send when full.
Definition at line 172 of file commsCore.h.
Referenced by main().
#define asyncDatalogBlockWords 0x06 |
Populate a large block with bytes as fast as possible, send when full.
Definition at line 173 of file commsCore.h.
Referenced by main().
#define asyncDatalogBlockLongs 0x07 |
Populate a large block with bytes as fast as possible, send when full.
Definition at line 174 of file commsCore.h.
Referenced by main().
#define asyncDatalogStreamByte 0x08 |
Send out a single byte as often as possible, ~1kHz with occasional ~3ms gaps from math running instead.
Definition at line 175 of file commsCore.h.
Referenced by main().
#define asyncDatalogStreamWord 0x09 |
Send out a single word as often as possible, ~1kHz with occasional ~3ms gaps from math running instead.
Definition at line 176 of file commsCore.h.
Referenced by main().
#define asyncDatalogStreamLong 0x0A |
Send out a single long as often as possible, ~1kHz with occasional ~3ms gaps from math running instead.
Definition at line 177 of file commsCore.h.
Referenced by main().
#define asyncDatalogLastType asyncDatalogStreamLong |
Definition at line 178 of file commsCore.h.
Referenced by decodePacketAndRespond().
void decodePacketAndRespond | ( | void | ) |
Decode a packet and respond.
This is the core function that controls which functionality is run when a packet is received in full by the ISR code and control is passed back to the main loop code. The vast majority of communications action happens here.
TODO
TODO
TODO
Definition at line 207 of file commsCore.c.
References _start(), ARMCOP, asyncDatalogLastType, ATOMIC_END, ATOMIC_START, attemptToWriteToReadOnlyBlock, BENCH_TEST_NAME, BENCH_TEST_ON, benchTestAlreadyRunning, benchTestNotRunningToBump, benchTestNotRunningToStop, block_is_2dus_table, block_is_indexable, block_is_main_table, block_is_read_only, buildTimeAndDate, builtByName, bumpingByZeroMakesNoSense, burnBlockFromRamToFlash, checksum(), CLEAR_ALL_SOURCE_ID_FLAGS, clearCountersAndFlagsToZero, Clocks, COM_SET_SCI0_INTERFACE_ID, compare(), compilerVersion, COPCTL, coreStatusA, CoreVars, Counters, KeyUserDebug::currentEvent, decoderMaxCodeTime, decoderName, DerivedVars, doesNotMakeSenseToRetrievePartially, DerivedVar::Dwell, ectSwitchOnCodeTime, finaliseAndSend(), firmwareVersion, FLAG_AND_INC_FLAGGABLE, FLAG_SERIAL_CHECKSUM_MISMATCHES_OFFSET, FLAG_SERIAL_PACKETS_UNDER_LENGTH_OFFSET, KeyUserDebug::flaggableFlags, KeyUserDebug::flaggableFlags2, Flaggables, Flaggables2, blockDetails::flags, blockDetails::FlashAddress, blockDetails::FlashPage, HEADER_HAS_LENGTH, HEADER_HAS_SEQUENCE, init(), interfaceVersion, invalidEventsPerCycle, invalidMemoryActionForID, invalidNumberOfCycles, invalidPayloadID, invalidSizeOffsetCombination, KeyUserDebugs, lookupBlockDetails(), lookupTwoDTableUS(), MEMORY_WRITE_ERROR, noChannelsConfiguredToTest, noSuchAsyncDatalogType, noSuchUnitTestID, operatingSystem, outputEventDelayFinalPeriod, outputEventInputEventNumbers, outputEventPulseWidthsMath, packetSizeWrongForTestMode, packetTooShortForSpecifiedFields, payloadLengthHeaderMismatch, payloadLengthTypeMismatch, payloadNotEqualToSpecifiedValue, payloadShorterThanRequiredForTest, populateBasicDatalog(), PPAGE, PPAGE_MIN, blockDetails::RAMAddress, blockDetails::RAMPage, DerivedVar::RefPW, requestBuiltByName, requestCompilerVersion, requestDatalogPacket, requestDecoderName, requestEchoPacketReturn, requestedAddressDisallowed, requestedFlashPageInvalid, requestedLengthTooLarge, requestedRAMPageInvalid, requestFirmwareBuildDate, requestFirmwareVersion, requestHardSystemReset, requestInterfaceVersion, requestMaxPacketSize, requestOperatingSystem, requestReInitOfSystem, requestSoftSystemReset, requestSupportEmail, requestUnitTestOverSerial, resetReceiveState(), retrieveArbitraryMemory, retrieveBlockFromFlash, retrieveBlockFromRAM, retrieveListOfLocationIDs, retrieveLocationIDDetails, RPAGE, RPAGE_MIN, CoreVar::RPM, RX_BUFFER_SIZE, RXBufferCurrentPosition, RXCalculatedPayloadLength, RXHeaderFlags, RXHeaderPayloadID, RXHeaderPayloadLength, KeyUserDebug::serialAndCommsCodeErrors, setAsyncDatalogType, blockDetails::size, startBenchTestSequence, stringCopy(), supportEmail, TEST_MODE_BUMP_UP_CYCLES, TEST_MODE_DODGY_MISSING_TOOTH, TEST_MODE_ITERATIONS, TEST_MODE_STOP, testEmptyTest, testEventsPerCycle, testMode, testNumberOfCycles, testNumberOfMissing, testTicksPerEvent, testTwoDTableUSLookup, thisIsNotTheBenchTestDecoder, TIE, Clock::timeoutADCreadingClock, tooManyEventsPerCycleMissingTth, tooShortOfAnEventPeriod, tooShortOfAPulseWidthToTest, TX_MAX_PAYLOAD_SIZE, TXBufferCurrentPositionCAN0, TXBufferCurrentPositionHandler, TXBufferCurrentPositionSCI0, TXBufferInUseFlags, TXHeaderFlags, uncheckedTableManipulationNotAllowed, unimplementedTestMode, unrecognisedPayloadID, updateBlockInFlash, updateBlockInRAM, validateMainTable(), validateTwoDTable(), and writeBlock().
Referenced by main().
void resetReceiveState | ( | unsigned char | sourceIDState | ) |
Reset Receive State.
Reset communications reception to the state provided.
sourceIDState | is the state to apply to the RX buffer state variable. |
Definition at line 64 of file commsISRs.c.
References COM_SET_CAN0_INTERFACE_ID, COM_SET_SCI0_INTERFACE_ID, RXBufferContentSourceID, RXBufferCurrentPosition, RXStateFlags, SCI0CR2, SCI0DRL, SCI0SR1, SCICR2_RX_ISR_DISABLE, and SCICR2_RX_ISR_ENABLE.
Referenced by decodePacketAndRespond(), and SCI0ISR().
void finaliseAndSend | ( | unsigned short | errorID | ) |
Finalise a packet and send it.
This functions job is to finalise the main loop part of the packet sending process. It configures the pos/neg ack header bit, adds the code if neg, runs a checksum over the packet data and tags it to the end before configuring the various ISRs that need to send the data out.
Definition at line 141 of file commsCore.c.
References checksum(), COM_CLEAR_CAN0_INTERFACE_ID, COM_CLEAR_SPARE2_INTERFACE_ID, COM_CLEAR_SPARE3_INTERFACE_ID, COM_CLEAR_SPARE4_INTERFACE_ID, COM_CLEAR_SPARE5_INTERFACE_ID, COM_CLEAR_SPARE6_INTERFACE_ID, COM_CLEAR_SPARE7_INTERFACE_ID, COM_SET_CAN0_INTERFACE_ID, COM_SET_SCI0_INTERFACE_ID, COM_SET_SPARE2_INTERFACE_ID, COM_SET_SPARE3_INTERFACE_ID, COM_SET_SPARE4_INTERFACE_ID, COM_SET_SPARE5_INTERFACE_ID, COM_SET_SPARE6_INTERFACE_ID, COM_SET_SPARE7_INTERFACE_ID, HEADER_IS_NACK, SCI0CR2, SCI0DRL, SCICR2_TX_ENABLE, SCICR2_TX_ISR_ENABLE, START_BYTE, TXBufferCurrentPositionHandler, TXBufferInUseFlags, and TXHeaderFlags.
Referenced by decodePacketAndRespond(), and main().
unsigned short populateBasicDatalog | ( | void | ) |
Populate a basic datalog packet.
Copies various chunks of data to the transmission buffer and truncates to the configured length. If changing this, update the maxBasicDatalogLength.
Definition at line 63 of file commsCore.c.
References KeyUserDebug::clockIn8thsOfAMilli, KeyUserDebug::clockInMilliSeconds, Clocks, KeyUserDebug::coreStatusA, coreStatusA, KeyUserDebugs, Clock::realTimeClockMain, Clock::realTimeClockMillis, KeyUserDebug::tempClock, and TXBufferCurrentPositionHandler.
Referenced by decodePacketAndRespond(), and main().
EXTERN unsigned char* TXBufferCurrentPositionHandler |
Definition at line 67 of file commsCore.h.
Referenced by decodePacketAndRespond(), finaliseAndSend(), main(), populateBasicDatalog(), and SCI0ISR().
EXTERN unsigned char* TXBufferCurrentPositionCAN0 |
Definition at line 68 of file commsCore.h.
Referenced by decodePacketAndRespond(), and main().
EXTERN unsigned char* TXBufferCurrentPositionSCI0 |
Definition at line 69 of file commsCore.h.
Referenced by decodePacketAndRespond(), main(), and SCI0ISR().
EXTERN unsigned char TXBufferInUseFlags |
Definition at line 73 of file commsCore.h.
Referenced by decodePacketAndRespond(), finaliseAndSend(), main(), and SCI0ISR().
EXTERN unsigned char RXBufferContentSourceID |
Definition at line 74 of file commsCore.h.
Referenced by resetReceiveState(), and SCI0ISR().
EXTERN unsigned char RXStateFlags |
Definition at line 108 of file commsCore.h.
Referenced by main(), resetReceiveState(), and SCI0ISR().
EXTERN unsigned char* RXBufferCurrentPosition |
Definition at line 109 of file commsCore.h.
Referenced by decodePacketAndRespond(), resetReceiveState(), and SCI0ISR().
EXTERN unsigned short RXCalculatedPayloadLength |
Definition at line 110 of file commsCore.h.
Referenced by decodePacketAndRespond().
EXTERN unsigned char RXHeaderFlags |
Definition at line 147 of file commsCore.h.
Referenced by decodePacketAndRespond().
EXTERN unsigned char* TXHeaderFlags |
Definition at line 148 of file commsCore.h.
Referenced by decodePacketAndRespond(), and finaliseAndSend().
EXTERN unsigned short RXHeaderPayloadID |
Definition at line 149 of file commsCore.h.
Referenced by decodePacketAndRespond().
EXTERN unsigned short RXHeaderPayloadLength |
TODO.
Definition at line 150 of file commsCore.h.
Referenced by decodePacketAndRespond().