rtc.c File Reference

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <stdio.h>
#include <inttypes.h>
#include "util.h"
#include "rtc.h"
Include dependency graph for rtc.c:

Functions

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

Function Documentation

void rtc_dump (  ) 

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 }

Here is the call graph for this function:

uint16_t rtc_gettime (  ) 

00041                        {
00042     uint16_t time = 0;
00043 
00044     // address 0    
00045     rtc_send(1);
00046 
00047     // data 1
00048     rtc_send(0);
00049     time = SPDR; 
00050     
00051     // data 2
00052     rtc_send(0);
00053     while (!(SPSR & _BV(SPIF)));
00054     time |= SPDR<<8;
00055     
00056     rtc_over();
00057           
00058     return time; 
00059 }

Here is the call graph for this function:

void rtc_init (  ) 

00013                 {
00014     DDRD |= _BV(6);     // RTCSEL#
00015     
00016     DDRB |= BV2(5,7);
00017     DDRB &= ~_BV(6);
00018     
00019     PORTD |= _BV(6);
00020     
00021     SPCR = BV4(SPE, MSTR, CPHA, SPR1);
00022 }

void rtc_over (  ) 

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 }

Here is the call graph for this function:

void rtc_send ( uint8_t  b  ) 

00024                          {
00025     PORTD &= ~_BV(6);
00026     SPDR = b;
00027     spi_wait();
00028 }


Generated on Sat Dec 12 00:45:14 2009 for Patashnik by  doxygen 1.6.1