 |
MySensors Library & Examples
2.3.2
|
43 #define SERIAL_BAUD 115200
47 #ifdef __AVR_ATmega1284P__
48 #define LED 15 // Moteino MEGAs have LEDs on D15
49 #define FLASH_SS 23 // and FLASH SS on D23
51 #define LED 9 // Moteinos have LEDs on D9
52 #define FLASH_SS 8 // and FLASH SS on D8
65 Serial.
begin(SERIAL_BAUD);
66 Serial.print(
"Start...");
69 Serial.println(
"Init OK!");
72 Serial.println(
"Init FAIL!");
83 input = Serial.
read();
85 Serial.println(
"Flash content:");
89 Serial.print(flash.
readByte(counter++), HEX);
94 }
else if (input ==
'e') {
95 Serial.print(
"Erasing Flash chip ... ");
98 Serial.println(
"DONE");
99 }
else if (input ==
'i') {
100 Serial.print(
"DeviceID: ");
102 }
else if (input >= 48 && input <= 57) {
103 Serial.print(
"\nWriteByte(");
106 flash.
writeByte(input-48, (millis()%2) ? 0xaa : 0xbb);
111 if ((
int)(millis()/500) > lastPeriod) {
113 pinMode(LED, OUTPUT);
114 digitalWrite(LED, lastPeriod%2);
118 void Blink(
byte PIN,
int DELAY_MS,
byte loops)
120 pinMode(PIN, OUTPUT);
122 digitalWrite(PIN,
HIGH);
124 digitalWrite(PIN,
LOW);
bool busy()
check if the chip is busy erasing/writing
void writeByte(uint32_t addr, uint8_t byt)
Write 1 byte to flash memory.
SPIFlash provides access to a SPI Flash IC for OTA update or storing data.
void begin(int baud)
This function does nothing.
uint16_t readDeviceId()
Get the manufacturer and device ID bytes (as a short word)
bool initialize()
setup SPI, read device ID etc...
void chipErase()
erase entire flash memory array
void setup()
Called after node initialises but before main loop.
int available()
This function does nothing.
uint8_t readByte(uint32_t addr)
read 1 byte from flash memory
int read()
Reads 1 key pressed from the keyboard.