PIC18 LaurTec Library  3.0 Beta
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
DS1337.h File Reference

Go to the source code of this file.

Macros

#define WRITE_ADD   0xD0
 
#define DO   0x00
 
#define LU   0x01
 
#define MA   0x02
 
#define ME   0x03
 
#define GI   0x04
 
#define VE   0x05
 
#define SA   0x06
 
#define SU   0x00
 
#define MO   0x01
 
#define TU   0x02
 
#define WE   0x03
 
#define TR   0x04
 
#define FR   0x05
 
#define SA   0x06
 
#define ENABLE_ON   0b00000000
 
#define ENABLE_OFF   0b10000000
 
#define SECONDS_ADDR   0x00
 
#define MINUTES_ADDR   0x01
 
#define HOURS_ADDR   0x02
 
#define DAYS_ADDR   0x03
 
#define MONTHS_ADDR   0x05
 
#define YEARS_ADDR   0x06
 
#define SECONDS_ALARM_ADDR   0x07
 
#define MINUTS_ALARM_ADDR   0x08
 
#define HOURS_ALARM_ADDR   0x09
 
#define DAYS_ALARM_ADDR   0x0A
 
#define MINUTS_ALARM_2_ADDR   0x0B
 
#define HOURS_ALARM_2_ADDR   0x0C
 
#define DAYS_ALARM_2_ADDR   0x0D
 
#define CONTROL_REG_1_ADDR   0x0E
 
#define CONTROL_REG_2_ADDR   0x0F
 
#define MAX_MINUTES   0x60
 
#define MAX_HOURS   0x24
 
#define MAX_YEARS   0xA0
 
#define MAX_MONTHS   0x13
 
#define MAX_DAYS   0x32
 

Functions

signed char set_seconds_RTCC (unsigned char seconds)
 
unsigned char get_seconds_RTCC (void)
 
signed char set_minutes_RTCC (unsigned char minutes)
 
unsigned char get_minutes_RTCC (void)
 
signed char set_hours_RTCC (unsigned char hours)
 
unsigned char get_hours_RTCC (void)
 
unsigned char * get_time_seconds_RTCC (void)
 
unsigned char * get_time_RTCC (void)
 
signed char set_days_RTCC (unsigned char days)
 
unsigned char get_days_RTCC (void)
 
signed char set_months_RTCC (unsigned char months)
 
unsigned char get_months_RTCC (void)
 
signed char set_years_RTCC (unsigned char years)
 
unsigned char get_years_RTCC (void)
 
unsigned char * get_date_RTCC (void)
 
signed char set_seconds_alarm_RTCC (unsigned char seconds, unsigned char alarm_enable)
 
signed char set_minutes_alarm_RTCC (unsigned char minutes, unsigned char alarm_enable)
 
signed char set_hours_alarm_RTCC (unsigned char hours, unsigned char alarm_enable)
 
signed char set_days_alarm_RTCC (unsigned char days, unsigned char alarm_enable)
 
signed char enable_alarm_interrupt_RTCC (void)
 
signed char disable_alarm_interrupt_RTCC (void)
 
unsigned char is_alarm_ON_RTCC (void)
 
signed char increment_minutes_RTCC (void)
 
signed char increment_hours_RTCC (void)
 
signed char increment_years_RTCC (void)
 
signed char increment_months_RTCC (void)
 
signed char increment_days_RTCC (void)
 

Macro Definition Documentation

#define CONTROL_REG_1_ADDR   0x0E

Definition at line 123 of file DS1337.h.

#define CONTROL_REG_2_ADDR   0x0F

Definition at line 124 of file DS1337.h.

#define DAYS_ADDR   0x03

Definition at line 113 of file DS1337.h.

#define DAYS_ALARM_2_ADDR   0x0D

Definition at line 122 of file DS1337.h.

#define DAYS_ALARM_ADDR   0x0A

Definition at line 119 of file DS1337.h.

#define DO   0x00

Definition at line 78 of file DS1337.h.

#define ENABLE_OFF   0b10000000

Definition at line 103 of file DS1337.h.

#define ENABLE_ON   0b00000000

Definition at line 102 of file DS1337.h.

#define FR   0x05

Definition at line 92 of file DS1337.h.

#define GI   0x04

