rtc.h File Reference
Go to the source code of this file.
Define Documentation
#define rtc_xday |
( |
x |
|
) |
rtc_rw(4,x) |
#define rtc_xdow |
( |
x |
|
) |
rtc_rw(3,x) |
#define rtc_xhour |
( |
x |
|
) |
rtc_rw(2,x) |
#define rtc_xminute |
( |
x |
|
) |
rtc_rw(1,x) |
#define rtc_xmonth |
( |
x |
|
) |
rtc_rw(5,x) |
#define rtc_xseconds |
( |
x |
|
) |
rtc_rw(0,x); |
#define rtc_xyear |
( |
x |
|
) |
rtc_rw(6,x) |
Typedef Documentation
Function Documentation
00061 {
00062 uint8_t i;
00063
00064 rtc_send(0);
00065 for (i = 0; i < 0x1a; i++) {
00066 rtc_send(0);
00067 printf_P(PSTR("%02x:%02x "), i, SPDR);
00068 }
00069 rtc_over();
00070 }
00041 {
00042 uint16_t time = 0;
00043
00044
00045 rtc_send(1);
00046
00047
00048 rtc_send(0);
00049 time = SPDR;
00050
00051
00052 rtc_send(0);
00053 while (!(SPSR & _BV(SPIF)));
00054 time |= SPDR<<8;
00055
00056 rtc_over();
00057
00058 return time;
00059 }
00013 {
00014 DDRD |= _BV(6);
00015
00016 DDRB |= BV2(5,7);
00017 DDRB &= ~_BV(6);
00018
00019 PORTD |= _BV(6);
00020
00021 SPCR = BV4(SPE, MSTR, CPHA, SPR1);
00022 }
00030 {
00031 PORTD |= _BV(6);
00032 }
uint8_t rtc_rw |
( |
uint8_t |
addr, |
|
|
int8_t |
value | |
|
) |
| | |
00034 {
00035 rtc_send(addr | (value == -1 ? 0 : 0200));
00036 rtc_send(value);
00037 rtc_over();
00038 return SPDR;
00039 }
void rtc_send |
( |
uint8_t |
b |
) |
|
00024 {
00025 PORTD &= ~_BV(6);
00026 SPDR = b;
00027 spi_wait();
00028 }