> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man4/ds1307.4.md).

# ds1307.4

`ds1307` — 64 x 8 串行 I2C 实时时钟（RTC）

## 名称

`ds1307`

## 概要

`device iic device iicbus device ds1307`

## 描述

`ds1307` 串行实时时钟（RTC）是一种低功耗、全二进制编码十进制（BCD）时钟/日历，外加 56 字节的 NV SRAM。

`ds1307` 具有内置电源检测电路，可检测电源故障并自动切换到备用电源。当器件由备用电源供电时，计时操作继续进行。

通过 [sysctl(8)](/man/man8/sysctl.8.md) 接口访问 `ds1307` 设置：

```sh
dev.ds1307.0.%desc: Maxim DS1307 RTC
dev.ds1307.0.%driver: ds1307
dev.ds1307.0.%location: addr=0xd0
dev.ds1307.0.%pnpinfo: name=rtc compat=maxim,ds1307
dev.ds1307.0.%parent: iicbus1
dev.ds1307.0.sqwe: 1
dev.ds1307.0.sqw_freq: 32768
dev.ds1307.0.sqw_out: 0
```

**`dev.ds1307.%d.sqwe`** 若设为 1，SQW 引脚输出频率为 `dev.ds1307.%d.sqw_freq` 的方波。若设为 0，SQW 引脚的输出电平由 `dev.ds1307.%d.sqw_out` 控制。

**`dev.ds1307.%d.sqw_freq`** 在 `dev.ds1307.%d.sqwe` 上启用方波输出时选择 SQW 引脚的频率。可设为 1、4096、8192 和 32768。

**`dev.ds1307.%d.sqw_out`** 当 `dev.ds1307.%d.sqwe` 设为 0 时设置 SQW 引脚的输出电平。

更多详情请查阅 `ds1307` 数据手册。

在基于 [device.hints(5)](/man/man5/device.hints.5.md) 的系统（如 `MIPS`）上，这些值可为 `ds1307` 配置：

**`hint.ds1307.%d.at`** `ds1307` 所连接的 [iicbus(4)](/man/man4/iicbus.4.md)。

**`hint.ds1307.%d.addr`** `ds1307` 的 i2c 地址。

在基于 FDT(4) 的系统上，必须设置以下属性：

**`compatible`** 必须始终设为"dallas,ds1307"或"maxim,ds1307"。

**`reg`** `ds1307` 的 i2c 地址。`ds1307` 的默认地址为 0xd0。

## 参见

[fdt(4)](/man/man4/fdt.4.md), [iic(4)](/man/man4/iic.4.md), [iicbus(4)](/man/man4/iicbus.4.md), [sysctl(8)](/man/man8/sysctl.8.md)

## 历史

`ds1307` 驱动首次出现于 FreeBSD 11.0。

## 作者

`ds1307` 驱动及本手册页由 Luiz Otavio O Souza <loos@FreeBSD.org> 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man4/ds1307.4.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
