#include "m41t81s.h"
#include "pic_serial.h"
Go to the source code of this file.
Functions | |
uns8 | bcd_to_dec (uns8 bcd) |
uns8 | dec_to_bcd (uns8 dec) |
uns8 | rtc_get_date () |
Get the date register from the ds1307. | |
uns8 | rtc_get_dow () |
Get the day register from the m41t81s. | |
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_register (uns8 reg) |
uns8 | rtc_get_seconds () |
Get the decoded seconds register from the ds1307. | |
uns8 | rtc_get_year () |
Get the year register from 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 (uns8 minutes) |
Set the minutes register from the m41t81s. | |
void | rtc_set_month (uns8 month) |
Set the month register in the ds1307. | |
void | rtc_set_register (uns8 reg, uns8 data) |
void | rtc_set_seconds (uns8 seconds) |
Set the seconds register in the ds1307. | |
void | rtc_set_sqw_freq (uns8 freq) |
Set the frequence of the square wave output pin. | |
void | rtc_set_year (uns8 year) |
Set the year register from the m41t81s. | |
void | rtc_setup_io () |
Setup ports and pins for use in the ds1307. | |
void | rtc_start_clock () |
Starts the clock in the ds1307. | |
void | rtc_start_sqw_output () |
Start pulsing on square wave output pin. | |
void | rtc_stop_clock () |
Stop the clock in the ds1307. | |
void | rtc_stop_sqw_output () |
Stop pulsing on square wave output pin. |
uns8 rtc_get_date | ( | ) |
Get the date register from the m41t81s.
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 66 of file m41t81s.c.
References bcd_to_dec(), ds1307_date_register, ds1307_device, i2c_read_eeprom(), m41t81s_date_reg, and m41t81s_device_addr.
uns8 rtc_get_dow | ( | ) |
Returns the day of the week from the m41t81s. The result is coverted to decimal from BCD and is ready to use. Range - 1 through 7
Definition at line 62 of file m41t81s.c.
References bcd_to_dec(), i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_dow_reg.
uns8 rtc_get_hours | ( | ) |
Get the decoded hours register from the m41t81s.
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 51 of file m41t81s.c.
References bcd_to_dec(), ds1307_device, ds1307_hours_register, i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_hours_reg.
uns8 rtc_get_minutes | ( | ) |
Get the decoded minutes register from the m41t81s.
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 48 of file m41t81s.c.
References bcd_to_dec(), ds1307_device, ds1307_minutes_register, i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_minutes_reg.
uns8 rtc_get_month | ( | ) |
Get the month register from the m41t81s.
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 70 of file m41t81s.c.
References bcd_to_dec(), ds1307_device, ds1307_month_register, i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_month_reg.
uns8 rtc_get_register | ( | uns8 | reg | ) |
Definition at line 78 of file m41t81s.c.
References i2c_read_eeprom(), and m41t81s_device_addr.
Referenced by rtc_start_sqw_output(), and rtc_stop_sqw_output().
uns8 rtc_get_seconds | ( | ) |
Get the decoded seconds register from the m41t81s.
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 58 of file m41t81s.c.
References bcd_to_dec(), ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_seconds_reg.
uns8 rtc_get_year | ( | ) |
Get the year register from the m41t81s.
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 74 of file m41t81s.c.
References bcd_to_dec(), ds1307_device, ds1307_year_register, i2c_read_eeprom(), m41t81s_device_addr, and m41t81s_year_reg.
void rtc_set_date | ( | uns8 | date | ) |
Set the date register from the m41t81s.
Changes the date in the ds1307.
seconds | Value to set date to |
Definition at line 107 of file m41t81s.c.
References dec_to_bcd(), ds1307_date_register, ds1307_device, i2c_write_eeprom(), m41t81s_date_reg, and m41t81s_device_addr.
void rtc_set_day | ( | uns8 | day | ) |
Set the day of the week register from the m41t81s.
Changes the day of the week in the ds1307.
seconds | Value to set day to |
Definition at line 104 of file m41t81s.c.
References dec_to_bcd(), ds1307_day_register, ds1307_device, i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_dow_reg.
void rtc_set_hours | ( | uns8 | hours | ) |
Set the hours register in the m41t81s.
Changes the hours in the ds1307. Forces the ds1307 into 24 hour mode.
Definition at line 116 of file m41t81s.c.
References dec_to_bcd(), ds1307_device, ds1307_hours_register, i2c_read_eeprom(), i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_hours_reg.
void rtc_set_minutes | ( | uns8 | minutes | ) |
Changes the minutes in the m41t81s.
seconds | Value to set minutes to |
Definition at line 101 of file m41t81s.c.
References dec_to_bcd(), i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_minutes_reg.
void rtc_set_month | ( | uns8 | month | ) |
Set the month register in the m41t81s.
Changes the month in the ds1307.
Definition at line 121 of file m41t81s.c.
References dec_to_bcd(), ds1307_device, ds1307_month_register, i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_month_reg.
void rtc_set_register | ( | uns8 | reg, | |
uns8 | data | |||
) |
Definition at line 82 of file m41t81s.c.
References i2c_write_eeprom(), and m41t81s_device_addr.
Referenced by rtc_set_sqw_freq(), rtc_start_sqw_output(), and rtc_stop_sqw_output().
void rtc_set_seconds | ( | uns8 | seconds | ) |
Set the seconds register in the m41t81s.
Changes the seconds in the ds1307.
seconds | Value to set seconds to |
Definition at line 111 of file m41t81s.c.
References dec_to_bcd(), ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_seconds_reg.
void rtc_set_sqw_freq | ( | uns8 | freq | ) |
Use one of the following self explanitory defines:
rtc_sqw_freq_32768Hz rtc_sqw_freq_8192Hz rtc_sqw_freq_4096Hz rtc_sqw_freq_2048Hz rtc_sqw_freq_1024Hz rtc_sqw_freq_512Hz rtc_sqw_freq_256Hz rtc_sqw_freq_128Hz rtc_sqw_freq_64Hz rtc_sqw_freq_32Hz rtc_sqw_freq_16Hz rtc_sqw_freq_8Hz rtc_sqw_freq_4Hz rtc_sqw_freq_2Hz rtc_sqw_freq_1Hz
Note that on the m41t81s 18384Hz is not available.
Definition at line 125 of file m41t81s.c.
References m41t81s_sqw_reg, and rtc_set_register().
void rtc_set_year | ( | uns8 | year | ) |
Changes the year in the m41t81s.
Definition at line 98 of file m41t81s.c.
References dec_to_bcd(), i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_year_reg.
void rtc_setup_io | ( | ) |
Setup ports and pins for use in the m41t81s.
Calls i2c_setup() to configure ports and pins ready for use
Definition at line 143 of file m41t81s.c.
References i2c_setup_io().
void rtc_start_clock | ( | ) |
Starts the clock in the m41t81s.
Resume time in the ds1307
Definition at line 91 of file m41t81s.c.
References ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), i2c_write_eeprom(), m41t81s_alarm_hour_reg, m41t81s_device_addr, and m41t81s_seconds_reg.
void rtc_start_sqw_output | ( | ) |
Outputs desired frequency on the SQW output pin. To set the frequency, see rtc_set_sqw_freq(uns8 freq);
Definition at line 131 of file m41t81s.c.
References m41t81s_alarm_month_reg, rtc_get_register(), and rtc_set_register().
void rtc_stop_clock | ( | ) |
Stop the clock in the m41t81s.
Pauses time in the ds1307
Definition at line 87 of file m41t81s.c.
References ds1307_device, ds1307_seconds_register, i2c_read_eeprom(), i2c_write_eeprom(), m41t81s_device_addr, and m41t81s_seconds_reg.
void rtc_stop_sqw_output | ( | ) |
Stops square wave output
Definition at line 136 of file m41t81s.c.
References m41t81s_alarm_month_reg, rtc_get_register(), and rtc_set_register().