Shivanand Gowda / Mbed OS SPI_SRAM_READ_WRITE

Dependencies:   S2568FBLL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 // SPI Single IO NOR sram Library for Nucleo F767ZI Interfacing
00003 
00004 
00005 
00006 #include "mbed.h"
00007 #include "S2568FBLL.h"
00008 #include <string>
00009 
00010 Serial pc(USBTX, USBRX); // tx, rx
00011 
00012 int main()
00013 {
00014     S2568FBLL sram(PA_7, PA_6, PA_5, PA_4,PA_3);
00015     pc.printf("SPI init done\r\n\r\n");
00016 
00017     // Read Identification information Related to chip.
00018 
00019     
00020     // Reading sram Memory Status Register1 contents.
00021 
00022     uint8_t MODE_REGISTER= sram.readRegister();
00023     pc.printf(" MODE REGISTER CONTENTS:%X\r\n\r\n",MODE_REGISTER);
00024 
00025     wait(1);
00026 
00027     
00028 
00029     
00030    
00031 
00032 // write a stream of characters to arbitrary address 0x168
00033     char stri[] = "Shivanand Gowda Ramaiah";
00034 
00035     pc.printf("Writing String Here: %s\r\n",stri);
00036 
00037 
00038     sram.writeStream(0x00, stri, 22); //Writing Strings in three Differnt addresses.
00039     sram.writeStream(22, stri, 22);
00040     sram.writeStream(44, stri, 22);
00041     
00042 
00043     char str2[22] = {0};
00044     char str3[22] = {0};
00045     char str4[22] = {0};
00046     
00047     pc.printf("Before String Here: %s\r\n",str2);
00048     sram.readStream(0x00, str2, 22);
00049     pc.printf("After Read 1 String Here: %s\r\n",str2);
00050     sram.readStream(22, str4, 22);
00051     pc.printf("After Read 2 String Here: %s\r\n",str2);
00052     sram.readStream(44, str3, 22);
00053     pc.printf("After Read 3 String Here: %s\r\n",str2);  
00054 
00055     pc.printf("Exited from program  \r\n");
00056     return 0;
00057 
00058 }