Passing parameter to 'out port' argument....

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
In_Control001
Member++
Posts: 20
Joined: Thu Mar 04, 2010 7:27 pm

Passing parameter to 'out port' argument....

Post by In_Control001 »

Hi guys,


What parameters can I pass to a 'port' argument?


Kind regards,
Jo


richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

I'm not sure I fully understand the question. Do you mean which port types can be passed to functions taking a parameters of different port types?

If the parameter is a void port then you can always pass any port type with any qualifier. Otherwise the following rules apply:

If the parameter is qualified in the argument can't be qualified void or out.
If the parameter is qualified out the argument can't be qualified void or in.
If the parameter is unqualified the argument can't qualified void, in or out.

The argument should be buffered if and only if the parameter is buffered. If the port width is specified then it must be the same for the argument and the parameter.
User avatar
In_Control001
Member++
Posts: 20
Joined: Thu Mar 04, 2010 7:27 pm

Post by In_Control001 »

Ah sorry, I need to give an example. What is a void port?

Code: Select all

#include<xs1.h>
#defineBIT_RATE115200
#defineBIT_TIME100000000/BIT_RATE
outportTXD=XS1_PORT_1A;
outportRXD=XS1_PORT_1B;
voidtransmitter(outportTXD){
unsignedbyte,time;
timert;
while(1){
/*getnextbytetotransmit*/
byte=getByte();
t:>time;
/*outputstartbit*/
TXD<:0;
time+=BIT_TIME;
twhentimerafter(time):>void;
/*outputdatabits*/
for(inti=0;i<8;i++){
TXD<:>>byte;
time+=BIT_TIME;
twhentimerafter(time):>void;
}
/*outputstopbit*/
TXD<:1;
time+=BIT_TIME;
twhentimerafter(time):>void;
}
}
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

It's used in functions which don't input or output on the port. Please see sections 3.2, 5.4 and 7.2 of the XC programming book at http://www.xmos.com/system/files/xcuser_en.pdf