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.
Diff: rm25c512cl.cpp
- Revision:
- 8:d71c8068ace2
- Parent:
- 7:c562fe4d48de
- Child:
- 9:5aa71e248abf
--- a/rm25c512cl.cpp Thu Sep 13 16:14:06 2018 +0000
+++ b/rm25c512cl.cpp Tue Sep 18 12:54:50 2018 +0000
@@ -388,3 +388,152 @@
}
+/**
+* @brief write_dissable()
+* @details Dissables writing to eeprom
+* @param NA
+* @return Sucess or failure of instruction
+* @warning Writes will be dissabled automatically after a write instruction so
+* this function is not required in that instance.
+*
+*/
+
+bool rm25c512cl:: write_dissable(){
+
+ char cmd[1];
+ char data_buffer[1];// not used here but required for spi.write() as a parameter
+ char status;
+
+ cmd[0] = WRDI;
+
+ _spi.lock();
+
+ _cs = LOW;
+
+ _spi.write(&cmd[0],1,&data_buffer[0],0);
+
+ _cs = HIGH;
+
+ _spi.unlock();
+
+ status = read_status_reg();
+ status = status & 0x2;
+
+ /* make sure write dissable is completed*/
+
+ if(status == 0){ // device is dissabled for writes now
+
+ return SUCCESS;
+
+ }
+ else{// WEL bit is 1 device is still enabled
+
+ return FAILURE;
+
+ }
+
+
+}
+
+/**
+* @brief write_status_reg()
+* @details write value to status reg to set write protection.
+* @param 8bit value to write to register.
+* @return NA
+* @warning Bit 4 and bit 0 are read only writes have no effect.
+*
+*/
+
+void rm25c512cl :: write_status_reg(char reg_status){
+
+ char cmd[2];
+ char data_buffer[1];// not used here but required for spi.write() as a parameter
+
+
+ cmd[0] = WRSR;
+ cmd[1] = reg_status;
+
+
+
+ _spi.lock();
+
+ _cs = LOW;
+
+ _spi.write(&cmd[0],2,&data_buffer[0],0);
+
+ _cs = HIGH;
+
+ _spi.unlock();
+
+
+}
+
+/**
+* @brief power_down()
+* @details Puts device in low power state
+* @param NA
+* @return NA
+* @warning After device is powered down reads and writes have no effect, and
+* resume function is only instuction that can resume from power down.
+*
+*/
+
+void rm25c512cl :: power_down(){
+
+ char cmd[1];
+ char data_buffer[1];// not used here but required for spi.write() as a parameter
+
+ cmd[0] = PD;
+
+ _spi.lock();
+
+ _cs = LOW;
+
+ _spi.write(&cmd[0],1,&data_buffer[0],0);
+
+ _cs = HIGH;
+
+ _spi.unlock();
+
+
+
+}
+
+/**
+* @brief resume()
+* @details Resumes from low power state.
+* @param NA
+* @return NA
+* @warning A delay of 75us is implemented here to allow device to resume properly.
+* before any reads and writes can be performed.
+*
+*/
+
+void rm25c512cl :: resume(){
+
+ char cmd[1];
+ char data_buffer[1];// not used here but required for spi.write() as a parameter
+
+ cmd[0] = RES;
+
+ _spi.lock();
+
+ _cs = LOW;
+
+ _spi.write(&cmd[0],1,&data_buffer[0],0);
+
+ _cs = HIGH;
+
+ _spi.unlock();
+
+ wait_us(75); // required after power down resume before reads or writes P21 datasheet
+
+
+}
+
+
+
+
+
+
+