From 09b90e41f067b68638873c73cf3a6216cafeaf10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Tue, 2 Jun 2020 22:38:05 +0200 Subject: [PATCH] Add ino sketch to program EEPROM --- arduino/eeprom_prog/eeprom_prog.ino | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 arduino/eeprom_prog/eeprom_prog.ino diff --git a/arduino/eeprom_prog/eeprom_prog.ino b/arduino/eeprom_prog/eeprom_prog.ino new file mode 100644 index 0000000..2efacbf --- /dev/null +++ b/arduino/eeprom_prog/eeprom_prog.ino @@ -0,0 +1,53 @@ +#include +#include + +#define ERASE_FIRST 0 + +const byte mac[] = { + 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; +const char serial[] = "abcd1234"; + +struct netConfig { + IPAddress address; + int port; +}; + +netConfig config = { + {192, 168, 10, 123}, + 8000 +}; + +void setup() { + + Serial.begin(9600); + while (!Serial) { + ; // wait for serial port to connect. Needed for native USB port only + } + + #if ERASE_FIRST + // initialize the LED pin as an output. + pinMode(13, OUTPUT); + // turn the LED on while erasing + digitalWrite(13, HIGH); + for (int i = 0 ; i < EEPROM.length() ; i++) { + EEPROM.write(i, 0); + } + // turn the LED on when we're done + digitalWrite(13, LOW); + #endif + + int eeAddress = 0; //Location we want the data to be put. + + //One simple call, with the address first and the object second. + EEPROM.put(eeAddress, mac); + eeAddress += sizeof(mac); + EEPROM.put(eeAddress, serial); + eeAddress += sizeof(serial); + + EEPROM.put(eeAddress, config); + Serial.println("Data written!"); +} + +void loop() { + /* Empty loop */ +}