Application Development

Last Updated on : 2024-07-26 03:46:10download

This topic describes how to develop applications with the THP23-X-D development board.

DTS

The device tree configuration for the THP23-X-D development board consists of four files:

  • ssd20x-mhub-4g.dts
  • ssd20x-mhub-4g.dtsi
  • ssd20x-mhub-4g-display.dtsi
  • ssd20x-mhub-4g-padmux-display.dtsi

You can adjust them based on product requirements.

LED

The THP23-X-D development board comes with three programmable LEDs, including two monochrome lights and one RGB light.

The table below shows the mappings between GPIO NUM and PAD for LEDs.

Label GPIO NUM PAD_NAME
NETWORK-LED 23 PAD_TTL4
STATUS-LED 24 PAD_TTL5
LED_G 4 PWM0
LED_B 5 PWM1
LED_R 2 PAD_GPIO2

The monochrome light pins are set to GPIO mode, while the RGB light pins are set to PWM mode.

See the source code tuya_hw_hal_led.c and tuya_hw_hal_led_rgb.c for the LED application code.

Button

The THP23-X-D development board has four buttons: three are programmable, and one is for hardware reset.

The table below shows the mappings between GPIO NUM and PAD for buttons.

Label GPIO NUM PAD_NAME
TAMPER 3 PAD_GPIO3
RESTORE 12 PAD_GPIO12
USER 73 PAD_SAR_GPIO2

The key codes mapped in the device tree:

Label Code
TAMPER 40
RESTORE 1
USER 38

The application code for the button can be found in tuya_hw_hal_key.c.

UART

The THP23-X-D development board has four serial ports.

  • Debugging (/dev/ttyS0)

  • Connect to a Zigbee module (/dev/ttyWCH0)

  • Connect to a Bluetooth module (/dev/ttyS2)

  • Reserved (/dev/ttyS3)

The debugging serial port is solely for debugging and cannot be used for any other purpose. The other three serial ports are available for use as needed.

/dev/ttyWCH0 to /dev/ttyWCH3 are extended from an SPI to a 4-UART chip (CH9434), with only one currently used for the Zigbee module connection.

The table below shows the mappings between GPIO NUM and PAD for /dev/ttyS2.

Label GPIO NUM PAD_NAME
RX 15 PAD_FUART_RX
TX 16 PAD_FUART_TX
CTS 17 PAD_FUART_CTS
RTS 18 PAD_FUART_RTS

The table below shows the mappings between GPIO NUM and PAD for /dev/ttyS3.

Label GPIO NUM PAD_NAME
RX 85 PAD_HSYNC_OUT
TX 86 PAD_VSYNC_OUT