//Defines to shorten print statements
#define mp(x) Serial1.print(F(x))
#define mpl(x) Serial1.println(F(x))
#define sp(x) Serial1.print(x)
#define spl(x) Serial1.println(x)
#define debug(P1,P2) mp(P1);spl(P2);
//extern "C" uint8_t _EEPROM_start;
#define FLASH_SECTOR_SIZE 4096
#include "EEPROM.h";
uint8_t _EEPROM_start = PICO_FLASH_SIZE_BYTES/FLASH_SECTOR_SIZE -2;
void setup() {
// put your setup code here, to run once:
Serial1.begin(115200);
Serial1.println("Hello, Raspberry Pi Pico!");
pinMode(4,OUTPUT);
pinMode(5, INPUT_PULLUP);
debug("PICO_FLASH_SIZE_BYTES ",PICO_FLASH_SIZE_BYTES);
debug("EEPROM Length:",EEPROM.length());
debug("Flash sectors:",PICO_FLASH_SIZE_BYTES/FLASH_SECTOR_SIZE);
EEPROM.begin(512);
debug("After begin EEPROM Length:",EEPROM.length());
// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;
// write a 0 to all 512 bytes of the EEPROM
for (int i = 0; i < 512; i++) {
value = EEPROM.read(address);
if (i % 8 == 0) {
Serial1.print("\n");
Serial1.print(address,HEX);
Serial1.print("\t");
}
Serial1.print(value, HEX);
Serial1.print(" ");
address++;
}
mpl("Read completed");
/*
// write a 0 to all 512 bytes of the EEPROM
for (int i = 0; i < 512; i++) {
EEPROM.write(i, 0);
}
mpl("Write completed");
*/
// turn the LED on when we're done
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
EEPROM.end();
}
void loop() {
/* e here, to run repeatedly:
bool state = 0;
delay(10); // this speeds up the simulation
digitalWrite(4,HIGH);
delay(100);
digitalWrite(4,LOW);
delay(200);
mp("Pin 4 State:");
//state = digitalRead(4);
spl(state);
state = digitalRead(5);
mp("Pin 5 State:");
spl(state);
*/
delay(500);
}