Interested?

* Indicates a required field

- from

GT-CP Communication on Linux

Introduction

This describes USB communication methods for the GT-CP modules using Linux:

USB Information

GT800X480A-C903PA/GT480X272A-C903PA

  • Vendor ID: 0x0EDA
  • Product ID: 0x1200
  • EP IN Address: 0x81
  • EP OUT Address: 0x02
  • Device and Interface Class: 0xFF (vendor-specific)
Endpoint Type Maximum Packet Size
Endpoint 0 Control 64 bytes
Endpoint 1 Bulk IN Full speed: 64 bytes, High speed: 512 bytes
Endpoint 2 Bulk OUT Full speed: 64 bytes, High speed: 512 bytes

This device has a single configuration with a single interface and two endpoints for data transfer.

libusb.h – USB Communication Library

For USB communication, we have used libusb.h. This is an open source library that lets users communicate with generic USB devices from user-space.

Website: https://libusb.info/

Installation: sudo apt-get install libusb-1.0-0-dev

This library can be used to open the GT-CP device and perform bulk transfers to send display commands and read responses back from the module.

The following functions are used to establish a test connection with a GT-CP module:

  1. libusb_init(NULL);
    1. This function initializes libusb with the default context.
  2. libusb_open_device_with_vid_pid(NULL, 0x0EDA, 0x1200);
    1. This function opens a device with a specific vendor and product ID. This example will establish a connection with a GT-CP module with the default context.
    2. This function returns the libusb_device_handle, which, for this example, we will call devh.
  3. libusb_claim_interface(devh, 0);
    1. This function claims the desired interface to communicate with. When communicating with the GT-CP module, we need to claim interface 0.

The libusb_bulk_transfer() function is used to write and read data to and from the GT-CP module using libusb.h:

  1. To write a byte of data, use the module’s EP OUT address (0x02).
    1. libusb_bulk_transfer(devh, 0x02, data_byte, 1, &actual_length, timeout);
      1. timeout = 0
  2. To read a byte of data, use the module’s EP IN address (0x81).
    1. libusb_bulk_transfer(devh, 0x81, read_data_array, number_bytes_to_read, &actual_length, timeout);
      1. timeout = 1000

The following functions are used to close and release a fully established USB connection to a GT-CP module using libusb.h:

  1. libusb_release_interface(devh, 0);
    1. This function releases the interface that was previously claimed.
  2. libusb_close(devh);
    1. This function closes the specified device handle.
  3. libusb_exit(NULL);
    1. This function will deinitialize libusb.

Example Program Using libusb.h

The example program (GTCP_test.c) sends an initialize command and a simple “Hello World!” to a GT-CP display. This program utilizes “GUTFT_USB_LIB.c” (as a libusb wrapper) and “GUTFT.c” (as a display command library). The command functions found in “GUTFT.c” directly relate to the commands found in the GT-CP software specification (s-gt-c9xxpa-soft_e04.pdf).

Run “make” before executing the program with “sudo ./GTCP_test”.

“Hello World!” should appear on the connected display:

NOTE: GT-CP = GUTFT. GUTFT was the name of the first version of the GT-CP module family.

Generic USB Driver

When connected to a Linux PC, a GT-CP module does not automatically get assigned to a USB driver.

To attach a generic USB driver to the GT-CP module, use: modprobe usbserial vendor=0x0EDA product=0x1200

Once a generic USB driver is attached, the GT-CP module is not associated with a device path like /dev/ttyUSB0. You can check your exact device path with the dmesg terminal command after plugging the module into your Linux PC. Look for the “generic converter now attached to ttyUSBX” message.

 

 

 

 

 

NOTE: A generic USB driver is intended for evaluation purposes only.

 

Example Program Using Generic USB Driver

The example program (GTCP_genericUSB.c) sends an initialize command and then falls into an infinite touch read loop that indicates touch on the module with a white box. This program opens in “/dev/ttyUSBX” and reads/writes data to/from the device path.

The device path may need to be changed in “GTCP_genericUSB.c” to match the path established with your GT-CP module.

#define GTCP_MODULE “/dev/ttyUSBX”

Run “make” before executing the program with:

  • “sudo ./GTCP_genericUSB GT800X480A-C903PA” when using a GT800X480A-C903PA
  • “sudo ./GTCP_genericUSB GT480X272A-C903PA” when using a GT480X272A-C903PA

The touch demo should start on your connected display. Touch the screen to “draw” on the display.