DS1904 API Overview
This API contains the functions to configure and control a DS1904 Real-Time-Clock over a 1-Wire bus.
Platform-specific layer provides a consistent MACROS API to upper layers of the driver.
DS1904 RTC Macros
The DS1904 has 2 specific commands that are defined as the following macros:
- DS1904_READ_CLOCK : Allows master to read the current time value and configuration resgister.
- DS1904_WRITE_CLOCK : Allows master to write time and configuration resgiers. Also there are defined the two combinations of configuration register to enable or disable internal oscillator:
- DS1904_OSC_ENABLE : Enables RTC oscillator.
- DS1904_OSC_DISABLE : Disables.
Converts a date to epoch time.
- Parameters
-
[in] | date | address where ROM of device is stored. |
- Return values
-
date | in epoch time (0 for 0:00 of 1/1/1970). |
Reads the RTC time-register and updates global time.
- Parameters
-
[in] | rom | address where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus. |
- Return values
-
0 | on success. |
<0 | if there is any error. |
Returns current date and time from RTC.
- Parameters
-
[out] | date | address where current date will be written. |
- Return values
-
Reads configuration and time registers.
- Parameters
-
[in] | rom | address where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus. |
[out] | config | address where configuration register will be stored. |
[out] | time | address where time-count register will be stored. |
- Return values
-
0 | on success. |
<0 | if there is any error. |
Enables or disables RTC's oscillator maintaining current time value.
- Parameters
-
[in] | rom | address where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus. |
[in] | enable | TRUE for enabling and FALSE for disabling. |
- Return values
-
0 | on success. |
<0 | if there is any error. |
Writes configuration and time registers.
- Parameters
-
[in] | rom | address where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus. |
[in] | config | configuration register to be written. |
[in] | time | time-count register to be written. |
- Return values
-
0 | on success. |
<0 | if there is any error. |