> 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/ads111x.4.md).

# ads111x.4

`ads111x` — ADS101x 和 ADS111x I2C 模数转换器驱动

## 名称

`ads111x`

## 概要

`要将此驱动编译进内核，请在你的内核配置文件中加入以下行：`

> device ads111x

`或者，要在引导时以模块形式加载此驱动，请在 loader.conf(5) 中加入以下行：`

```sh
ads111x_load="YES"
```

## 描述

`ads111x` 驱动为 ADS101x/ADS111x 系列模数转换器（ADC）设备提供支持。受支持的设备彼此类似，区别在于分辨率和输入通道数等特性。设备提供多种配置选项，可通过 hints、FDT 数据和 [sysctl(8)](/man/man8/sysctl.8.md) 进行设置。

[sysctl(8)](/man/man8/sysctl.8.md) 实用程序可访问设备测量的电压。每次访问给定通道的 `dev.ads111x.<unit>.<channel>.voltage` 变量时，驱动会切换芯片内部的 mux 以选择该通道对应的输入引脚，指示其进行单次测量，并返回以微伏为单位的测量值。进行测量所需的时间取决于为设备配置的采样速率。虽然设备被指示进行单次测量，但它仍会在与连续模式下输出一个样本相同的时间内对输入值进行平均。例如，如果采样速率配置为每秒 125 个样本，则单次测量需要 8 毫秒。

对于支持多个输入引脚的设备，设备数据手册描述了 mux 设置，用于控制在单端或差分测量时如何解释这些引脚。四个引脚的输入有八种可能的组合方式。`ads111x` 驱动通过为八种组合中的每一种创建单独的输出通道来建模。要在给定引脚或一对引脚上进行测量，只需访问与数据手册中所示 mux 设置编号（0 至 7）对应的通道号的 voltage 变量。当通过 hints 或 FDT 数据配置驱动时，它仅为配置数据中指定的通道创建 sysctl 变量。当没有通道配置数据时，它创建所有八个可能的通道，以便你可以访问所需的任意通道。

对于包含 `alert` 输出引脚的设备，`ads111x` 驱动不直接支持感知引脚状态变化或对其采取行动。但是，你可以将引脚连接到 gpio 输入、风扇控制器或其他外部设备，并使用驱动的 sysctl 变量配置引脚的行为和阈值。驱动在对配置寄存器进行其他操作时不会干扰你的设置。

## SYSCTL 变量

sysctl 变量用于访问电压测量值和更改通道配置。所有可写变量也可作为 [loader(8)](/man/man8/loader.8.md) 可调参数设置。这些 sysctl 变量中的通道号范围为 0 至 7。

**`dev.ads111x.<unit>.config`** 提供对控制 alert 引脚配置的配置寄存器位的访问。由驱动控制的其他位会被屏蔽，无法通过此变量查看或更改。

**`dev.ads111x.<unit>.lo_thresh`** 设置激活 alert 引脚的低阈值。

**`dev.ads111x.<unit>.hi_thresh`** 设置激活 alert 引脚的高阈值。

**`dev.ads111x.<unit>.<channel>.rate_index`** 设置通道的采样速率。设备数据手册记录了八种可用采样速率，通过在相应控制寄存器位中设置 0 至 7 的值来选择。此变量设置在给定通道进行测量时用于这些位的值。由于测量始终在单次模式下进行，因此可将此变量视为控制单个样本的平均时间；测量时间为 1 / 采样速率。

**`dev.ads111x.<unit>.<channel>.gain_index`** 在具有内部放大器的设备上设置通道的可编程增益放大器。设备数据手册记录了八种可用增益值，通过在相应控制寄存器位中设置 0 至 7 的值来选择。此变量设置在给定通道进行测量时用于这些位的值。

**`dev.ads111x.<unit>.<channel>.voltage`** 读取此变量会促使设备在相应输入引脚上进行测量，并返回以微伏为单位的电压。注意，列出多个 sysctl 变量时不会显示此变量——你必须通过名称专门访问它，因为访问它会触发设备 I/O。

## 硬件

`ads111x` 驱动支持以下设备：

| ADS1013 | ADS1113 |
| ------- | ------- |
| ADS1014 | ADS1114 |
| ADS1015 | ADS1115 |

## FDT 配置

在基于 [fdt(4)](/man/man4/fdt.4.md) 的系统上，`ads111x` 设备定义为 i2c 总线控制器节点的从设备子节点。`ads1015.txt` 绑定文档中记录的所有属性都可用于 `ads111x` 设备。

`ads111x` 设备子节点中需要以下属性：

| “ti,ads1013” | “ti,ads1113” |
| ------------ | ------------ |
| “ti,ads1014” | “ti,ads1114” |
| “ti,ads1015” | “ti,ads1115” |

**`compatible`** 以下之一：

**`reg`** 设备的 I2C 从地址。

可以通过向 `ads111x` 节点添加子节点来配置特定通道，如标准 ads1015.txt 绑定文档所述。如果未配置任何通道，将为设备类型支持的所有可能通道创建 sysctl 变量，否则仅创建指定的通道。

### 包含通道配置的示例

```sh
adc@48 {
    compatible = "ti,ads1115";
    reg = <0x48>;
    status = "okay";
    #address-cells = <1>;
    #size-cells = <0>;
    channel@6 {
        reg = <6>;
        ti,gain = <3>;
        ti,datarate = <4>;
    };
    channel@7 {
        reg = <7>;
        ti,gain = <1>;
        ti,datarate = <7>;
    };
};
```

## HINTS 配置

在基于 [device.hints(5)](/man/man5/device.hints.5.md) 的系统上（例如 `MIPS`），以下值可用于配置 `ads111x`：

**`hint.ads111x.<unit>.at`** `ads111x` 实例所附加的 iicbus 实例。

**`hint.ads111x.<unit>.<channel>.gain_index`** 放大器增益，如上文的 sysctl 变量 `dev.ads111x.<unit>.<channel>.gain_index` 所述。

**`hint.ads111x.<unit>.<channel>.rate_index`** 采样速率，如上文的 sysctl 变量 `dev.ads111x.<unit>.<channel>.rate_index` 所述。

如果未配置任何通道，将为设备类型支持的所有可能通道创建 sysctl 变量，否则仅创建指定的通道。

## 参见

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

## 历史

`ads111x` 驱动最早出现在 FreeBSD 13.0 中。


---

# 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/ads111x.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.
