Standard UART Library - using in MC Audio project
Posted: Mon Jan 08, 2018 11:31 am
Hi guys, new guy here.
I'm doing a project involving an XUF216 doing USB to I2S duties.
I've adapted the mc reference design project to my needs with no problems, everything seems to be working as it should, I'm getting audio out and everything.
But then I attempted to include a UART interface and my newbeeness at this caught up with me.
The idea is to use a UART tx channel to send audio channel info to an external uC every time something worthwhile happens, like for example the sampling rate changes. To do that I see that i need to use AudioHwConfig() to send the relevant data through a serial port. I'd like that serial port to be at port 1A.
Looking at the lib_uart user's guide, I'm seeing that I need to do something like this:
port p_uart_tx = on tile[0] : XS1_PORT_1A;
int main() {
interface uart_tx_if i_tx;
output_gpio_if i_gpio_tx[1];
par {
on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
on tile[0]: uart_tx(i_tx, null,115200, UART_PARITY_NONE, 8, 1,i_gpio_tx[0]);
on tile[0]: app(i_tx);
}
return 0;
}
and have an app() that looks like this:
void app(client uart_tx_if uart_tx) {
// For starters, just write a single byte to the UART
uart_tx.write(0xff);
}
It looks pretty simple, I suppose.
The problem is that I can't figure out where exactly to put the above code.
I've tried putting all of it in main.cx or audiohw.cx and pretty much all different combinations of parts of code and files, with no success.
I'm suspecting that I'm missing something pretty basic here.
Any kind of help would be most welcome.
I'm doing a project involving an XUF216 doing USB to I2S duties.
I've adapted the mc reference design project to my needs with no problems, everything seems to be working as it should, I'm getting audio out and everything.
But then I attempted to include a UART interface and my newbeeness at this caught up with me.
The idea is to use a UART tx channel to send audio channel info to an external uC every time something worthwhile happens, like for example the sampling rate changes. To do that I see that i need to use AudioHwConfig() to send the relevant data through a serial port. I'd like that serial port to be at port 1A.
Looking at the lib_uart user's guide, I'm seeing that I need to do something like this:
port p_uart_tx = on tile[0] : XS1_PORT_1A;
int main() {
interface uart_tx_if i_tx;
output_gpio_if i_gpio_tx[1];
par {
on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
on tile[0]: uart_tx(i_tx, null,115200, UART_PARITY_NONE, 8, 1,i_gpio_tx[0]);
on tile[0]: app(i_tx);
}
return 0;
}
and have an app() that looks like this:
void app(client uart_tx_if uart_tx) {
// For starters, just write a single byte to the UART
uart_tx.write(0xff);
}
It looks pretty simple, I suppose.
The problem is that I can't figure out where exactly to put the above code.
I've tried putting all of it in main.cx or audiohw.cx and pretty much all different combinations of parts of code and files, with no success.
I'm suspecting that I'm missing something pretty basic here.
Any kind of help would be most welcome.