This page has moved to

Click here if you are not redirected.

I2C 总线概述

I2C 是一种分组交换串行通信协议,允许多个主设备连接到多个从属设备,每个连接只需使用2根电线。 它用于在短距离、板内通信中将低速外设 IC 连接到处理器和微控制器。

Pixhawk/PX4 支持:

  • 连接需要比严格的串行 UART 更高数据速率的板载组件:例如测距仪。
  • 与仅支持 I2C 的外围设备兼容。
  • 允许多个设备连接到单个总线(有效保护端口)。 例如,LED、指南针、测距仪等。

IMU(加速度计/陀螺仪)不应通过 I2C 连接(通常使用 SPI 总线)。 即使连一个设备可以进行振动过滤(实例),总线的速度也不够快,并且总线上的每一个额外设备都会进一步降低性能。

集成 I2C 设备

Drivers should #include <drivers/device/i2c.h> and then provide an implementation of the abstract base class I2C defined in I2C.hpp for the target hardware (i.e. for NuttX here).

Drivers will also need to include headers for their type of device (drv_*.h) in /src/drivers/ - e.g. drv_baro.h.

To include a driver in firmware you must add the driver to the board-specific cmake file that corresponds to the target you want to build for:


For example, you can see/search for this driver in the px4_fmu-v4_default configuration.

I2C 驱动程序示例

To find I2C driver examples, search for i2c.h in /src/drivers/.



results matching ""

    No results matching ""