My Project  1.3
WaveShare DS1302 Clock Module
Macros | Functions
ds1302.h File Reference

Clock Calender device. More...

Go to the source code of this file.

Macros

#define DS1302SECONDS   0x81
 
#define DS1302MINUTES   0x83
 
#define DS1302HOURS   0x85
 
#define DS1302DAY   0x87
 
#define DS1302MONTH   0x89
 
#define DS1302WEEKDAY   0x8B
 
#define DS1302YEAR   0x8D
 
#define DS1302WP   0x8F
 
#define DS1302BURSTRD   0xBF
 
#define DS1302BURSTMM   0xFF
 

Functions

void DS1302_open (short mosi, short cs, short sclk, short miso)
 open connection to clock chip More...
 
short DS1302_getSeconds (void)
 get seconds More...
 
short DS1302_getMinutes (void)
 get minutes More...
 
short DS1302_getHours (void)
 get hours More...
 
char * DS1302_getAMPM (void)
 get am/pm string More...
 
short DS1302_getDay (void)
 get day More...
 
short DS1302_getMonth (void)
 get month More...
 
short DS1302_getWeekDay (void)
 get day of the week More...
 
short DS1302_getYear (void)
 Get year value. More...
 
void DS1302_setDate (short year, short month, short day)
 set Date More...
 
void DS1302_setYear (short year)
 set year More...
 
void DS1302_setMonth (short month)
 set month More...
 
void DS1302_setDay (short day)
 set day More...
 
void DS1302_setWeekDay (short weekday)
 set day of the week More...
 
void DS1302_setTime (short hours, short minutes, short seconds)
 set time More...
 
void DS1302_setHour (short hour)
 set hours More...
 
void DS1302_set12Hour (short hour, char AmPm)
 set 12 hour format More...
 
void DS1302_setMinute (short minutes)
 set minutes More...
 
void DS1302_setSecond (short seconds)
 set seconds More...
 
short DS1302_getWriteProtect (void)
 get write protect state More...
 
void DS1302_setWriteProtect (void)
 set write protect state prevents any register from being written to
 
void DS1302_clearWriteProtect (void)
 clear write protect state must be called before changing any date/time value or message
 
void DS1302_setDateTime (void)
 set propeller date/time This sets the tick value for unix date time functions used in the propeller libraries and the time must be accessed before every 54 seonds or time will be lost
 
void DS1302_setMessage (char *msg)
 save message in ram More...
 
char * DS1302_getMessage (void)
 get message from ram More...
 

Detailed Description

Clock Calender device.

Author
Michael Burmeister
Date
January 14, 2017
Version
1.2

Function Documentation

◆ DS1302_getAMPM()

char* DS1302_getAMPM ( void  )

get am/pm string

Returns
ampm AM/PM string

◆ DS1302_getDay()

short DS1302_getDay ( void  )

get day

Returns
day

◆ DS1302_getHours()

short DS1302_getHours ( void  )

get hours

Returns
seconds returns the hours in 24 hour format or 12 hour format. In 12 hour format use getAMPM to return a string with AM/PM value.

◆ DS1302_getMessage()

char* DS1302_getMessage ( void  )

get message from ram

Returns
message

◆ DS1302_getMinutes()

short DS1302_getMinutes ( void  )

get minutes

Returns
minutes

◆ DS1302_getMonth()

short DS1302_getMonth ( void  )

get month

Returns
month

◆ DS1302_getSeconds()

short DS1302_getSeconds ( void  )

get seconds

Returns
seconds

◆ DS1302_getWeekDay()

short DS1302_getWeekDay ( void  )

get day of the week

Returns
day

◆ DS1302_getWriteProtect()

short DS1302_getWriteProtect ( void  )

get write protect state

Returns
0 - false 1 - true

◆ DS1302_getYear()

short DS1302_getYear ( void  )

Get year value.

Returns
year only last 2 digits

◆ DS1302_open()

void DS1302_open ( short  mosi,
short  cs,
short  sclk,
short  miso 
)

open connection to clock chip

Parameters
mosiMaster out slave in pin
csChip Select pin
sclkSystem Clock pin
misoMaster in slave out pin

◆ DS1302_set12Hour()

void DS1302_set12Hour ( short  hour,
char  AmPm 
)

set 12 hour format

Parameters
hourin 12 hour format
AmPmuse A for AM and P for PM

◆ DS1302_setDate()

void DS1302_setDate ( short  year,
short  month,
short  day 
)

set Date

Parameters
yearlast two digits only
month
day

◆ DS1302_setDay()

void DS1302_setDay ( short  day)

set day

Parameters
day

◆ DS1302_setHour()

void DS1302_setHour ( short  hour)

set hours

Parameters
hourMust be in 24 hour format

◆ DS1302_setMessage()

void DS1302_setMessage ( char *  msg)

save message in ram

Parameters
msgSave a short message to ram 31 bytes max

◆ DS1302_setMinute()

void DS1302_setMinute ( short  minutes)

set minutes

Parameters
minutes

◆ DS1302_setMonth()

void DS1302_setMonth ( short  month)

set month

Parameters
month

◆ DS1302_setSecond()

void DS1302_setSecond ( short  seconds)

set seconds

Parameters
seconds

◆ DS1302_setTime()

void DS1302_setTime ( short  hours,
short  minutes,
short  seconds 
)

set time

Parameters
hours
minutes
secondshours are in 24 hour format

◆ DS1302_setWeekDay()

void DS1302_setWeekDay ( short  weekday)

set day of the week

Parameters
weekdaynumber from 1-sunday, 7 - saturday

◆ DS1302_setYear()

void DS1302_setYear ( short  year)

set year

Parameters
yearonly the last 2 digits of the year