From a4fa48945059d5bb211b95039da2d3967769f0f7 Mon Sep 17 00:00:00 2001 From: "joey.zhou" <2775152163@qq.com> Date: Sat, 15 Mar 2025 16:54:39 +0800 Subject: [PATCH] uart_wiki --- en/peripherals/machine.UART.md | 489 ++++++++++++++++++++++++++++++--- zh/peripherals/machine.UART.md | 59 +++- 2 files changed, 503 insertions(+), 45 deletions(-) diff --git a/en/peripherals/machine.UART.md b/en/peripherals/machine.UART.md index eedc665..48631c4 100644 --- a/en/peripherals/machine.UART.md +++ b/en/peripherals/machine.UART.md @@ -1400,50 +1400,43 @@ This class transmits data through the UART.
-

1.To use UART4 in BG95 series, you need to call modem.main_uart_enable_set(1) to enable UART4, and restart it as follows.

+

To use UART4 in BG95 series, you need to call modem.main_uart_enable_set(1) to enable UART4, and restart it as follows

-
-
-

1. When flowctl = 1, uart1 of EC600M only maps uart1 to different pins, and the flow control function is not turned on.

+

When flowctl = 1, uart1 of EC600M only maps uart1 to different pins and does not turn on the flow control function.

-
-

1, when flowctl = 1, uart1 of EC800M only maps uart1 to different pins, and the flow control function is not turned on.

+

When flowctl = 1, uart1 of EC800M only maps uart1 to different pins, and the flow control function is not turned on.

-

1. When flowctl = 1, uart1 of EG810M only maps uart1 to different pins, and the flow control function is not turned on.

+

When flowctl = 1, uart1 of EG810M only maps uart1 to different pins and does not turn on the flow control function.

-

1. When flowctl = 1, uart1 of EG912N only maps uart1 to different pins, and the flow control function is not turned on.

+

When flowctl = 1, uart1 of EG912N only maps uart1 to different pins and does not turn on the flow control function.

-

1, when flowctl = 1, uart1 of EC600K only maps uart1 to different pins, and the flow control function is not turned on.

+

When flowctl = 1, uart1 of EC600K only maps uart1 to different pins and does not turn on the flow control function.

-

1, when flowctl = 1, uart1 of EC800K only maps uart1 to different pins, and the flow control function is not turned on.

-
+

The uart1 of EC800K only maps uart1 to different pins when flowctl = 1, and the flow control function is not turned on.

-
-
-

1. The interaction port of FCM360W UART2 will not be used after it is initialized. You need to execute uart2.close() in the code or restart the module to continue to use the interaction port.

-
+
+

After the FCM360W UART2 is initialized, the interaction port will not be used. You need to execute uart2.close() in the code or restart the module to continue to use the interaction port.

-
-
-

1, FCM362K UART1 is initialized after the interaction port will not be able to use, you need to execute uart1.close() in the code or restart the module to continue to use the interaction port.

+
+

FCM362K UART1 is initialized after the interaction port will not be used, you need to execute uart1.close() in the code or restart the module to continue to use the interaction port.

@@ -1522,37 +1515,459 @@ This method disables the UART. `-1` - Failed execution +
+
### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-```python -uart.control_485(UART.GPIOn, direction) -``` +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-This method controls the direction of RS-485 communication. Before and after sending data through the UART, the specified GPIO is pulled up and down to indicate the direction of RS-485 communication. +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-**Parameter:** +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-- `GPIOn` - Integer type. GPIO numbers to be controlled. See [class Pin - Control I/O Pins](machine.Pin.md) for pin definitions. +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-- `direction` - Integer type. Pin level change.
`1` - The pin is pulled high before the data is sent through the UART, and pulled low after the data is sent.
+
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
- `0` - The pin is pulled low before the data is sent through the UART, and pulled high after the data is sent. +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-**Return Value:** +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-`0` - Successful execution -`-1` - Failed execution +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-> Note: BC25 series/BG95-M3 series module does not support this method. +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-**Example:** +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
-```python ->>> from machine import UART ->>> uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0) ->>> uart1.control_485(UART.GPIO24, 1) -``` +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +
+ +
+### `uart.control_485` +
uart.control_485(UART.GPIOn, direction)
+
+

This method is used to control the 485 communication direction, and the specified GPIO is pulled up and down before and after the serial port sends data to indicate the 485 communication direction.

+

Parametric Description

+
    +
  • GPIOn - GPIO Pin number to control, refer to pin definition in [Pin module](machine.Pin.md), int type.

    +
  • +
  • direction - Pin level change, int type, described as follows:
    1It indicates that the pin level change is: the serial port is pulled up by low before sending data, and then pulled down by high after sending data
    0It indicates that the pin level change is: the serial port is pulled down by high before sending data, and then pulled up by low after sending data

    +
  • +
+

Return value Description:

+

Returns an integer value on success0,Returns an integer value on failure-1

+

Example:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
uart1.control_485(UART.GPIO24, 1) +

Example:

+
+
### `uart.set_callback` diff --git a/zh/peripherals/machine.UART.md b/zh/peripherals/machine.UART.md index 575e23e..ab591df 100644 --- a/zh/peripherals/machine.UART.md +++ b/zh/peripherals/machine.UART.md @@ -1527,6 +1527,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1543,6 +1545,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1559,6 +1563,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1575,6 +1581,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1591,6 +1599,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1607,6 +1617,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1623,6 +1635,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1639,6 +1653,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1655,6 +1671,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1672,6 +1690,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1688,6 +1708,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1704,6 +1726,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1720,6 +1744,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1736,6 +1762,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1752,6 +1780,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1768,6 +1798,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1784,6 +1816,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1800,6 +1834,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1816,6 +1852,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1832,6 +1870,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1848,6 +1888,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1864,6 +1906,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1880,6 +1924,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1896,6 +1942,8 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1)
@@ -1912,17 +1960,12 @@ uart.close()

返回值描述:

成功返回整型值0,失败返回整型值-1

+

示例:

+
from machine import UART
uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0)
art1.control_485(UART.GPIO24, 1) +
-**示例:** - -```python ->>> from machine import UART ->>> uart1 = UART(UART.UART1, 115200, 8, 0, 1, 0) ->>> uart1.control_485(UART.GPIO24, 1) -``` - ### `uart.set_callback` ```python -- Gitee