Some test with Nucleo and SPI EEPROM.

Dependencies:   mbed

Revision:
0:a063a7db08f8
Child:
1:c667d1f8e407
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jan 19 23:13:12 2015 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+
+DigitalIn mybutton(USER_BUTTON); // Activate button
+DigitalOut chipselect(D10); // ChipSelect (CS) pin
+SPI eeprom(SPI_MOSI, SPI_MISO, SPI_SCK); // Activate SPI to ST eeprom
+
+#define WREN 0x06
+#define RDSR 0x05
+#define READ_LOW 0x03
+ 
+int main() {
+    chipselect =1;
+    eeprom.frequency(1000000); // set 1 MHz clock rate
+    int i = 0;
+    while(1) {
+        if (mybutton == 0) { // Button is pressed
+            chipselect = 0;
+            eeprom.write(RDSR);
+            eeprom.write(0x00);
+            chipselect = 1;
+            chipselect = 0;
+            eeprom.write(WREN);
+            chipselect = 1;
+            wait_us(1);
+            chipselect = 0;
+            eeprom.write(RDSR);
+            eeprom.write(0x00);
+            chipselect = 1;
+            chipselect = 0;
+            eeprom.write(READ_LOW);
+            eeprom.write(0x00);
+            eeprom.write(0x00);
+            chipselect = 1;
+            wait(2);
+        }
+    }
+}
+ 
\ No newline at end of file