Armando Hernández
/
DS1302_HelloWorld
TEST_LP 1608
main.cpp@2:10b51af4fb8c, 2018-11-30 (annotated)
- Committer:
- armandotill
- Date:
- Fri Nov 30 03:12:40 2018 +0000
- Revision:
- 2:10b51af4fb8c
- Parent:
- 1:e747c4ea86e0
- Child:
- 3:8c4b9d2adf7a
DS1302_TEST
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
armandotill | 2:10b51af4fb8c | 1 | #define SCLK p22 |
armandotill | 2:10b51af4fb8c | 2 | #define IO p23 |
armandotill | 2:10b51af4fb8c | 3 | #define CE p24 |
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 |
armandotill | 2:10b51af4fb8c | 15 | clk.set_time(2056729737); |
Sissors | 0:5e6107966aba | 16 | #endif |
Sissors | 0:5e6107966aba | 17 | |
Sissors | 0:5e6107966aba | 18 | char storedByte = clk.recallByte(0); |
armandotill | 2:10b51af4fb8c | 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); |
armandotill | 2:10b51af4fb8c | 24 | printf("Fecha - Hora = %s\r", ctime(&seconds)); |
Sissors | 0:5e6107966aba | 25 | wait(1); |
Sissors | 0:5e6107966aba | 26 | } |
Sissors | 0:5e6107966aba | 27 | } |