rtc.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _rtc_time

Defines

#define rtc_xseconds(x)   rtc_rw(0,x);
#define rtc_xminute(x)   rtc_rw(1,x)
#define rtc_xhour(x)   rtc_rw(2,x)
#define rtc_xyear(x)   rtc_rw(6,x)
#define rtc_xmonth(x)   rtc_rw(5,x)
#define rtc_xday(x)   rtc_rw(4,x)
#define rtc_xdow(x)   rtc_rw(3,x)

Typedefs

typedef struct _rtc_time RTC_TIME

Functions

void rtc_init ()
void rtc_send (uint8_t b)
void rtc_over ()
uint16_t rtc_gettime (uint8_t)
uint8_t rtc_rw (uint8_t addr, int8_t value)
void rtc_dump ()

Define Documentation

#define rtc_xday (  )     rtc_rw(4,x)
#define rtc_xdow (  )     rtc_rw(3,x)
#define rtc_xhour (  )     rtc_rw(2,x)
#define rtc_xminute (  )     rtc_rw(1,x)
#define rtc_xmonth (  )     rtc_rw(5,x)
#define rtc_xseconds (  )     rtc_rw(0,x);
#define rtc_xyear (  )     rtc_rw(6,x)

Typedef Documentation

typedef struct _rtc_time RTC_TIME

Function Documentation

void rtc_dump (  ) 

00073                 {
00074     uint8_t i;
00075     
00076     rtc_send(0); 
00077     for (i = 0; i < 0x1a; i++) {
00078         rtc_send(0); 
00079         printf_P(PSTR("%02x:%02x   "), i, SPDR);
00080     }
00081     rtc_over();
00082 }

Here is the call graph for this function:

uint16_t rtc_gettime ( uint8_t   ) 

00053                                  {
00054     uint16_t time = 0;
00055 
00056     // address 0 for seconds, minutes; minutes, hours otherwise   
00057     rtc_send(ss ? 0 : 1);
00058 
00059     // data 1
00060     rtc_send(0);
00061     time = SPDR; 
00062     
00063     // data 2
00064     rtc_send(0);
00065     while (!(SPSR & _BV(SPIF)));
00066     time |= SPDR<<8;
00067     
00068     rtc_over();
00069           
00070     return time; 
00071 }

Here is the call graph for this function:

void rtc_init (  ) 

00024                 {
00025     //DDRD |= _BV(4);     // RTCSEL#
00026     DDRRTCSEL |= _BV(RTCSEL);
00027     
00028     DDRSPI |= BV2(MOSI,SCK);
00029     DDRB &= ~_BV(MISO);
00030     
00031     PORTRTCSEL |= _BV(RTCSEL);
00032     
00033     SPCR = BV4(SPE, MSTR, CPHA, SPR1);
00034 }

void rtc_over (  ) 

00042                 {
00043     PORTRTCSEL |= _BV(RTCSEL);
00044 }

uint8_t rtc_rw ( uint8_t  addr,
int8_t  value 
)

00046                                            {
00047     rtc_send(addr | (value == -1 ? 0 : 0200));
00048     rtc_send(value);
00049     rtc_over();
00050     return SPDR;
00051 }

Here is the call graph for this function:

void rtc_send ( uint8_t  b  ) 

00036                          {
00037     PORTRTCSEL &= ~_BV(RTCSEL); 
00038     SPDR = b;
00039     spi_wait();
00040 }


Generated on Wed Jan 27 00:29:58 2010 for Patashnik by  doxygen 1.6.1