samples/boards/stm32/i2c_timing/README.html · samples/boards/stm32/i2c_timing/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Boards · STM32 I2C

STM32 I2C V2 Timings

계산된 TIMING 값을 production Device Tree 설정으로 옮깁니다.

Official pathsamples/boards/stm32/i2c_timing/README.html
Source filesamples/boards/stm32/i2c_timing/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

get_config, CubeMX 대안, Kconfig와 i2c-0 alias 요구 사항을 설명합니다.

Input

Peripheral clock · bitrate

Output

TIMING register

Board

b_u585i_iot02a

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 7FD536878DA29CC8449FD6B5281A67A5F8B39F70C504E7317A6EC7B53FEF7BCF
.. zephyr:code-sample:: stm32_i2c_v2_timings
   :name: STM32 I2C V2 timings
   :relevant-api: i2c_interface

Overview
********
This sample simply demonstrate the **get_config** API of the stm32 I2C driver.
The I2C peripheral configuration is checked regarding the I2C bitrate which can be:

	- <I2C_BITRATE_FAST_STANDARD>
	- <I2C_BITRATE_FAST>
	- <I2C_BITRATE_FAST_PLUS>


In case of the I2C V2, the I2C peripheral of the STM32 microcontrollers have
a TIMING register to write in order to generate the correct I2C clock signal.
This value depends on the peripheral clock input and the I2C speed.
The calculation of that TIMING value can be given by the `STM32CubeMX`_ application
**or** by the present sample.

Because the code sequence to calculate the I2C V2 TIMING value is heavy,
it is not advised to enable it in production binary.
By enabling CONFIG_I2C_STM32_V2_TIMING flag, this sample allows to
retrieve timing register configuration for the defined ``clock-frequency``.
User can then configure timing in his application by adapting the following dts
snippet with the output of this sample:


 .. code-block:: c

    &i2c {
        timings = <160000000 I2C_BITRATE_STANDARD  0xB0C03E40>,
                    <160000000 I2C_BITRATE_FAST  0xC041090F>,
                    <160000000 I2C_BITRATE_FAST_PLUS  0x6021050A>;
    }


Building and Running
********************

In order to run this sample, make sure to

- enable ``i2c`` node in your board DT file.
- enable the CONFIG_I2C_STM32_V2_TIMING=y in the board **conf** file
- alias the **i2c-0** to your ``i2c`` node of the board **overlay** file

 .. zephyr-app-commands::
   :zephyr-app: samples/boards/stm32/i2c_config
   :board: b_u585i_iot02a
   :goals: build
   :compact:

Sample Output
=============
When setting the b_u585i_iot02a.overlay to

 .. code-block:: c

    / {
        aliases {
         i2c-0 = &i2c2;
      };
    };
    &i2c2 {
        /delete-property/ clock-frequency;
        clock-frequency = <I2C_BITRATE_FAST>;
    };

The sample gives the corresponding TIMING value to report to the Device Tree:

.. code-block:: console

    I2C timing value, report to the DTS :
    timings = <160000000 I2C_BITRATE_FAST  0xC041090F>;

    I2C config : I2C_BITRATE_FAST


.. _STM32CubeMX:
   https://www.st.com/en/development-tools/stm32cubemx.html

Part 3

한국어 전문 번역

개요

STM32 I2C driver의 get_config API를 간단히 보여주는 sample입니다. I2C peripheral configuration을 다음 I2C bit rate에 대해 검사합니다.

  • I2C_BITRATE_FAST_STANDARD
  • I2C_BITRATE_FAST
  • I2C_BITRATE_FAST_PLUS

I2C V2의 경우 STM32 microcontroller의 I2C peripheral은 올바른 I2C clock signal을 만들기 위해 TIMING register에 값을 써야 합니다. 이 값은 peripheral clock input과 I2C speed에 따라 달라집니다. TIMING 값은 STM32CubeMX application 또는 이 sample로 계산할 수 있습니다.

I2C V2 TIMING 값을 계산하는 code sequence는 무거우므로 production binary에서 활성화하는 것은 권장하지 않습니다. CONFIG_I2C_STM32_V2_TIMING flag를 활성화하면 이 sample이 정의된 clock-frequency에 대한 timing register configuration을 구합니다. 사용자는 sample 출력으로 다음 DTS snippet을 조정해 자신의 application에 timing을 구성할 수 있습니다.

&i2c {
    timings = <160000000 I2C_BITRATE_STANDARD  0xB0C03E40>,
                <160000000 I2C_BITRATE_FAST  0xC041090F>,
                <160000000 I2C_BITRATE_FAST_PLUS  0x6021050A>;
}

Build와 실행

Sample을 실행하려면 다음 조건을 만족해야 합니다.

  • Board DT file에서 i2c node를 활성화합니다.
  • Board conf file에서 CONFIG_I2C_STM32_V2_TIMING=y를 활성화합니다.
  • Board overlay file에서 i2c-0 alias가 board의 i2c node를 가리키게 합니다.
west build -b b_u585i_iot02a samples/boards/stm32/i2c_config

Sample 출력

b_u585i_iot02a.overlay를 다음과 같이 설정합니다.

/ {
    aliases {
     i2c-0 = &i2c2;
  };
};
&i2c2 {
    /delete-property/ clock-frequency;
    clock-frequency = <I2C_BITRATE_FAST>;
};

Sample은 Device Tree에 기록할 대응 TIMING 값을 다음과 같이 출력합니다.

I2C timing value, report to the DTS :
timings = <160000000 I2C_BITRATE_FAST  0xC041090F>;

I2C config : I2C_BITRATE_FAST

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.