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.
Fork of MPU9250 by
Diff: FLASH.h
- Revision:
- 2:6b427a493d9b
- Child:
- 4:337af8bbd44e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FLASH.h	Thu Jul 06 15:41:29 2017 +0000
@@ -0,0 +1,58 @@
+#ifndef FLASH_H
+#define FLASH_H
+
+#include "mbed.h"
+
+char Sensor_data[255];
+
+char SPI_rec[10];
+
+void write_EN_Flash(void);
+ SPI SER_FLASH(PA_12,PB_4,PB_3);//MOSI,MISO,SCL
+
+ DigitalOut FLASH_CS(PA_4);// CS
+ 
+// SPI commands for memory
+
+#define read_ID                 0x90
+
+
+                                
+#define write_EN                0x06
+#define page_prog               0x02
+#define Read_Data               0x03
+#define Chip_Erase              0xC7
+
+ void write_EN_Flash()
+ {
+    FLASH_CS=0; 
+    SER_FLASH.write(write_EN);
+    FLASH_CS=1;
+     }
+     
+ uint16_t read_flash_ID()
+{
+    uint16_t ID;
+    FLASH_CS=0;
+    SER_FLASH.write(read_ID);
+    SER_FLASH.write(0x00);
+    SER_FLASH.write(0x00);
+    SER_FLASH.write(0x00);
+    uint8_t ID_h=SER_FLASH.write(0x00);
+    uint8_t ID_l=SER_FLASH.write(0x00);
+    FLASH_CS=1;
+    ID = (ID_h<<8 | ID_l);
+    return ID ;
+}
+ 
+void SER_FLASH_ERASE()
+{
+    write_EN_Flash();
+    FLASH_CS=0;
+   SER_FLASH.write(Chip_Erase);
+    FLASH_CS=1;
+    wait(1.5);
+ } 
+ 
+                                    
+#endif
\ No newline at end of file
    