For example, I'd like a C function running in one thread to be able to insert data into a channel to a UART implemented in XC which takes a channel for input. Specifically, the C function will do some floating point computations, convert the results to a string and output them over a UART - there may be multiple threads doing this. In the example below, compute_some_numbers() is a C function and test_uart() is an XC function.
Code: Select all
int compute_task(chanend uart1)
{
while (1)
{
compute_some_numbers(uart1);
}
}
int main_core0()
{
chan uart1;
test_flash();
p_leds_3_0 <: 1;
par
{
test_uart(UART_19200, uart1);
compute_task(uart1);
}
return 0;
}
Also, once in C-land, assuming I could pass the channel to a C function, how can it be used for input or output? I'm hoping someone could point me to some examples of XC<->C channel communication or should these constructs never mix? I could see implementing this so the C function is called and a string or array returned, then output in XC, but that seems more indirect that it could be if the C function writes into the channel itself.
A related question is: where can I find out how to manipulate an XC port from a C function? How do/can things like timers and @time functionality work within a C function? or do they?
Still learning. Thanks,
Landon