# 并行 IO

[English]

## 简介

[并行 IO 外设] 是一个通用的并行接口，可用于连接外部设备，如 LED 矩阵、LCD 显示器、打印机和摄像头。该外设具有独立的 TX 和 RX 单元。每个单元最多可以具有 8 或 16 个数据信号以及 1 或 2 个时钟信号。

并行 IO 外设的 TX 和 RX 驱动程序有各自独立的设计，可分别通过包含头文件 `driver/parlio_tx.h` 或 `driver/parlio_rx.h` 来使用。

- 并行 IO TX 驱动程序
- 并行 IO RX 驱动程序

## API 参考

### Header File

- components/esp_driver_parlio/include/driver/parlio_types.h

- This header file can be included with:

  >     #include "driver/parlio_types.h"

- This header file is a part of the API provided by the `esp_driver_parlio` component. To declare that your component depends on `esp_driver_parlio`, add the following to your CMakeLists.txt:

  >     REQUIRES esp_driver_parlio

  > or

  >     PRIV_REQUIRES esp_driver_parlio

### Structures

struct parlio_tx_done_event_data_t

  Type of Parallel IO TX done event data.

struct parlio_tx_buffer_switched_event_data_t

  Type of Parallel IO TX buffer switched event data.

  Public Members

  void *old_buffer_addr

    Address of the previous buffer used before switching

  void *new_buffer_addr

    Address of the new buffer switched to

### Type Definitions

typedef struct parlio_tx_unit_t *parlio_tx_unit_handle_t

  Type of Parallel IO TX unit handle.

typedef struct parlio_rx_unit_t *parlio_rx_unit_handle_t

  Type of Parallel IO RX unit handle.

typedef struct parlio_rx_delimiter_t *parlio_rx_delimiter_handle_t

  Type of Parallel IO RX frame delimiter handle.

typedef bool (*parlio_tx_done_callback_t)(parlio_tx_unit_handle_t tx_unit, const parlio_tx_done_event_data_t *edata, void *user_ctx)

  Prototype of parlio tx event callback.

  Param tx_unit:

    [in] Parallel IO TX unit that created by `parlio_new_tx_unit`

  Param edata:

    [in] Point to Parallel IO TX event data. The lifecycle of this pointer memory is inside this function, user should copy it into static memory if used outside this function.

  Param user_ctx:

    [in] User registered context, passed from `parlio_tx_unit_register_event_callbacks`

  Return:

    Whether a high priority task has been waken up by this callback function

typedef bool (*parlio_tx_buffer_switched_callback_t)(parlio_tx_unit_handle_t tx_unit, const parlio_tx_buffer_switched_event_data_t *edata, void *user_ctx)

  Prototype of parlio tx buffer switched event callback.

  Param tx_unit:

    [in] Parallel IO TX unit that created by `parlio_new_tx_unit`

  Param edata:

    [in] Point to Parallel IO TX event data. The lifecycle of this pointer memory is inside this function, user should copy it into static memory if used outside this function.

  Param user_ctx:

    [in] User registered context, passed from `parlio_tx_unit_register_event_callbacks`

  Return:

    Whether a high priority task has been waken up by this callback function

### Header File

- components/esp_hal_parlio/include/hal/parlio_types.h

- This header file can be included with:

  >     #include "hal/parlio_types.h"

- This header file is a part of the API provided by the `esp_hal_parlio` component. To declare that your component depends on `esp_hal_parlio`, add the following to your CMakeLists.txt:

  >     REQUIRES esp_hal_parlio

  > or

  >     PRIV_REQUIRES esp_hal_parlio

### Macros

PARLIO_TX_UNIT_MAX_DATA_WIDTH

  Maximum data width of TX unit.

PARLIO_RX_UNIT_MAX_DATA_WIDTH

  Maximum data width of RX unit.

### Type Definitions

typedef soc_periph_parlio_clk_src_t parlio_clock_source_t

  Parallel IO clock source.

  备注

  User should select the clock source based on the power and resolution requirement

### Enumerations

enum parlio_sample_edge_t

  Parallel IO Rx sample edge.

  Values:

  enumerator PARLIO_SAMPLE_EDGE_NEG

    Sample data on falling edge of clock

  enumerator PARLIO_SAMPLE_EDGE_POS

    Sample data on rising edge of clock

enum parlio_shift_edge_t

  Parallel IO Tx shift edge.

  Values:

  enumerator PARLIO_SHIFT_EDGE_POS

    Shift data on rising edge of clock

  enumerator PARLIO_SHIFT_EDGE_NEG

    Shift data on falling edge of clock

enum parlio_bit_pack_order_t

  Parallel IO bit packing order.

  Data in memory: Byte 0: MSB < B0.7 B0.6 B0.5 B0.4 B0.3 B0.2 B0.1 B0.0 > LSB Byte 1: MSB < B1.7 B1.6 B1.5 B1.4 B1.3 B1.2 B1.1 B1.0 > LSB

  Output on line (PARLIO_BIT_PACK_ORDER_LSB): Cycle 0 Cycle 1 Cycle 2 —> time GPIO 0: B0.0 B0.4 B1.0 GPIO 1: B0.1 B0.5 B1.1 GPIO 2: B0.2 B0.6 B1.2 GPIO 3: B0.3 B0.7 B1.3

  Output on line (PARLIO_BIT_PACK_ORDER_MSB): Cycle 0 Cycle 1 Cycle 2 —> time GPIO 0: B0.4 B0.0 B1.4 GPIO 1: B0.5 B0.1 B1.5 GPIO 2: B0.6 B0.2 B1.6 GPIO 3: B0.7 B0.3 B1.7

  Values:

  enumerator PARLIO_BIT_PACK_ORDER_LSB

    Bit pack order: LSB

  enumerator PARLIO_BIT_PACK_ORDER_MSB

    Bit pack order: MSB

此文档对您有帮助吗？

- 反馈已收到，谢谢！
- 如果您有其他意见，欢迎填写乐鑫文档反馈表。

- 我们重视您的反馈。
- 您可以填写乐鑫文档反馈表告诉我们如何改进该文档。