ds1307.h File Reference

Routines for communicating with the ds1307 real time clock. More...

#include "i2c.h"
#include "pic_utils.h"

Include dependency graph for ds1307.h:

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

Go to the source code of this file.

Defines

#define __ds1307_h   defined
#define ds1307_control_register   0x07
#define ds1307_date_register   0x04
#define ds1307_day_register   0x03
#define ds1307_device   0xD0
#define ds1307_hours_register   0x02
#define ds1307_minutes_register   0x01
#define ds1307_month_register   0x05
#define ds1307_seconds_register   0x00
#define ds1307_year_register   0x06

Functions

uns8 rtc_get_config ()
 Get the config register from the ds1307.
uns8 rtc_get_date ()
 Get the date register from the ds1307.
uns8 rtc_get_day ()
 Get the day register from the ds1307.
uns8 rtc_get_hours ()
 Get the decoded hours register from the ds1307.
uns8 rtc_get_minutes ()
 Get the decoded minutes register from the ds1307.
uns8 rtc_get_month ()
 Get the month register from the ds1307.
uns8 rtc_get_seconds ()
 Get the decoded seconds register from the ds1307.
uns8 rtc_get_year ()
 Get the year register from the ds1307.
uns8 rtc_set_config (uns8 config)
 Set the config register in the ds1307.
void rtc_set_date (uns8 date)
 Set the date register from the ds1307.
void rtc_set_day (uns8 day)
 Set the day of the week register from the ds1307.
void rtc_set_hours (uns8 hours)
 Set the hours register in the ds1307.
void rtc_set_minutes (uns16 minutes)
 Set the minutes register from the ds1307.
void rtc_set_month (uns8 month)
 Set the month register in the ds1307.
void rtc_set_seconds (uns8 seconds)
 Set the seconds register in the ds1307.
void rtc_set_year (uns16 year)
 Set the year register from the ds1307.
void rtc_setup ()
 Setup ports and pins for use in the ds1307.
void rtc_start_clock ()
 Starts the clock in the ds1307.
void rtc_stop_clock ()
 Stop the clock in the ds1307.


Detailed Description

Definition in file ds1307.h.


Define Documentation

#define __ds1307_h   defined

Definition at line 8 of file ds1307.h.

#define ds1307_control_register   0x07

ds1307 control register

Definition at line 31 of file ds1307.h.

Referenced by rtc_get_config(), and rtc_set_config().

#define ds1307_date_register   0x04

ds1307 date in month register

Definition at line 25 of file ds1307.h.

Referenced by rtc_get_date(), and rtc_set_date().

#define ds1307_day_register   0x03

ds1307 day of week register

Definition at line 23 of file ds1307.h.

Referenced by rtc_get_day(), and rtc_set_day().

#define ds1307_device   0xD0

#define ds1307_hours_register   0x02

ds1307 hours register

Definition at line 21 of file ds1307.h.

Referenced by rtc_get_hours(), and rtc_set_hours().

#define ds1307_minutes_register   0x01

ds1307 minutes register

Definition at line 19 of file ds1307.h.

Referenced by rtc_get_minutes(), and rtc_set_minutes().

#define ds1307_month_register   0x05

ds1307 month register

Definition at line 27 of file ds1307.h.

Referenced by rtc_get_month(), and rtc_set_month().

#define ds1307_seconds_register   0x00

ds1307 seconds register

Definition at line 17 of file ds1307.h.

Referenced by rtc_get_seconds(), rtc_set_seconds(), rtc_start_clock(), and rtc_stop_clock().

#define ds1307_year_register   0x06

ds1307 year register

Definition at line 29 of file ds1307.h.

Referenced by rtc_get_year(), and rtc_set_year().


Function Documentation

uns8 rtc_get_config (  ) 

Returns the config register from the ds1307. Bit 7 - Out - Value on SQWE pin if not outputting square wave Bit 6 - 0 Bit 5 - 0 Bit 4 - SQWE - Enable square wave output Bit 3 - 0 Bit 2 - 0 Bit 1 - RS1 Bit 0 - RS0

RS1/0 determin the speed of the square wave output. Set to 0/0 for 1 Hz.

Definition at line 41 of file ds1307.c.

References ds1307_control_register, ds1307_device, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_date (  ) 

