PX4-Autopilot/docs/zh/sensor_bus/i2c_development.md
Hamish Willee 88d623bedb
Move PX4 Guide source into /docs (#24490)
* Add vitepress tree

* Update existing workflows so they dont trigger on changes in the docs path

* Add nojekyll, package.json, LICENCE etc

* Add crowdin docs upload/download scripts

* Add docs flaw checker workflows

* Used docs prefix for docs workflows

* Crowdin obvious fixes

* ci: docs move to self hosted runner

runs on a beefy server for faster builds

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* ci: don't run build action for docs or ci changes

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* ci: update runners

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* Add docs/en

* Add docs assets and scripts

* Fix up editlinks to point to PX4 sources

* Download just the translations that are supported

* Add translation sources for zh, uk, ko

* Update latest tranlsation and uorb graphs

* update vitepress to latest

---------

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Co-authored-by: Ramon Roche <mrpollo@gmail.com>
2025-03-13 16:08:27 +11:00

3.2 KiB
Raw Blame History

I2C Bus (Development Overview)

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

Pixhawk/PX4 支持:

  • Connecting off board components that require higher data rates than provided by a strict serial UART, such as rangefinders.
  • 与仅支持 I2C 的外围设备兼容。
  • 允许多个设备连接到单个总线(有效保护端口)。 例如LED、指南针、测距仪等。

:::info The page Hardware > I2C Peripherals contains information about how to use (rather than integrate) I2C peripherals and solve common setup problems. :::

:::tip IMUs (accelerometers/gyroscopes) should not be attached via I2C (typically the SPI bus is used). The bus is not fast enough even with a single device attached to allow vibration filtering (for instance), and the performance degrades further with every additional device on the bus. :::

集成 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).

A small number of drivers will also need to include headers for their type of device (drv_*.h) in /src/drivers/ - e.g. drv_led.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. You can do this for a single driver:

drivers/sf1xx

You can also include all drivers of a particular type.

CONFIG_COMMON_DISTANCE_SENSOR=y

:::tip For example, you can see/search for CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_LASER_I2C in the px4_fmu-v4_default configuration. :::

I2C 驱动程序示例

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

Just a few examples are:

更多信息