Loading...
Searching...
No Matches
ds1307.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include <stdbool.h>
21#include <time.h>
22
23#include "nvram.h"
24#include "periph/i2c.h"
25#include "periph/gpio.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34#define DS1307_I2C_ADDRESS (0x68)
35
41
45#ifndef DS1307_I2C_MAX_CLK
46#define DS1307_I2C_MAX_CLK (I2C_SPEED_FAST)
47#endif
49
53#define DS1307_NVRAM_MAX_SIZE (56U)
54
58typedef struct {
61} ds1307_t;
62
66typedef struct {
69
81
91int ds1307_init(ds1307_t *dev, const ds1307_params_t *params);
92
102int ds1307_set_time(const ds1307_t *dev, const struct tm *time);
103
113int ds1307_get_time(const ds1307_t *dev, struct tm *time);
114
125int ds1307_halt(const ds1307_t *dev);
126
139
152
153#ifdef __cplusplus
154}
155#endif
156
Low-level GPIO peripheral driver interface definitions.
int ds1307_set_sqw_mode(const ds1307_t *dev, ds1307_sqw_mode_t mode)
Set mode of square wave / output driver.
int ds1307_halt(const ds1307_t *dev)
Halt clock.
int ds1307_get_time(const ds1307_t *dev, struct tm *time)
Get current RTC time.
int ds1307_init(ds1307_t *dev, const ds1307_params_t *params)
Initialize the given DS1307 device.
int ds1307_set_time(const ds1307_t *dev, const struct tm *time)
Set RTC to a given time.
ds1307_sqw_mode_t
Modes for the DS1307 square wave / output driver.
Definition ds1307.h:73
int ds1307_get_sqw_mode(const ds1307_t *dev)
Get current mode of square wave / output driver.
@ DS1307_SQW_MODE_32768HZ
SQW: 32.768 kHz.
Definition ds1307.h:78
@ DS1307_SQW_MODE_0
OUT: 0.
Definition ds1307.h:74
@ DS1307_SQW_MODE_1
OUT: 1.
Definition ds1307.h:79
@ DS1307_SQW_MODE_8192HZ
SQW: 8.192 kHz.
Definition ds1307.h:77
@ DS1307_SQW_MODE_1000HZ
SQW: 1kHz.
Definition ds1307.h:75
@ DS1307_SQW_MODE_4096HZ
SQW: 4.096 kHz.
Definition ds1307.h:76
struct nvram nvram_t
Device descriptor for generic NVRAM devices.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Generic non-volatile RAM driver interface.
Set of configuration parameters for DS1307 devices.
Definition ds1307.h:66
i2c_t i2c
I2C bus the device is connected to.
Definition ds1307.h:67
Device descriptor for DS1307 devices.
Definition ds1307.h:58
i2c_t i2c
I2C bus the device is connected to.
Definition ds1307.h:59
nvram_t nvram
on-chip NVRAM (see nvram.h)
Definition ds1307.h:60