- Silicon Labs Community
- Welcome and Announcements
- Silicon Labs Knowledge Base
- 8-bit MCU
- 32-bit MCU
- Bluetooth / Wi-Fi
- Other Products Category
- Optical/RH/Temp Sensor
- Other Products
- Hardware and Software Tools
- Simplicity Studio and Software
- General Discussions and Suggestions
- Chinese Forum
- Software Libraries
- Development Kits
- Reference Designs
- Third Party Tools
- White Papers
- Official Blog of Silicon Labs
- Chinese Blog
09-07-2017 10:34 AM
I have a bit of trouble accessing the GPIO8-15 of the CP2108. I followed the example code and it works for the first 8 GPIOs but I have no idea how to access the other ones. It seems to me that the upper 8 ones are not supported at all. At least when I look at the prototype of the CP210xRT_WriteLatch function in AN721 (p42):
CP210x_STATUS CP210xRT_WriteLatch(HANDLE Handle, BYTE Mask, BYTE Latch)
And a byte holds IMHO only 8 bit, so there is no way of accessing 16 GPIOs... can somebody please give me a hint what to do?
Thanks in advance!
Solved! Go to Solution.
09-08-2017 03:19 AM
Thanks for the answer but this does not help me very much. I tried it on Linux as well and there is no distinguishable way of flipping the upper 8 GPIOs. So I will just use some other GPIOs and redesign the PCB. Thanks anyway!
09-13-2017 12:39 PM
Please have a look at application note "AN978: CP210x USB-to-UART API Specification.":
The API specification for the CP210xRT_WriteLatch() function is contained in section 1.2.2 (page 17), and is as follows:
Thus, the mask and latch parameters are WORD parameters, not BYTE parameters.
Also, you can verify the functionality of using this function to change all of the GPIO states on the CP2108 using the AN223 software tool "CP210x Port Read/Write Example":
https://www.silabs.com/documents/public/application-notes/an223.pdf (This document is superseded by AN978).
I hope this helps. Let me know if you have questions.
09-14-2017 02:35 AM
Thanks for your reply, Mitch. I used AN721 as reference:
The software from AN223 is sadly only for Windows, as far as I can see, but seems to work in my virtual machine. And the example code from the Linux VCP driver toggles only the lower 8 GPIOs. Since the final product should work in combination with a Linux system (I forgot to mention in my initial post) and it seems to work under Windows, how to make the magic happen on Linux?
09-15-2017 10:09 AM
The CP210x driver that is pre-built into the Linux kernel does not support GPIO functions, however, you can download and install the CP210x Linux driver from our website, which does support GPIO manipulation on the CP210x devices. You can download the appropriate driver from the following site:
Additionally, the following knowledge base may provide a bit more information about the differences in these linux CP210x drivers:
Finally, I have attached some example code (cp210x_gpio_example2_linux.c) that demonstrates GPIO use using the driver from our website.
I hope this helps!
09-18-2017 03:19 AM
this comment in your code did the trick:
// mask = 3: gpio #1 and #0; value = 2: set #1, clear #0 // Clearing GPIO turns LED on on SiLabs blue EK boards. #ifdef CP2108 unsigned short gpioread = 0x3333; unsigned long gpio = 0x00020003; #else unsigned char gpioread = 0;// 0x33; unsigned short gpio = 0; #endif
Would be nice to find this somewhere in the documentation. But thanks, it's working now fine