saiteja dommeti / Mbed 2 deprecated testing_rtc

Dependencies:   mbed

Fork of testing_rtc by WarLord Rocks

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtc_tst.h"
00003 //SPI spi(PTD6, PTD7, PTD5); // mosi, miso, sclk
00004 //DigitalOut cs(D9);
00005 
00006 
00007 int main() 
00008 {
00009  
00010  while(1)
00011  {
00012  Getts();
00013  }
00014  
00015  
00016  
00017   /*  // Setup the spi for 8 bit data, high steady state clock,
00018     // second edge capture, with a 1MHz clock rate
00019     spi.format(8,3);
00020     spi.frequency(1000000);
00021 
00022     cs = 0;
00023     spi.write(0x80);  // set write register to seconds
00024     spi.write(0x00);  // send value of zero
00025     
00026     //cs=1;
00027     //cs=0;
00028      spi.write(0x81);  
00029     spi.write(0x00);   //write reg to minutes
00030     
00031     //cs=1;
00032     //cs=0;
00033     
00034     spi.write(0x82);  
00035     spi.write(0x15);  //write reg to hours (00-23)
00036     
00037     spi.write(0x83);  
00038     spi.write(0x07);  //write reg to day (1-7)
00039     
00040     spi.write(0x84);  
00041     spi.write(0x20);  //write reg to date(01-31)
00042     
00043     spi.write(0x85);  
00044     spi.write(0x12);  //write reg to mnth(01-12)
00045     
00046     spi.write(0x86);  
00047     spi.write(0x12);  //write reg to year(00-99)
00048     
00049     cs=1;
00050     // Receive the contents of the seconds register
00051    
00052    for(int i=0;i<1000000;i++){
00053     
00054         
00055     cs=0;
00056     spi.write(0x00);                 // set read register to seconds
00057     int seconds = spi.write(0x00);   // read the value by sending dummy byte
00058     
00059     //cs=1;
00060     //cs=0;
00061     
00062     spi.write(0x01);
00063     int minutes =spi.write(0x01);
00064     
00065     //cs=1;
00066     //cs=0;
00067     
00068     spi.write(0x02);
00069     int hours =spi.write(0x01);
00070     
00071     spi.write(0x03);
00072     int day =spi.write(0x01);
00073     
00074     spi.write(0x04);
00075     int date =spi.write(0x01);
00076     
00077     spi.write(0x05);
00078     int mnth =spi.write(0x01);
00079     
00080     spi.write(0x06);
00081     int year =spi.write(0x01);
00082     
00083     //This cs=1 is to make the chipselect line high to "deselect" the slave in our case RTC
00084     cs = 1;
00085     
00086     //This printf function is to check the timestamp function in the terminal output
00087     printf("timestamp as  = %X : %X : %X : %X : %X : %X : %X\n\r", hours,minutes,seconds,day,date,mnth,year);
00088     }
00089     
00090     return 0;
00091     */
00092     
00093     
00094     
00095     }