]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Data copy code in Fr_TransmitTxLPdu tuned to be more readable
authorMichal Horn <hornmich@fel.cvut.cz>
Thu, 19 Sep 2013 11:26:00 +0000 (13:26 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Thu, 19 Sep 2013 11:26:00 +0000 (13:26 +0200)
rpp/src/drv/fr_tms570.c

index 766f98fe1999d6d579b9504d5e54d38803d8828b..467fcebd23fd2181cb0eb44e22f8b57834c436c9 100644 (file)
@@ -1379,7 +1379,7 @@ Std_ReturnType Fr_GetPOCStatus(uint8_t Fr_CtrlIdx, Fr_POCStatusType* Fr_POCStatu
 }
 
 Std_ReturnType Fr_TransmitTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, const uint8_t* Fr_LSduPtr, uint8_t Fr_LSduLength) {
-       uint32_t byte, word, buffer, index, bufferIndex;
+       uint32_t word, buffer, index, bufferIndex;
 #ifdef DET_ACTIVATED
        if (Fr_CtrlIdx != 0) {
                return E_NOT_OK;
@@ -1401,13 +1401,11 @@ Std_ReturnType Fr_TransmitTxLPdu(uint8_t Fr_CtrlIdx, uint16_t Fr_LPduIdx, const
                        if (Fr_BuffersConfigured[bufferIndex] == TRUE && Fr_buffer_slot_map[bufferIndex].buffer_ptr->isTx == TRUE) {    // Buffer was configured already and is TX
                                memset((void *)frayREG->WRDS, 0, sizeof(frayREG->WRDS));
                                for (word = 0; word < (Fr_LSduLength+3)/4; word++) {
-                                       buffer = 0;
-                                       for (byte = 0; byte < 4; byte++) {
-                                               index = word*4+byte;
-                                               if (index < Fr_LSduLength) {
-                                                       buffer |= Fr_LSduPtr[index] << byte*8;
-                                               }
-                                       }
+                                       index = word*4;
+                                       buffer = Fr_LSduPtr[index++];
+                                       buffer |= (index < Fr_LSduLength) ? Fr_LSduPtr[index++] << 8 : 0;
+                                       buffer |= (index < Fr_LSduLength) ? Fr_LSduPtr[index++] << 16 : 0;
+                                       buffer |= (index < Fr_LSduLength) ? Fr_LSduPtr[index++] << 24 : 0;
                                        frayREG->WRDS[word] = buffer;
                                }
                                Fr_buffer_transmit_data(bufferIndex);