Returns the date in month from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range 1 through 28/29/30/31 depending on month

Definition at line 30 of file ds1307.c.

References bcd_to_dec(), ds1307_date_register, ds1307_device, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_day (  ) 

Returns the day of the week from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range - 1 through 7

Definition at line 26 of file ds1307.c.

References bcd_to_dec(), ds1307_day_register, ds1307_device, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_hours (  ) 

Returns hour from the ds1307. The result is coverted to decimal from BCD and is ready to use. These routines assume the ds1307 is running in 24 hour mode. Range - 0 through 23

Definition at line 15 of file ds1307.c.

References bcd_to_dec(), ds1307_device, ds1307_hours_register, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_minutes (  ) 

Returns the number of minutes past the hour from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range - 0 through 59

Definition at line 12 of file ds1307.c.

References bcd_to_dec(), ds1307_device, ds1307_minutes_register, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_month (  ) 

Returns the month of the year from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range 1 through 12

Definition at line 34 of file ds1307.c.

References bcd_to_dec(), ds1307_device, ds1307_month_register, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_seconds (  ) 

Returns seconds from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range - 0 through 59

Definition at line 22 of file ds1307.c.

References bcd_to_dec(), ds1307_device, ds1307_seconds_register, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_get_year (  ) 

Returns the year from the ds1307. The result is coverted to decimal from BCD and is ready to use. Range 0 through 99

Definition at line 37 of file ds1307.c.

References bcd_to_dec(), ds1307_device, ds1307_year_register, and i2c_read_eeprom().

Here is the call graph for this function:

uns8 rtc_set_config ( uns8  config  ) 

Sets the config register in the ds1307.

Bit 7 - Out - Value on SQWE pin if not outputting square wave Bit 6 - 0 Bit 5 - 0 Bit 4 - SQWE - Enable square wave output Bit 3 - 0 Bit 2 - 0 Bit 1 - RS1 Bit 0 - RS0

RS1/0 determin the speed of the square wave output. Set to 0/0 for 1 Hz.

Parameters:
config Value to set the config register to

Definition at line 45 of file ds1307.c.

References ds1307_control_register, ds1307_device, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_date ( uns8  date  ) 

Changes the date in the ds1307.

Parameters:
seconds Value to set date to

Definition at line 67 of file ds1307.c.

References dec_to_bcd(), ds1307_date_register, ds1307_device, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_day ( uns8  day  ) 

Changes the day of the week in the ds1307.

Parameters:
seconds Value to set day to

Definition at line 64 of file ds1307.c.

References dec_to_bcd(), ds1307_day_register, ds1307_device, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_hours ( uns8  hours  ) 

Changes the hours in the ds1307. Forces the ds1307 into 24 hour mode.

Definition at line 75 of file ds1307.c.

References dec_to_bcd(), ds1307_device, ds1307_hours_register, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_minutes ( uns16  minutes  ) 

Changes the minutes in the ds1307.

Parameters:
seconds Value to set minutes to

Definition at line 61 of file ds1307.c.

References dec_to_bcd(), ds1307_device, ds1307_minutes_register, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_month ( uns8  month  ) 

Changes the month in the ds1307.

Definition at line 80 of file ds1307.c.

References dec_to_bcd(), ds1307_device, ds1307_month_register, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_seconds ( uns8  seconds  ) 

Changes the seconds in the ds1307.

Parameters:
seconds Value to set seconds to

Definition at line 71 of file ds1307.c.

References dec_to_bcd(), ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_set_year ( uns16  year  ) 

Changes the year in the ds1307.

Definition at line 58 of file ds1307.c.

References dec_to_bcd(), ds1307_device, ds1307_year_register, and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_setup (  ) 

Calls i2c_setup() to configure ports and pins ready for use

Definition at line 84 of file ds1307.c.

References i2c_setup().

Here is the call graph for this function:

void rtc_start_clock (  ) 

Resume time in the ds1307

Definition at line 54 of file ds1307.c.

References ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), and i2c_write_eeprom().

Here is the call graph for this function:

void rtc_stop_clock (  ) 

Pauses time in the ds1307

Definition at line 50 of file ds1307.c.

References ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), and i2c_write_eeprom().

Here is the call graph for this function:


Generated on Tue Jul 22 09:31:53 2008 for Pic Pack by  doxygen 1.5.5