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:
- 3:e846980a1536
- Parent:
- 2:183d1d96f917
- Child:
- 4:17e602b21ac5
--- a/rm25c512cl.cpp Wed Sep 12 14:48:05 2018 +0000
+++ b/rm25c512cl.cpp Wed Sep 12 16:02:49 2018 +0000
@@ -152,7 +152,7 @@
/**
* @brief read_bytes()
-* @details Reads multiple bytes at given address.
+* @details Reads multiple bytes starting at given address.
* @param Page Address to start reading from.
* @param Pointer to data buffer to store multiple bytes read from EEprom.
* @param Size of the data buffer in bytes.
@@ -222,4 +222,70 @@
return data_buffer[0];
-}
\ No newline at end of file
+}
+
+/**
+* @brief page_erase()
+* @details 128 byte erase at page address
+* @param Page address
+* @return NA
+* @warning write enable must be called prior to calling this function or or
+* instruction will be ignored.
+*
+*/
+
+
+void rm25c512cl :: page_erase(uint16_t address){
+
+ char cmd[3];
+ char data_buffer[1];// not used here but required as function parameter
+
+ cmd[0] = PERS;
+ cmd[1] = address >> 8;
+ cmd[2] = address & 0x00FF;
+
+ _spi.lock();
+
+ _cs = 0;
+
+ _spi.write(&cmd[0],3,&data_buffer[0],0);
+
+ _cs = 1;
+
+ _spi.unlock();
+
+
+
+}
+
+/**
+* @brief chip_erase()
+* @details erases all memory on chip
+* @param NA
+* @return NA
+* @warning write enable must be called prior to calling this function or or
+* instruction will be ignored.
+*
+*/
+
+void rm25c512cl :: chip_erase(){
+
+ char cmd[1];
+ char data_buffer[1];// not used here but required as function parameter
+
+ cmd[0] = CERS;
+
+ _spi.lock();
+
+ _cs = 0;
+
+ _spi.write(&cmd[0],1,&data_buffer[0],0);
+
+ _cs = 1;
+
+ _spi.unlock();
+
+
+
+}
+