AnsweredAssumed Answered

About ports, variables and write/read operations

Question asked by gsanchez on May 8, 2013
Latest reply on May 13, 2013 by gsanchez

Hi all, I have a question.

How can I redirect a set of defined ports to a variable? Or better, treat all they as a variable.

I try to explain it better:


I have in my application:


#define PORT_OUT_1 (GPIO_PORT_E | GPIO_PIN11)

#define PORT_OUT_2 (GPIO_PORT_E | GPIO_PIN8)

...

 

Then, in the code:

 

GPIO_PIN_STRUCT pins_control[] = {

 

     PORT_OUT_1 | GPIO_PIN_STATUS_0,

     PORT_OUT_2 | GPIO_PIN_STATUS_0,

     PORT_OUT_3 | GPIO_PIN_STATUS_0,

     PORT_OUT_4 | GPIO_PIN_STATUS_0,

 

     PORT_OUT_5 | GPIO_PIN_STATUS_0,

 

     PORT_OUT_6 | GPIO_PIN_STATUS_0,

     PORT_OUT_7 | GPIO_PIN_STATUS_0,

     PORT_OUT_8 | GPIO_PIN_STATUS_0,

     GPIO_LIST_END };

 

And in some place:

 

     port_file = fopen("gpio:write", (char_ptr) &pins_control);

 

Then, what I want is to write:

pins_control = "0xAA";


And obtain the values independently in the ports:

PORT_OUT_1<-1,

 

PORT_OUT_2<-0,

PORT_OUT_3<-1,

PORT_OUT_4<-0,

 

PORT_OUT_5<-1,

 

PORT_OUT_6<-0,

PORT_OUT_7<-1,

PORT_OUT_8<-0,

 

This can be done? I hope I explained.

Thanks. Kind regards.

 

PS: Sorry about my english.

 

Outcomes