AnsweredAssumed Answered

GPIO Write operation

Question asked by OLEG KARPENKO on Jun 3, 2009
Latest reply on Jan 31, 2011 by Juraj Vanco

Hi, 

I have a problem  with setting value (other then all 1's or or all 0's) for group of GPIO pins .

Below is code fragment. Comments shows what's working/not working. 

For now I made clunky piece of code when I open and manipulate each pin  individually through GPIO_IOCTL_WRITE_LOGx. But I have feeling there is better way of doing it ether through ioctl() or write(). 

 

FILE_PTR port_file1;   
uint_32 set_value = 10;
uint_32 pins1[] = {
      GPIO_OUTPUT1,
      GPIO_OUTPUT2,
      GPIO_OUTPUT3,
      GPIO_OUTPUT4,
      GPIO_LIST_END
   };
port_file1 = fopen("gpio:write", (char_ptr) &pins1);

ioctl(port_file1, GPIO_IOCTL_WRITE_LOG0, NULL);         //Works! pins value 0x00
ioctl(port_file1, GPIO_IOCTL_WRITE_LOG1, NULL);         //Works pins value 0x0f

ioctl(port_file1, GPIO_IOCTL_WRITE, (char_ptr) &set_value);    //Doesn't work. Pins value 0x00

 

write(port_file1,(char_ptr) &set_value, 1);            //Doesn't work. Pins value 0x00

pins1[0]=GPIO_PIN_STATUS_1;
write(port_file1,(char_ptr) &pins1, sizeof (pins1));        //Doesn't work. Pins value 0x00

Outcomes