From 8690c03509bbb82cb3171b1070f7b4c65f784d8b Mon Sep 17 00:00:00 2001 From: Felix Rusu Date: Tue, 13 Mar 2018 11:56:47 -0400 Subject: [PATCH] PrintHex83 update, add #ifndef arm --- RFM69_OTA.cpp | 28 ++++++++++++---------------- RFM69_OTA.h | 3 +++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/RFM69_OTA.cpp b/RFM69_OTA.cpp index 12db364..de268ec 100644 --- a/RFM69_OTA.cpp +++ b/RFM69_OTA.cpp @@ -30,6 +30,7 @@ // Please maintain this license information along with authorship // and copyright notices in any redistribution of this code // ********************************************************************************** +#ifndef __arm__ #include #include #include @@ -173,6 +174,10 @@ uint8_t HandleWirelessHEXData(RFM69& radio, uint8_t remoteID, SPIFlash& flash, u flash.writeByte(bytesFlashed++, radio.DATA[i]); if (bytesFlashed%32768==0) flash.blockErase32K(bytesFlashed);//erase subsequent 32K blocks (possible in case of atmega1284p) } + //faster alternative using writeBytes - the gain is only up to 2 seconds + //if (bytesFlashed<=32768 && (bytesFlashed+dataLen-index)>32768) flash.blockErase32K(32768);//erase subsequent 32K blocks (possible in case of atmega1284p) + //flash.writeBytes(bytesFlashed, (void*)(radio.DATA+index), dataLen-index); + //bytesFlashed += dataLen-index; } //send ACK @@ -491,28 +496,18 @@ uint8_t sendHEXPacket(RFM69& radio, uint8_t targetID, uint8_t* sendBuf, uint8_t //=================================================================================================================== // PrintHex83() - prints 8-bit data in HEX format //=================================================================================================================== -void PrintHex83(uint8_t *data, uint8_t length) +void PrintHex83(uint8_t* data, uint8_t length) { - char tmp[length*2+1]; - uint8_t first ; - int j=0; + uint8_t tmp; for (uint8_t i=0; i> 4) | 48; - if (first > 57) tmp[j] = first + (uint8_t)39; - else tmp[j] = first ; - j++; - - first = (data[i] & 0x0F) | 48; - if (first > 57) tmp[j] = first + (uint8_t)39; - else tmp[j] = first; - j++; + tmp = (data[i] >> 4) | 48; + Serial.print((char)((tmp > 57) ? tmp+7 : tmp)); + tmp = (data[i] & 0x0F) | 48; + Serial.print((char)((tmp > 57) ? tmp+7 : tmp)); } - tmp[length*2] = 0; - Serial.println(tmp); } - //=================================================================================================================== // resetUsingWatchdog() - Use watchdog to reset the MCU //=================================================================================================================== @@ -523,3 +518,4 @@ void resetUsingWatchdog(uint8_t DEBUG) wdt_enable(WDTO_15MS); while(1) if (DEBUG) Serial.print(F(".")); } +#endif \ No newline at end of file diff --git a/RFM69_OTA.h b/RFM69_OTA.h index 300a3d9..012f43e 100644 --- a/RFM69_OTA.h +++ b/RFM69_OTA.h @@ -30,6 +30,8 @@ // Please maintain this license information along with authorship // and copyright notices in any redistribution of this code // ********************************************************************************** +#ifndef __arm__ + #ifndef RFM69_OTA_H #define RFM69_OTA_H #ifdef __AVR_ATmega1284P__ @@ -77,3 +79,4 @@ uint8_t readSerialLine(char* input, char endOfLineChar=10, uint8_t maxLength=115 void PrintHex83(uint8_t* data, uint8_t length); #endif +#endif \ No newline at end of file