FM25W256, it was write protect first. 初期状態ではライトプロテクトがかかっていることに対応。 "The WREN command must be issued prior to any write operation." from FM25W256 datasheet.
Fork of Hello-FM25W256 by
main.cpp
00001 /* Cypress FM25W256 F-RAM component library test program 00002 * 00003 * Copyright (c) 2016 ARM Limited 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * * 00017 * @author Toyomasa Watarai 00018 * @version 1.0 00019 * @date 5-March-2016 00020 * 00021 * http://www.cypress.com/products/nonvolatile-ram 00022 * http://www.cypress.com/documentation/datasheets/fm25w256-256-kbit-32-k-8-serial-spi-f-ram?source=search&keywords=FM25W256&cat=technical_documents 00023 * 00024 */ 00025 00026 #include "mbed.h" 00027 #include "FM25W256.h" 00028 00029 Serial pc(USBTX, USBRX); 00030 #if defined(TARGET_LPC1114) 00031 FM25W256 f_ram(dp2, dp1, dp6, dp18); 00032 #elif defined(TARGET_LPC1768) 00033 FM25W256 f_ram(p5, p6, p7, p8); 00034 #endif 00035 00036 void read_test() 00037 { 00038 uint16_t adrs = 0; 00039 for(int i=0; i<16; i++) { 00040 pc.printf("0x%04X : ", i * 16); 00041 for(int j=0; j<16; j++) { 00042 pc.printf("%02X ", f_ram.read(adrs++)); 00043 } 00044 pc.printf("\n"); 00045 } 00046 } 00047 00048 void write_test() 00049 { 00050 uint8_t buf[16]; 00051 for(int i=0; i<16; i++) { 00052 buf[i] = (15 - i); 00053 } 00054 f_ram.write(0, buf, 16); 00055 } 00056 00057 void write_protect_test() 00058 { 00059 f_ram.set_write_protect(FM25W256::BANK_ALL); 00060 00061 pc.printf("[write data]\n"); 00062 pc.printf("0x0000 : "); 00063 uint8_t buf[16]; 00064 for(int i=0; i<16; i++) { 00065 buf[i] = i; 00066 pc.printf("%02X ", buf[i]); 00067 } 00068 pc.printf("\n"); 00069 f_ram.write(0, buf, 16); 00070 00071 pc.printf("[read data]\n"); 00072 read_test(); 00073 00074 f_ram.clear_write_protect(); 00075 } 00076 00077 int main() 00078 { 00079 f_ram.clear_write_protect(); 00080 00081 pc.printf("\nFM25W256 test program - write test? (y/n) "); 00082 if (pc.getc() == 'y') { 00083 write_test(); 00084 } 00085 00086 pc.printf("\nFM25W256 test program - read test? (y/n) "); 00087 if (pc.getc() == 'y') { 00088 pc.printf("\n"); 00089 read_test(); 00090 } 00091 00092 pc.printf("\nFM25W256 test program - write protect test? (y/n) "); 00093 if (pc.getc() == 'y') { 00094 pc.printf("\n"); 00095 write_protect_test(); 00096 } 00097 00098 while(1) { 00099 } 00100 }
Generated on Wed Jul 13 2022 11:31:35 by
1.7.2
Takehisa Oneta
