Index: firmware/.launches/DG.launch =================================================================== diff -u -r36a2fa774e2f5721c30261a40360d706bb4ea4bb -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/.launches/DG.launch (.../DG.launch) (revision 36a2fa774e2f5721c30261a40360d706bb4ea4bb) +++ firmware/.launches/DG.launch (.../DG.launch) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -2,7 +2,7 @@ - + Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -ra303cd4258157a8fbcbd8af4dd2bbaadec1a736c -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a303cd4258157a8fbcbd8af4dd2bbaadec1a736c) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -17,7 +17,7 @@ #include "ModeFill.h" #include "Common.h" #include "OperationModes.h" -#include +#include "Timers.h" #ifdef RM46_EVAL_BOARD_TARGET #include "CPLD.h" Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r36a2fa774e2f5721c30261a40360d706bb4ea4bb -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 36a2fa774e2f5721c30261a40360d706bb4ea4bb) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -42,6 +42,8 @@ #define SCI1_RECEIVE_DMA_REQUEST 30 #define SCI1_TRANSMIT_DMA_REQUEST 31 +#define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< if transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on + #define HD_COMM_TIMEOUT_IN_MS 2000 #define MAX_COMM_CRC_FAILURES 5 @@ -87,6 +89,10 @@ COMM_BUFFER_IN_UART_PC }; +static U08 lastCANPacketSent[ CAN_MESSAGE_PAYLOAD_SIZE ]; +static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = 0; +static U32 lastCANPacketSentTimeStamp = 0; + static U08 pcXmitPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -105,6 +111,15 @@ static U32 badCRCListIdx = 0; // where next bad message CRC time stamp will go in list static U32 badCRCListCount = 0; // # of bad CRCs in the list +#ifdef CAN_TEST +U08 dbgRcvdCANFrames[1024][8]; +U32 dbgRcvdCANFrameTS[1024]; +U32 dbgRcvdCANFrameIdx = 0; +U08 dbgXmitCANFrames[1024][8]; +U32 dbgXmitCANFrameTS[1024]; +U32 dbgXmitCANFrameIdx = 0; +#endif + // ********** private function prototypes ********** static void initUARTAndDMA( void ); @@ -222,6 +237,15 @@ { transmitNextCANPacket(); } + else + { // generally, transmitter should not be busy at time of this function call - check timeout just in case so we don't get stuck waiting forever + if ( TRUE == didTimeout( lastCANPacketSentTimeStamp, CAN_XMIT_PACKET_TIMEOUT_MS ) ) + { + // TODO - depending on why we timed out, we may need to reset CAN controller??? + // assume last packet was not successfully transmitted. TODO - Re-send last packet? Or should we move on? + canTransmit( canREG1, lastCANPacketSentChannel, lastCANPacketSent ); + } + } // if UART transmitter is idle, start transmitting any pending packets if ( FALSE == isSCI1DMATransmitInProgress() ) @@ -266,6 +290,18 @@ // if packet retrieved, add to buffer if ( result != 0 ) { +#ifdef CAN_TEST + if ( dbgRcvdCANFrameIdx >= 1000 ) + { + result = 99; // Break point here + } + else + { + dbgRcvdCANFrameTS[dbgRcvdCANFrameIdx] = getMSTimerCount(); + memcpy( &dbgRcvdCANFrames[dbgRcvdCANFrameIdx][0], data, 8); + dbgRcvdCANFrameIdx++; + } +#endif //#ifdef DEBUG_ENABLED // if ( srcCANBox == COMM_BUFFER_IN_CAN_PC ) // { @@ -503,7 +539,24 @@ // if there's another CAN packet to send, send it if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) { + // we're transmitting another packet - signal transmitter is busy signalCANXmitsInitiated(); + // remember packet data being transmitted here in case transmission fails and we need to re-send + memcpy( lastCANPacketSent, data, CAN_MESSAGE_PAYLOAD_SIZE ); + lastCANPacketSentChannel = mBox; + lastCANPacketSentTimeStamp = getMSTimerCount(); +#ifdef CAN_TEST + if ( dbgXmitCANFrameIdx > 1000 ) + { + dataSize = 99; // Break point here + } + else + { + dbgXmitCANFrameTS[dbgXmitCANFrameIdx] = getMSTimerCount(); + memcpy( &dbgXmitCANFrames[dbgXmitCANFrameIdx][0], data, 8); + dbgXmitCANFrameIdx++; + } +#endif if ( 0 != canTransmit( canREG1, mBox, data ) ) { result = CAN_MESSAGE_PAYLOAD_SIZE; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r36a2fa774e2f5721c30261a40360d706bb4ea4bb -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 36a2fa774e2f5721c30261a40360d706bb4ea4bb) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -325,6 +325,7 @@ #ifdef CAN_TEST void broadcastCANTest1LargeFrequentMessage() { + static U16 seqNo = 0; MESSAGE_T msg; U32 i; @@ -333,10 +334,13 @@ msg.hdr.msgID = MSG_ID_DG_CAN_TEST_1_LARGE_FREQ; msg.hdr.payloadLen = 96; - for ( i = 0; i < 96; i++ ) + for ( i = 0; i < 12; i++ ) { - msg.payload[i] = i+1; + memcpy(&msg.payload[i*8], &seqNo, 2); + seqNo++; } + memcpy(&msg.payload[94], &seqNo, 2); + seqNo++; // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r36a2fa774e2f5721c30261a40360d706bb4ea4bb -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 36a2fa774e2f5721c30261a40360d706bb4ea4bb) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -38,9 +38,11 @@ MSG_ID_DIALYSATE_OUT_FLOW_DATA, // 11 MSG_ID_LOAD_CELL_READINGS, // 12 MSG_ID_TREATMENT_TIME, // 13 + XXXXX, #ifdef CAN_TEST - MSG_ID_HD_CAN_TEST_1_LARGE_FREQ, // 14 - MSG_ID_DG_CAN_TEST_1_LARGE_FREQ, // 15 + MSG_ID_HD_CAN_TEST_1_LARGE_FREQ, // 15 + MSG_ID_DG_CAN_TEST_1_LARGE_FREQ, // 16 + YYYYY, #endif // service/test CAN messages Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/App/Services/Timers.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/App/Services/Timers.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/App/Services/Utilities.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/App/Services/Utilities.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r36a2fa774e2f5721c30261a40360d706bb4ea4bb -r4d27576bdd7843178d9b69ffff3584ee01ec24fe --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 36a2fa774e2f5721c30261a40360d706bb4ea4bb) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 4d27576bdd7843178d9b69ffff3584ee01ec24fe) @@ -47,7 +47,14 @@ execOperationModes(); #ifdef CAN_TEST - broadcastCANTest1LargeFrequentMessage(); + { + static U32 canTestCtr = 0; + if ( ++canTestCtr >= 2 ) + { + broadcastCANTest1LargeFrequentMessage(); + canTestCtr = 0; + } + } #endif // manage data to be transmitted to other sub-systems Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/irqDispatch_a.asm'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 4d27576bdd7843178d9b69ffff3584ee01ec24fe refers to a dead (removed) revision in file `firmware/irqDispatch_c.c'. Fisheye: No comparison available. Pass `N' to diff?