About GPIO output functions

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About GPIO output functions

Jump to solution
2,598 Views
d_vara
Contributor III
Hi.
I am starting to use GPIO pins and ports.
I have read that I use :

const uint_32 puerto_set[]=
{
puertox_pin0|GPIO_PIN_STATUS_0,
puertox_pin1|GPIO_PIN_STATUS_0,
puertox_pin2|GPIO_PIN_STATUS_0,
puertox_pin3|GPIO_PIN_STATUS_0,
puertox_pin4|GPIO_PIN_STATUS_0,
puertox_pin5|GPIO_PIN_STATUS_0,
puertox_pin6|GPIO_PIN_STATUS_0,
puertox_pin7|GPIO_PIN_STATUS_0,
GPIO_LIST_END
};

If I want read:
puerto=fopen("gpio:read",(char_ptr)&puerto_set);
static const uint_32 data_a[]=
{
dato0,
dato1,
dato2,
dato3,
dato4,
dato5,
dato6,
dato7,
GPIO_LIST_END
}
ioctl(puerto,GPIO_IOCTL_READ,(char_ptr)&data_a);


In this case, I can read all the pins only once.

But when I want write, I only write pins one by one. For example:

puerto=fopen("gpio:write",(char_ptr)&puerto_set);
static const uint_32 data_b=
{
dato0,
GPIO_LIST_END
}

ioctl(puerto,GPIO_IOCTL_WRITE_LOG0,(char_ptr)&data_b);

I know that if change the last definition of "data_b", I can include some pins more. But I am interested to output the port in one go. All pins simultaneously. But, the value of the pins can be different at any time.
I want know what function carry out : output(data_a, puerto_set);

Do you understand me?

Thanks.



Message Edited by d.vara on 28-07-2009 02:37 PM
0 Kudos
1 Solution
600 Views
d_vara
Contributor III

Sorry.

 

I have studing the MQX drive, and I am wrong.

I must use the next expression:

ioctl(port, GPIO_IOCTL_WRITE,&data);

 

Before I was using  GPIO_IOCTL_WRITE_0 or GPIO_IOCTL_WRITE_1. I did not realize, that existed a generic define.

 

thanks.

View solution in original post

0 Kudos
5 Replies
600 Views
CarlFST60L
Senior Contributor II

From my (limited) understanding, I believe you will only ever be able to 'simultaneously' set/clear pins on a single port at a time, even if you do it in straight assembly as you can only write to one port at a time as they all have their own address. I have not read the MQX IO driver to see how it writes to the port, so it may be possible it does bit by bit even on single ports, is this what your saying? 

 

If you need such finite control, maybe you are better off writing a couple of lines in assembly or straight C to control the ports directly i.e. write you own low level driver if its mission critical.

 

Again, I dont really know the IO MQX drive, just trying to offer something...

0 Kudos
600 Views
bkatt
Contributor IV

CarlFST60L wrote:

From my (limited) understanding, I believe you will only ever be able to 'simultaneously' set/clear pins on a single port at a time, even if you do it in straight assembly as you can only write to one port at a time as they all have their own address.


Yes, but Freescale generally lays out the port, set, and clear addresses for GPIO consecutively. It would appear that one could use a move.w or move.l instruction to affect 16 or 32 bits at a time. While I've never tried this and I assume that an OS like MQX would have no built-in support for it, I suspect it would work and would be useful for some kinds of embedded interfaces.

0 Kudos
600 Views
sumakana
Contributor I

It works. You  can even include drivers made in MCU_init( ), but you have to be careful in the integration of the headers of MQX an Processor expert, for some PERIPHERALS conflict in the way they`re represented, in one could be a constant, and in the other could be a variable with such value. The first example WE ALL SHOULD KNOW ABOUT is TRUE and FALSE in Codewarrior is defined as 1 or 0 and in MQX is defined as (boolean)1 AND we find that Boolean is "typedef unsigned long  Boolean". My project consists of a network of 4 MCF52233 boards with Xbee and MC13192 with TCP/IP web server. As far as my experience goes, GPIO(LEDS and SWITCHER),ADC,Serial Port, SPI and so are better off in regular Processor Expert driver. Ethernet, USB and Flexcan should REALLY be done using MQX drivers. Simple answers towards simple needs, complex tools towards complex tasks. If anyone is interested, we can set up a forum dedicated to this board, as its very popular due to its low price. I`m also interested in uploading a pdf on what I`m working on, but I`d like to know the requirement for it.

0 Kudos
601 Views
d_vara
Contributor III

Sorry.

 

I have studing the MQX drive, and I am wrong.

I must use the next expression:

ioctl(port, GPIO_IOCTL_WRITE,&data);

 

Before I was using  GPIO_IOCTL_WRITE_0 or GPIO_IOCTL_WRITE_1. I did not realize, that existed a generic define.

 

thanks.

0 Kudos
600 Views
d_vara
Contributor III

Thanks for your reply.

 

All of this, is not critical in my program.

But I would know how make it.

I want for example:

char i=0x42;

output (portX,i);

 

But,I think that it is imposible using MQX.

 

Thanks.

0 Kudos