Definition at line 82 of file DS1337.h.

#define HOURS_ADDR   0x02

Definition at line 112 of file DS1337.h.

#define HOURS_ALARM_2_ADDR   0x0C

Definition at line 121 of file DS1337.h.

#define HOURS_ALARM_ADDR   0x09

Definition at line 118 of file DS1337.h.

#define LU   0x01

Definition at line 79 of file DS1337.h.

#define MA   0x02

Definition at line 80 of file DS1337.h.

#define MAX_DAYS   0x32

Definition at line 133 of file DS1337.h.

#define MAX_HOURS   0x24

Definition at line 130 of file DS1337.h.

#define MAX_MINUTES   0x60

Definition at line 129 of file DS1337.h.

#define MAX_MONTHS   0x13

Definition at line 132 of file DS1337.h.

#define MAX_YEARS   0xA0

Definition at line 131 of file DS1337.h.

#define ME   0x03

Definition at line 81 of file DS1337.h.

#define MINUTES_ADDR   0x01

Definition at line 111 of file DS1337.h.

#define MINUTS_ALARM_2_ADDR   0x0B

Definition at line 120 of file DS1337.h.

#define MINUTS_ALARM_ADDR   0x08

Definition at line 117 of file DS1337.h.

#define MO   0x01

Definition at line 88 of file DS1337.h.

#define MONTHS_ADDR   0x05

Definition at line 114 of file DS1337.h.

#define SA   0x06

Definition at line 93 of file DS1337.h.

#define SA   0x06

Definition at line 93 of file DS1337.h.

#define SECONDS_ADDR   0x00

Definition at line 110 of file DS1337.h.

#define SECONDS_ALARM_ADDR   0x07

Definition at line 116 of file DS1337.h.

#define SU   0x00

Definition at line 87 of file DS1337.h.

#define TR   0x04

Definition at line 91 of file DS1337.h.

#define TU   0x02

Definition at line 89 of file DS1337.h.

#define VE   0x05

Definition at line 83 of file DS1337.h.

#define WE   0x03

Definition at line 90 of file DS1337.h.

#define WRITE_ADD   0xD0

Definition at line 71 of file DS1337.h.

#define YEARS_ADDR   0x06

Definition at line 115 of file DS1337.h.

Function Documentation

signed char disable_alarm_interrupt_RTCC ( void  )

This function disable the interrupt pin funtionality.

Returns
status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision

Definition at line 341 of file DS1337.c.

signed char enable_alarm_interrupt_RTCC ( void  )

This function enables the interrupt pin funtionality.

Returns
status 1: The info has been properly written -1: Bus Collision error -2: Not Ack error condition -3: Write collision

Definition at line 331 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 termianted with /0

Definition at line 249 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 191 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 107 of file DS1337.c.

unsigned char get_minutes_RTCC ( void  )

This function reads the muntes 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 84 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 215 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 57 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 termianted with /0

Definition at line 154 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 termianted with /0

Definition at line 121 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 238 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 514 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 410 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 incremetns the hours.

Definition at line 375 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 480 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 445 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 351 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
daysDays to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010).
alarmEnableEnable 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 319 of file DS1337.c.

signed char set_days_RTCC ( unsigned char  days)

This function writes the days in the RTC.

Parameters
daysDay 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 182 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
hoursHours to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010).
alarmEnableEnable 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 308 of file DS1337.c.

signed char set_hours_RTCC ( unsigned char  hours)

This function writes the hours in the RTC.

Parameters
hoursHours 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 98 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
minutesMinutes to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010).
alarmEnableEnable 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 295 of file DS1337.c.

signed char set_minutes_RTCC ( unsigned char  minutes)

This function writes the seconds in the RTC.

Parameters
minutesMinutes 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 74 of file DS1337.c.

signed char set_months_RTCC ( unsigned char  months)

This function writes the moths in the RTC.

Parameters
monthsMonths 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 205 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
secondsSeconds to be written, as 2 digits BCD format (eg. 12 is 0x12 or 0b00010010).
alarmEnableEnable 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 283 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
secondsSeconds 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 47 of file DS1337.c.

signed char set_years_RTCC ( unsigned char  years)

This function writes the Year in the RTC.

Parameters
yearsYear 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 229 of file DS1337.c.