#include <i2c.h>
Go to the source code of this file.
#define CONTROL_REG_1_ADDR 0x0E |
#define CONTROL_REG_2_ADDR 0x0F |
#define DAYS_ALARM_2_ADDR 0x0D |
#define DAYS_ALARM_ADDR 0x0A |
#define ENABLE_OFF 0b10000000 |
#define ENABLE_ON 0b00000000 |
#define HOURS_ALARM_2_ADDR 0x0C |
#define HOURS_ALARM_ADDR 0x09 |
#define MINUTES_ADDR 0x01 |
#define MINUTS_ALARM_2_ADDR 0x0B |
#define MINUTS_ALARM_ADDR 0x08 |
#define SECONDS_ADDR 0x00 |
#define SECONDS_ALARM_ADDR 0x07 |
signed char disable_alarm_interrupt_RTCC |
( |
void |
| ) |
|
This function disable the interrupt pin functionality.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
Definition at line 357 of file DS1337.c.
signed char enable_alarm_interrupt_RTCC |
( |
void |
| ) |
|
This function enables the interrupt pin functionality.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
Definition at line 344 of file DS1337.c.
unsigned char* get_date_RTCC |
( |
void |
| ) |
|
This function reads the Date from the RTC. The Format DD/MM/YY
- Returns
- Date that is read back, as ASCII string terminated with /0
Definition at line 262 of file DS1337.c.
unsigned char get_days_RTCC |
( |
void |
| ) |
|
This function reads the day from the RTC.
- Returns
- Days that are read back, in BCD format (eg. 12 is 0x12 or 0b00010010).
- Note
- Days are in BCD format.
Definition at line 204 of file DS1337.c.
unsigned char get_hours_RTCC |
( |
void |
| ) |
|
This function reads the hours from the RTC.
- Returns
- Hours that are read back, in BCD format (eg. 12 is 0x12 or 0b00010010).
- Note
- Hours are in BCD format.
Definition at line 120 of file DS1337.c.
unsigned char get_minutes_RTCC |
( |
void |
| ) |
|
This function reads the minutes from the RTC.
- Returns
- Minutes that are read back, in BCD format (eg. 22 min. is 0x22 or 0b00100010).
- Note
- Seconds are in BCD format.
Definition at line 97 of file DS1337.c.
unsigned char get_months_RTCC |
( |
void |
| ) |
|
This function reads the months from the RTC.
- Returns
- Months that are read back, in BCD format (eg. 12 is 0x12 or 0b00010010).
- Note
- Months are in BCD format.
Definition at line 228 of file DS1337.c.
unsigned char get_seconds_RTCC |
( |
void |
| ) |
|
This function reads the second from the RTC.
- Returns
- Second that are read back, in BCD format (eg. 22 sec. is 0x22 or 0b00100010).
- Note
- Seconds are in BCD format.
Definition at line 70 of file DS1337.c.
unsigned char* get_time_RTCC |
( |
void |
| ) |
|
This function reads the time from the RTC. The format is HH:MM (without seconds)
- Returns
- Time that is read back, as ASCII string terminated with /0
Definition at line 167 of file DS1337.c.
unsigned char* get_time_seconds_RTCC |
( |
void |
| ) |
|
This function reads the time from the RTC. The format is HH:MM.ss
- Returns
- Time that is read back, as ASCII string terminated with /0
Definition at line 134 of file DS1337.c.
unsigned char get_years_RTCC |
( |
void |
| ) |
|
This function reads the Year from the RTC.
- Returns
- Year that is read back, in BCD format (eg. 12 is 0x12 or 0b00010010 represents 2012).
- Note
- Year are in BCD format. 2012 is read as 0x12.
Definition at line 251 of file DS1337.c.
signed char increment_days_RTCC |
( |
void |
| ) |
|
This function increments the Days inside the RTCC.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Note
- The function automatically checks the overflow.
Definition at line 530 of file DS1337.c.
signed char increment_hours_RTCC |
( |
void |
| ) |
|
This function increments the hours inside the RTCC.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Note
- The function automatically checks the overflow.
Definition at line 426 of file DS1337.c.
signed char increment_minutes_RTCC |
( |
void |
| ) |
|
This function increments the minutes inside the RTCC.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Note
- The function automatically checks the overflow and automatically increments the hours.
Definition at line 391 of file DS1337.c.
signed char increment_months_RTCC |
( |
void |
| ) |
|
This function increments the Months inside the RTCC.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Note
- The function automatically checks the overflow.
Definition at line 496 of file DS1337.c.
signed char increment_years_RTCC |
( |
void |
| ) |
|
This function increments the Years inside the RTCC.
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Note
- The function automatically checks the overflow.
Definition at line 461 of file DS1337.c.
void initialize_DS1337 |
( |
unsigned char |
crystal_frequency_MHz, |
|
|
unsigned int |
baud_rate_KHz |
|
) |
| |
This function initialize the I2C module accordingly to the clock and baud rate.
- Parameters
-
crystal_frequency_MHz | Clock frequency expressed in MHz |
baud_rate_KHz | Baud rate expressed in KHz |
- Returns
- Note
- If other devices are connected on the I2C bus the baud rate would be changed by the function. Among several calls from different device initializations, only the last one will be reflected in the I2C module configuration.
Definition at line 49 of file DS1337.c.
unsigned char is_alarm_ON_RTCC |
( |
void |
| ) |
|
This function checks if the Alarm id ON using polling method.
- Returns
- status Alarm status 1: ON 0:OFF
- Note
- If the alarm is on, AF flag is automatically cleaned.
Definition at line 367 of file DS1337.c.
signed char set_days_alarm_RTCC |
( |
unsigned char |
days, |
|
|
unsigned char |
alarm_enable |
|
) |
| |
This function writes the Days for the alarm, in the RTC.
- Parameters
-
days | Days to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
alarmEnable | Enable the alarm or not (for matching) [ENABLE_ON , ENABLE_OFF] |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Days are in BCD format. Decimal format won't work!
- Note
- Use the constants ENABLE_ON and ENABLE_OFF
Definition at line 332 of file DS1337.c.
signed char set_days_RTCC |
( |
unsigned char |
days | ) |
|
This function writes the days in the RTC.
- Parameters
-
days | Day to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Days are in BCD format. Decimal format won't work!
Definition at line 195 of file DS1337.c.
signed char set_hours_alarm_RTCC |
( |
unsigned char |
hours, |
|
|
unsigned char |
alarm_enable |
|
) |
| |
This function writes the hours for the alarm, in the RTC.
- Parameters
-
hours | Hours to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
alarmEnable | Enable the alarm or not (for matching) [ENABLE_ON , ENABLE_OFF] |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Hours are in BCD format. Decimal format won't work!
- Note
- Use the constants ENABLE_ON and ENABLE_OFF
Definition at line 321 of file DS1337.c.
signed char set_hours_RTCC |
( |
unsigned char |
hours | ) |
|
This function writes the hours in the RTC.
- Parameters
-
hours | Hours to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Hours are in BCD format. Decimal format won't work!
Definition at line 111 of file DS1337.c.
signed char set_minutes_alarm_RTCC |
( |
unsigned char |
minutes, |
|
|
unsigned char |
alarm_enable |
|
) |
| |
This function writes the minutes for the alarm, in the RTC.
- Parameters
-
minutes | Minutes to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
alarmEnable | Enable the alarm or not (for matching) [ENABLE_ON , ENABLE_OFF] |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Minutes are in BCD format. Decimal format won't work!
- Note
- Use the constants ENABLE_ON and ENABLE_OFF
Definition at line 308 of file DS1337.c.
signed char set_minutes_RTCC |
( |
unsigned char |
minutes | ) |
|
This function writes the seconds in the RTC.
- Parameters
-
minutes | Minutes to be written, as 2 digits BCD format (eg. 22 min. is 0x22 or 0b00100010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Minutes are in BCD format. Decimal format won't work!
Definition at line 87 of file DS1337.c.
signed char set_months_RTCC |
( |
unsigned char |
months | ) |
|
This function writes the moths in the RTC.
- Parameters
-
months | Months to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Months are in BCD format. Decimal format won't work!
Definition at line 218 of file DS1337.c.
signed char set_seconds_alarm_RTCC |
( |
unsigned char |
seconds, |
|
|
unsigned char |
alarm_enable |
|
) |
| |
This function writes the seconds for the alarm, in the RTC.
- Parameters
-
seconds | Seconds to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010). |
alarmEnable | Enable the alarm or not (for matching) [ENABLE_ON , ENABLE_OFF] |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Seconds are in BCD format. Decimal format won't work!
- Note
- Use the constants ENABLE_ON and ENABLE_OFF
Definition at line 296 of file DS1337.c.
References SECONDS_ALARM_ADDR, and WRITE_ADD.
signed char set_seconds_RTCC |
( |
unsigned char |
seconds | ) |
|
This function writes the seconds in the RTC.
- Parameters
-
seconds | Seconds to be written, as 2 digits BCD format (eg. 22 sec. is 0x22 or 0b00100010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Seconds are in BCD format. Decimal format won't work!
Definition at line 60 of file DS1337.c.
signed char set_years_RTCC |
( |
unsigned char |
years | ) |
|
This function writes the Year in the RTC.
- Parameters
-
years | Year to be written, as 2 digits BCD format (eg. 2012 is only 0x12 or 0b00010010). |
- Returns
- status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision
- Warning
- Years are in BCD format. Decimal format won't work!
- Note
- 2012 is written as 12.
Definition at line 242 of file DS1337.c.