Driver for the Maxim DS3231 extremely accurate RTC.
More...
Driver for the Maxim DS3231 extremely accurate RTC.
About
This module implements a device driver for Maxim DS3231 RTC.
Implementation status
The current implementation does only support reading and setting of time registers as well as reading the temperature register and configuring the aging offset.
Setting alarms and configuring the square wave output is not yet supported.
|
file | ds3231_params.h |
| Default configuration for DS3231 devices.
|
|
file | ds3231.h |
| Interface definition for the Maxim DS3231 RTC.
|
|
|
enum | { DS3231_OPT_BAT_ENABLE = 0x01,
DS2321_OPT_32KHZ_ENABLE = 0x02
} |
| Configuration options.
|
|
◆ ds3231_disable_bat()
int ds3231_disable_bat |
( |
const ds3231_t * |
dev | ) |
|
Disable the backup battery.
- Parameters
-
[in] | dev | DS3231 device descriptor |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_enable_bat()
int ds3231_enable_bat |
( |
const ds3231_t * |
dev | ) |
|
Enable the backup battery.
- Parameters
-
[in] | dev | DS3231 device descriptor |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_get_aging_offset()
int ds3231_get_aging_offset |
( |
const ds3231_t * |
dev, |
|
|
int8_t * |
offset |
|
) |
| |
Get the configured aging offset (see datasheet for more information)
- Parameters
-
[in] | dev | DS3231 device descriptor |
[out] | offset | aging offset |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_get_temp()
int ds3231_get_temp |
( |
const ds3231_t * |
dev, |
|
|
int16_t * |
temp |
|
) |
| |
Get temperature from the device.
- Parameters
-
[in] | dev | DS3231 device descriptor |
[out] | temp | current value of the temperature register [in centi °C] |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_get_time()
int ds3231_get_time |
( |
const ds3231_t * |
dev, |
|
|
struct tm * |
time |
|
) |
| |
Get date and time from the device.
- Parameters
-
[in] | dev | DS3231 device descriptor |
[out] | time | current date and time from on device |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_init()
Initialize the given DS3231 device.
- Parameters
-
[out] | dev | device descriptor of the targeted device |
[in] | params | device configuration |
- Returns
- 0 on success
-
-EIO if no DS3231 device was found
◆ ds3231_set_aging_offset()
int ds3231_set_aging_offset |
( |
const ds3231_t * |
dev, |
|
|
int8_t |
offset |
|
) |
| |
Set the aging offset (see datasheet for more information)
- Parameters
-
[in] | dev | DS3231 device descriptor |
[in] | offset | aging offset |
- Returns
- 0 on success
-
-EIO on I2C communication error
◆ ds3231_set_time()
int ds3231_set_time |
( |
const ds3231_t * |
dev, |
|
|
const struct tm * |
time |
|
) |
| |
Set date and time of the device.
- Parameters
-
[in] | dev | DS3231 device descriptor |
[in] | time | target date and time |
- Returns
- 0 on success
-
-EIO on I2C communication error