Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RTC-DS1307 by
DS1307 Class Reference
Class Rtc_Ds1307 implements the real time clock module DS1307. More...
#include <DS1307.h>
Inherited by RtcCls.
Data Structures | |
| struct | Time_rtc |
| Structure which is used to exchange the time and date. More... | |
Public Types | |
| enum | SqwRateSelect_t |
RateSelect specifies the valid frequency values for the square wave output. More... | |
Public Member Functions | |
| DS1307 (I2C *) | |
| public constructor which creates the real time clock object | |
| virtual bool | getTime (Time_rtc &time) |
| Read the current time from RTC chip. | |
| virtual bool | setTime (Time_rtc &time, bool start, bool thm) |
| Write the given time onto the RTC chip. | |
| bool | startClock () |
| Start the clock. | |
| bool | stopClock () |
| Stop the clock. | |
| const char * | weekdayToString (int wday) |
| Service function to convert a weekday into a string representation. | |
| bool | setSquareWaveOutput (bool ena, SqwRateSelect_t rs) |
| Enable Square Wave output. | |
Detailed Description
Class Rtc_Ds1307 implements the real time clock module DS1307.
You can read the clock and set a new time and date. It is also possible to start and stop the clock. Rtc_Ds1307 allows you to display the time in a 12h or 24h format
Definition at line 36 of file DS1307.h.
Member Enumeration Documentation
| enum SqwRateSelect_t |
Constructor & Destructor Documentation
| DS1307 | ( | I2C * | i2c ) |
public constructor which creates the real time clock object
- Parameters:
-
sda : specifies the pin for the SDA communication line. scl : the pin for the serial clock
Definition at line 12 of file DS1307.cpp.
Member Function Documentation
| bool getTime | ( | Time_rtc & | time ) | [virtual] |
Read the current time from RTC chip.
- Parameters:
-
time : reference to a struct tm which will be filled with the time from rtc
- Returns:
- true if successful, otherwise an acknowledge error occured
Definition at line 64 of file DS1307.cpp.
| bool setSquareWaveOutput | ( | bool | ena, |
| SqwRateSelect_t | rs | ||
| ) |
Enable Square Wave output.
The function enables or disables the square wave output of the module and sets the desired frequency.
- Parameters:
-
ena : if set to true, the square wave output is enabled. rs : rate select, can be either one of the four values defined by type /c RateSelect_t
- Returns:
- true if the operation was successful or false otherwise
Definition at line 139 of file DS1307.cpp.
| bool setTime | ( | Time_rtc & | time, |
| bool | start, | ||
| bool | thm | ||
| ) | [virtual] |
Write the given time onto the RTC chip.
- Parameters:
-
time : refereence to a struct which contains valid date and time information start : contains true if the clock shall start (or keep on running). thm : 12-hour-mode if set to true, otherwise 24-hour-mode will be set.
- Returns:
- true if successful, otherwise an acknowledge error occured
Definition at line 29 of file DS1307.cpp.
| bool startClock | ( | ) |
Start the clock.
Please note that the seconds register need to be read and written in order to start or stop the clock. This can lead to an error in the time value. The recommended way of starting and stoping the clock is to write the actual date and time and set the start bit accordingly.
- Returns:
- true if the clock was started, false if a communication error occured
Definition at line 95 of file DS1307.cpp.
| bool stopClock | ( | ) |
Stop the clock.
Please note that the seconds register need to be read and written in order to start or stop the clock. This can lead to an error in the time value. The recommended way of starting and stoping the clock is to write the actual date and time and set the start bit accordingly.
- Returns:
- true if the clock was stopped, false if a communication error occured
Definition at line 117 of file DS1307.cpp.
Generated on Sun Jul 17 2022 00:49:39 by
1.7.2
