Hello program for the FM25W256 library

Dependencies:   FM25W256 mbed

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Sat Mar 05 14:06:46 2016 +0000
Parent:
1:be908b1aafe6
Child:
3:d4a2357f06e3
Commit message:
Add more test functions

Changed in this revision

FM25W256.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/FM25W256.lib	Fri Mar 04 15:50:11 2016 +0000
+++ b/FM25W256.lib	Sat Mar 05 14:06:46 2016 +0000
@@ -1,1 +1,1 @@
-FM25W256#5a552209903c
+https://developer.mbed.org/users/MACRUM/code/FM25W256/#bb2b1e4bfb6e
--- a/main.cpp	Fri Mar 04 15:50:11 2016 +0000
+++ b/main.cpp	Sat Mar 05 14:06:46 2016 +0000
@@ -1,3 +1,28 @@
+/* Cypress FM25W256 F-RAM component library test program
+ *
+ * Copyright (c) 2016 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *  *
+ *  @author  Toyomasa Watarai
+ *  @version 1.0
+ *  @date    5-March-2016
+ *
+ *  http://www.cypress.com/products/nonvolatile-ram
+ *  http://www.cypress.com/documentation/datasheets/fm25w256-256-kbit-32-k-8-serial-spi-f-ram?source=search&keywords=FM25W256&cat=technical_documents
+ *
+ */
+
 #include "mbed.h"
 #include "FM25W256.h"
 
@@ -25,6 +50,26 @@
     f_ram.write(0, buf, 16);
 }
 
+void write_protect_test()
+{
+    f_ram.set_write_protect(FM25W256::BANK_ALL);
+
+    pc.printf("[write data]\n");
+    pc.printf("0x0000 : ");
+    uint8_t buf[16];
+    for(int i=0; i<16; i++) {
+        buf[i] = i;
+        pc.printf("%02X ", buf[i]);
+    }
+    pc.printf("\n");
+    f_ram.write(0, buf, 16);
+
+    pc.printf("[read data]\n");
+    read_test();
+
+    f_ram.clear_write_protect();
+}
+
 int main()
 {
     pc.printf("\nFM25W256 test program - write test? (y/n) ");
@@ -37,6 +82,12 @@
         pc.printf("\n");
         read_test();
     }
+    
+    pc.printf("\nFM25W256 test program - write protect test? (y/n) ");
+    if (pc.getc() == 'y') {
+        pc.printf("\n");
+        write_protect_test();
+    }
 
     while(1) {
     }