DS1307 RTC¶
Device drive interface for the DS1307 real-time clock.
-
enum
ds1307_sqw_mode_t
¶ - DS1307_SQW_MODE_0
= 0x00
- OUT: 0.
- DS1307_SQW_MODE_1000HZ
= 0x10
- SQW: 1kHz.
- DS1307_SQW_MODE_4096HZ
= 0x11
- SQW: 4.096 kHz.
- DS1307_SQW_MODE_8192HZ
= 0x12
- SQW: 8.192 kHz.
- DS1307_SQW_MODE_32768HZ
= 0x13
- SQW: 32.768 kHz.
- DS1307_SQW_MODE_1
= 0x80
- OUT: 1.
- DS1307_SQW_MODE_0
-
int
ds1307_init
(ds1307_t * dev, const ds1307_params_t * params)¶ Initialize the given DS1307 device.
Parameters
dev: device descriptor of the targeted device params: device configuration (i2c bus, address and bus clock) Return values
- 0 on success
- < 0 if unable to speak to the device
-
int
ds1307_set_time
(const ds1307_t * dev, const struct tm * time)¶ Set RTC to a given time.
Parameters
dev: device descriptor of the targeted device time: pointer to the struct holding the time to set. Return values
- 0 on success
- < 0 if unable to speak to the device
-
int
ds1307_get_time
(const ds1307_t * dev, struct tm * time)¶ Get current RTC time.
Parameters
dev: device descriptor of the targeted device time: pointer to the struct to write the time to. Return values
- 0 on success
- < 0 if unable to speak to the device
-
int
ds1307_halt
(const ds1307_t * dev)¶ Halt clock.
Note
Can be reversed using
ds1307.h::ds1307_set_time()
Parameters
dev: device descriptor of the targeted device Return values
- 0 on success
- < 0 if unable to speak to the device
-
int
ds1307_set_sqw_mode
(const ds1307_t * dev,ds1307.h::ds1307_sqw_mode_t
mode)¶ Set mode of square wave / output driver.
Note
To get the actual output of the driver, attach the pin via GPIO
Parameters
dev: device descriptor of the targeted device mode: mode for the square wave / output driver Return values
- 0 on success
- < 0 if unable to speak to the device
-
int
ds1307_get_sqw_mode
(const ds1307_t * dev)¶ Get current mode of square wave / output driver.
Note
To get the actual output of the driver, attach the pin via GPIO
Parameters
dev: device descriptor of the targeted device Return values
- current mode of the square wave / output driver (see ds1307_sqw_mode_t)
- < 0 if unable to speak to the device
-
DS1307_I2C_ADDRESS
¶ I2C address of DS1307 RTC.
1
(0x68)
-
DS1307_I2C_MAX_CLK
¶ Maximum I2C bus speed to use with the device.
1
(I2C_SPEED_FAST)
-
DS1307_NVRAM_MAX_SIZE
¶ Maximum size in byte of on-chip NVRAM.
1
(56U)
-
struct
ds1307_t
¶ Device descriptor for DS1307 devices.
-
i2c.h::i2c_t
i2c
¶ I2C bus the device is connected to.
-
nvram.h::nvram_t
nvram
¶ on-chip NVRAM (see nvram.h)
-
-
struct
ds1307_params_t
¶ Set of configuration parameters for DS1307 devices.
-
i2c.h::i2c_t
i2c
¶ I2C bus the device is connected to.
-