Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:a063a7db08f8
- Child:
- 1:c667d1f8e407
diff -r 000000000000 -r a063a7db08f8 main.cpp
--- /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