Skip to content

Commit

Permalink
some toogling bits working
Browse files Browse the repository at this point in the history
  • Loading branch information
GBert committed Mar 29, 2014
1 parent 6dab4d3 commit 5bf731c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cp210x_toggle.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
int main()
{
int fd;
printf("CP210x Serial Test\n");
printf("CP2104 GPIO Test\n");
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
Expand All @@ -23,16 +23,11 @@ int main()

ioctl(fd, IOCTL_GPIOGET, &gpio);
printf("original gpio = 0x%08X\n",gpio);
gpio = ~gpio;
gpio = gpio << 8;
gpio |= 0x00FF;
printf("gpio = 0x%08X\n",gpio);
ioctl(fd, IOCTL_GPIOSET, &gpio);
ioctl(fd, IOCTL_GPIOGET, &gpio);
printf("gpio = 0x%08X\n",gpio);

for (i = 0; i<= 1000000; i++) {
gpio ^= 0xffffffff;
for (i = 0; i<= 50000; i++) {
gpio = 0x0005000f;
ioctl(fd, IOCTL_GPIOSET, &gpio);
gpio = 0x000a000f;
ioctl(fd, IOCTL_GPIOSET, &gpio);
}

Expand Down

0 comments on commit 5bf731c

Please sign in to comment.