TEST_LP 1608

Dependencies:   mbed DS1302

Committer:
Gijsvanoort
Date:
Sat Feb 21 15:18:52 2015 +0000
Revision:
1:e747c4ea86e0
Parent:
0:5e6107966aba
Child:
2:10b51af4fb8c
Fixed bug which occurs when you define a different CE pin

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
Gijsvanoort 1:e747c4ea86e0 11 DS1302 clk(SCLK, IO, CE);
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 }