DS1302 Hello World program

Dependencies:   DS1302 mbed

Committer:
Sissors
Date:
Mon Mar 31 20:54:17 2014 +0000
Revision:
0:5e6107966aba
Child:
1:e747c4ea86e0
v1.0
;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 0:5e6107966aba 1 #define SCLK PTC5
Sissors 0:5e6107966aba 2 #define IO PTC4
Sissors 0:5e6107966aba 3 #define CE PTC3
Sissors 0:5e6107966aba 4
Sissors 0:5e6107966aba 5 //Comment this line if the DS1302 is already running
Sissors 0:5e6107966aba 6 #define INITIAL_RUN
Sissors 0:5e6107966aba 7
Sissors 0:5e6107966aba 8 #include "mbed.h"
Sissors 0:5e6107966aba 9 #include "DS1302.h"
Sissors 0:5e6107966aba 10
Sissors 0:5e6107966aba 11 DS1302 clk(SCLK, IO, PTC3);
Sissors 0:5e6107966aba 12
Sissors 0:5e6107966aba 13 int main() {
Sissors 0:5e6107966aba 14 #ifdef INITIAL_RUN
Sissors 0:5e6107966aba 15 clk.set_time(1256729737);
Sissors 0:5e6107966aba 16 #endif
Sissors 0:5e6107966aba 17
Sissors 0:5e6107966aba 18 char storedByte = clk.recallByte(0);
Sissors 0:5e6107966aba 19 printf("\r\nStored byte was %d, now increasing by one\r\n", storedByte);
Sissors 0:5e6107966aba 20 clk.storeByte(0, storedByte + 1);
Sissors 0:5e6107966aba 21
Sissors 0:5e6107966aba 22 while(1) {
Sissors 0:5e6107966aba 23 time_t seconds = clk.time(NULL);
Sissors 0:5e6107966aba 24 printf("Time as a basic string = %s\r", ctime(&seconds));
Sissors 0:5e6107966aba 25 wait(1);
Sissors 0:5e6107966aba 26 }
Sissors 0:5e6107966aba 27 }