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!
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!
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.
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?
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!
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