Hello I have a program, that I want to run on the same tile on 2 cores. The program is the same only the ports differ.
So I want to start the software in the par{} statement with different port configurations....is there a good way to do that?
I guess it would be something like:
on tile[0]: ctrl_ports_t hal_ctrl1 =
{
XS1_PORT_4F, // slp_tr / rst_n
XS1_PORT_1M, // chip select
XS1_PORT_1I, // nIRQ
XS1_PORT_4E,
};
on tile[0]: ctrl_ports_t hal_ctrl2 =
{
... different config...
};
par
{
on tile[0]: rfmac_server(hal_ctrl1);
on tile[0]: rfmac_server(hal_ctrl2);
}
Is there a good example I can look at?
dynamic port configuration
-
- Member++
- Posts: 19
- Joined: Wed Sep 17, 2014 1:20 pm
-
- Member++
- Posts: 19
- Joined: Wed Sep 17, 2014 1:20 pm
I meant somethin like this:
can someone overview it? There should be a better implementation without unsafe regions. My problem is, that I have to access ports out of the select functions. I have a whole class that should be able to access the port...and runs on one core
Code: Select all
//Port Configuration 1
on tile[0]: at86rf233_ctrl_ports_t hal_ctrl1 =
{
XS1_PORT_4E
};
//Port Configuration 2
on tile[1]: at86rf233_ctrl_ports_t hal_ctrl2 =
{
XS1_PORT_4A
};
port* unsafe val;
at86rf233_ctrl_ports_t* unsafe local_cnfg;
void ledtask(at86rf233_ctrl_ports_t &port_cnfg){
at86rf233_ctrl_ports_t* movable local_cnfg_tmp = &port_cnfg;
unsafe {
local_cnfg = move(local_cnfg_tmp);
}
while(1){
unsafe{
local_cnfg->p_led <: 0xFF;
delay_seconds(1);
local_cnfg->p_led <: 0x00;
delay_seconds(1);
}
}
}
int main () {
par {
on tile[0]:ledtask(hal_ctrl1);
on tile[1]:ledtask(hal_ctrl2);
//ledtask();
}
return 0;
}
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
You can do something as shown below:
Is this what you are looking for?
Code: Select all
/Port Configuration 1
on tile[0]: hal_ctrl1 =
{
XS1_PORT_4E
};
//Port Configuration 2
on tile[1]: hal_ctrl2 =
{
XS1_PORT_4A
};
void ledtask(port hal_port){
while(1){
select{
case hal_port:> unsigned data: //If you want to read from a port
break;
}
hal_port<: 0xFF; //Write data to the port
}
}
int main () {
par {
on tile[0]:ledtask(hal_ctrl1);
on tile[1]:ledtask(hal_ctrl2);
//ledtask();
}
return 0;
}
-
- Member++
- Posts: 19
- Joined: Wed Sep 17, 2014 1:20 pm
sethu_jangala wrote:You can do something as shown below:
Is this what you are looking for?Code: Select all
/Port Configuration 1 on tile[0]: hal_ctrl1 = { XS1_PORT_4E }; //Port Configuration 2 on tile[1]: hal_ctrl2 = { XS1_PORT_4A }; void ledtask(port hal_port){ while(1){ select{ case hal_port:> unsigned data: //If you want to read from a port break; } hal_port<: 0xFF; //Write data to the port } } int main () { par { on tile[0]:ledtask(hal_ctrl1); on tile[1]:ledtask(hal_ctrl2); //ledtask(); } return 0; }
Thanks, yes I am aware and know that implementation. My problem is that I have a driver that is written in C and that calls functions like Select() that should set a pin high. The whole driver must be ported to xc if I want to do it your way.
Somehow I need to copy the port configuration, so that I can call functions like:
Code: Select all
void xhal_set_rst_low(void){
p_ctrl_state &= ~HAL_RST_N;
hal_ctrl->p_ctrl <: p_ctrl_state; //set pin low
}
I have a version running now using unsafe structure and copying the port configuration in the local xc file:
Code: Select all
at86rf233_ctrl_ports_t* movable local_cnfg_tmp = &ctrl_ports;
unsafe {
hal_ctrl = move(local_cnfg_tmp);
}
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
If I understand correctly, you want to pass the port as parameters to C functions. If that is the case, have a look at the solution specified by Ross in the following post:
http://www.xcore.com/forum/viewtopic.php?f=3&t=2562
You can pass XC to C using xccompat.h header file.
http://www.xcore.com/forum/viewtopic.php?f=3&t=2562
You can pass XC to C using xccompat.h header file.
-
- Member++
- Posts: 19
- Joined: Wed Sep 17, 2014 1:20 pm
yes thanks, if the same works with channels and ports....I guess it does ;) thank you!