diff --git a/Examples/WirelessProgramming_OTA/Programmer/Programmer.ino b/Examples/WirelessProgramming_OTA/Programmer/Programmer.ino index 566b3de..74a97f4 100644 --- a/Examples/WirelessProgramming_OTA/Programmer/Programmer.ino +++ b/Examples/WirelessProgramming_OTA/Programmer/Programmer.ino @@ -35,7 +35,6 @@ #include //get it here: https://github.com/lowpowerlab/RFM69 #include //get it here: https://github.com/lowpowerlab/RFM69 #include //get it here: https://github.com/lowpowerlab/RFM69 -#include //get it here: https://www.github.com/lowpowerlab/spiflash #include //included with Arduino IDE (www.arduino.cc) //**************************************************************************************************************** @@ -47,7 +46,7 @@ //#define FREQUENCY RF69_433MHZ //#define FREQUENCY RF69_868MHZ #define FREQUENCY RF69_915MHZ -#define FREQUENCY_EXACT 916000000 +#define FREQUENCY_EXACT 917000000 #define ENCRYPTKEY "sampleEncryptKey" //(16 bytes of your choice - keep the same on all encrypted nodes) #define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW! //********************************************************************************************* @@ -61,12 +60,6 @@ #define ACK_TIME 50 // # of ms to wait for an ack #define TIMEOUT 3000 -#ifdef __AVR_ATmega1284P__ - #define LED 15 // MoteinoMEGA has LED on D15 -#else - #define LED 9 // Moteino has LED on D9 -#endif - #ifdef ENABLE_ATC RFM69_ATC radio; #else @@ -152,7 +145,7 @@ void loop(){ Serial.println(); } - Blink(LED,5); //heartbeat + Blink(LED_BUILTIN,1); //heartbeat } void Blink(byte PIN, int DELAY_MS) diff --git a/Examples/WirelessProgramming_OTA/Target/Target.ino b/Examples/WirelessProgramming_OTA/Target/Target.ino index a12fecd..420c285 100644 --- a/Examples/WirelessProgramming_OTA/Target/Target.ino +++ b/Examples/WirelessProgramming_OTA/Target/Target.ino @@ -40,31 +40,27 @@ //**************************************************************************************************************** //**** IMPORTANT RADIO SETTINGS - YOU MUST CHANGE/CONFIGURE TO MATCH YOUR HARDWARE TRANSCEIVER CONFIGURATION! **** //**************************************************************************************************************** -#define NODEID 123 // node ID used for this unit -#define NETWORKID 100 +#define NODEID 123 // node ID used for this unit +#define NETWORKID 100 //Match frequency to the hardware version of the radio on your Moteino (uncomment one): //#define FREQUENCY RF69_433MHZ //#define FREQUENCY RF69_868MHZ #define FREQUENCY RF69_915MHZ -#define FREQUENCY_EXACT 916000000 +#define FREQUENCY_EXACT 917000000 +#define ENCRYPTKEY "sampleEncryptKey" //(16 bytes of your choice - keep the same on all encrypted nodes) #define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW! //***************************************************************************************************************************** #define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL -#define ATC_RSSI -75 +#define ATC_RSSI -80 //***************************************************************************************************************************** //#define BR_300KBPS //run radio at max rate of 300kbps! //***************************************************************************************************************************** #define SERIAL_BAUD 115200 #define ACK_TIME 30 // # of ms to wait for an ack -#define ENCRYPTKEY "sampleEncryptKey" //(16 bytes of your choice - keep the same on all encrypted nodes) -#define BLINKPERIOD 500 +#define BLINKPERIOD 200 -#ifdef __AVR_ATmega1284P__ - #define LED 15 // Moteino MEGAs have LEDs on D15 - #define FLASH_SS 23 // and FLASH SS on D23 -#else - #define LED 9 // Moteinos hsave LEDs on D9 - #define FLASH_SS 8 // and FLASH SS on D8 +#if defined(MOTEINO_M0) && defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL // Required for Serial on Zero based boards #endif #ifdef ENABLE_ATC @@ -82,12 +78,14 @@ long lastPeriod = -1; // MANUFACTURER_ID - OPTIONAL, 0x1F44 for adesto(ex atmel) 4mbit flash // 0xEF30 for windbond 4mbit flash // 0xEF40 for windbond 16/64mbit flash +// 0x1F84 for adesto 4mbit AT25SF041 4MBIT flash //***************************************************************************************************************************** -SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for windbond 4mbit flash +SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF30 for windbond 4mbit flash void setup() { - pinMode(LED, OUTPUT); + pinMode(LED_BUILTIN, OUTPUT); Serial.begin(SERIAL_BAUD); + delay(1000); radio.initialize(FREQUENCY,NODEID,NETWORKID); radio.encrypt(ENCRYPTKEY); //OPTIONAL @@ -102,7 +100,7 @@ void setup() { #ifdef IS_RFM69HW_HCW radio.setHighPower(); //must include this only for RFM69HW/HCW! #endif - Serial.print("Start node..."); + Serial.println("Start node..."); Serial.print("Node ID = "); Serial.println(NODEID); @@ -140,6 +138,18 @@ void loop(){ Serial.println(); } + else if (input == 'D') //d=dump higher memory + { + Serial.println("Flash content:"); + uint16_t counter = 4090; //dump the memory between the first 4K and second 4K sectors + + while(counter<=4200){ + Serial.print(flash.readByte(counter++), HEX); + Serial.print('.'); + } + + Serial.println(); + } else if (input == 'e') { Serial.print("Erasing Flash chip ... "); @@ -193,6 +203,7 @@ void loop(){ { lastPeriod++; digitalWrite(LED, lastPeriod%2); + Serial.print("BLINKPERIOD ");Serial.println(BLINKPERIOD); } //***************************************************************************************************************************** } \ No newline at end of file diff --git a/RFM69_OTA.cpp b/RFM69_OTA.cpp index 8804143..c8e48ef 100644 --- a/RFM69_OTA.cpp +++ b/RFM69_OTA.cpp @@ -37,7 +37,7 @@ #include #endif -#ifdef MOTEINO_ZERO +#ifdef MOTEINO_M0 #if defined(SERIAL_PORT_USBVIRTUAL) #define Serial SERIAL_PORT_USBVIRTUAL // output on SerialUSB instead of Serial #endif @@ -130,7 +130,7 @@ uint8_t HandleWirelessHEXData(RFM69& radio, uint8_t remoteID, SPIFlash& flash, u //first clear the fist 32k block (dedicated to a new FLASH image) flash.blockErase32K(0); flash.writeBytes(0,"FLXIMG:", 7); -#if defined (MOTEINO_ZERO) +#if defined (MOTEINO_M0) flash.writeByte(10,':'); uint32_t bytesFlashed=11; #else @@ -211,7 +211,7 @@ uint8_t HandleWirelessHEXData(RFM69& radio, uint8_t remoteID, SPIFlash& flash, u if (dataLen==7 && radio.DATA[4]=='E' && radio.DATA[5]=='O' && radio.DATA[6]=='F') //Expected EOF { -#if defined (MOTEINO_ZERO) +#if defined (MOTEINO_M0) if ((bytesFlashed-10)>253952) { //max 65536 - 10 bytes (signature) if (DEBUG) Serial.println(F("IMG > 64k, too big")); radio.sendACK("FLX?NOK:HEX>64k",15); @@ -233,7 +233,7 @@ uint8_t HandleWirelessHEXData(RFM69& radio, uint8_t remoteID, SPIFlash& flash, u HandleHandshakeACK(radio, flash, false); if (DEBUG) Serial.println(F("FLX?OK")); //save # of bytes written -#ifdef MOTEINO_ZERO +#ifdef MOTEINO_M0 flash.writeByte(7,(bytesFlashed-11)>>16); flash.writeByte(8,(bytesFlashed-11)>>8); flash.writeByte(9,(bytesFlashed-11)); @@ -545,7 +545,7 @@ void resetUsingWatchdog(uint8_t DEBUG) if (DEBUG) Serial.print(F("REBOOTING")); wdt_enable(WDTO_15MS); while(1) if (DEBUG) Serial.print(F(".")); -#elif defined(MOTEINO_ZERO) +#elif defined(MOTEINO_M0) WDT->CTRL.reg = 0; // disable watchdog while (WDT->STATUS.bit.SYNCBUSY == 1); // sync is required WDT->CONFIG.reg = 0; // see Table 18.8.2 Timeout Period (valid values 0-11) diff --git a/RFM69_OTA.h b/RFM69_OTA.h index b905f19..b0d1077 100644 --- a/RFM69_OTA.h +++ b/RFM69_OTA.h @@ -37,7 +37,7 @@ #include #include -#if defined(MOTEINO_ZERO) +#if defined(MOTEINO_M0) #define LED 13 // Moteino M0 #elif defined(__AVR_ATmega1284P__) #define LED 15 // Moteino MEGAs have LEDs on D15