Menu

Tree [49bf10] master /
 History

HTTPS access


File Date Author Commit
 demo 2017-06-23 paco andres paco andres [49bf10] Initial commit
 lib 2017-06-23 paco andres paco andres [49bf10] Initial commit
 README.md 2017-06-23 paco andres paco andres [49bf10] Initial commit

Read Me

About

This is a simple but working library for use the D0-D7 pins of the CH341 chip as a GPIO in Linux.

This library is based on the module contained in CH341PAR_LINUX.ZIP published by WCH:

http://www.wch.cn/download/CH341PAR_LINUX_ZIP.html

Todo

Just enter in the lib directory and type make in a console to get the library.

For linking a project with the library you also need to link libusb-1.0, as in demo/Makefile

If you want to use the library as a non root user copy the file lib/99-ch341-gpio.rules to the /etc/udev/rules.d/ directory.

The library has been tested with a YSUMA01-341A module, and I think it must work with any EPP/I2C/SPI module based on the CH341 chip (and maybe any CH34X)

The library has a limitation: you cannot use D6 and D7 pins for output. By now i haven't find the way to do this.

Usage

The API is very simple.

Initiate the device and get the pointer:

c3g_device_handle *dev;
dev = c3g_open_device ();
if (!dev){
  //Manage the error
}

And use the pointer for calling the functions to manage the pins, e.g.:

int res = c3g_read_pin (dev, 1); //Reads the state of D1
if (res < 0){
  //Manage the error
}
res = c3g_write_out (dev, 0b00101101); //sets D0, D2, D3, D5
if (res){
  //Manage the error
}

To see the list of functions take a look at the library header file.

I think you shouldn't have any problem, but you can contact me through the ticket system.

And if you know how to use D6 and D7 for output, please notice me.

License

This library is under GPL3 license. A copy of it is included.