Hi Jesse
For each UART you need a handle. This is allocated when the UART is opened and then used to change the UART state (eg. enable TX or RX) and then send and receive over it.
Each UART has a channel number starting at 0 for UART0, continuing with 1, 2, 3 etc. for UARTs 1, 2, 3 etc. (the limit depends on the processor hardware).
This means that an open will configure one UART and afterwards the handle corresponds to this HW UART. This one UART handle can be used for input and output via this UART (it is not necessary to have one handle for input and one for output).
eg. fnWrite(SerialPortID, buffer, length); and fnRead(SerialPortID, buffer, length;
Assuming the processor has 3 UARTs the open can be repeated 3 times (with same or different paremeters) and then there are 3 handles (say, SerialPortID, SerialPortID1 and SerialPortID2 for UARTs 0, 1 and 2).
To send something over UART 1 use fnWrite(
SerialPortID1, buffer, length); and to send something over UART2 use fnWrite(
SerialPortID2, buffer, length);, etc.
When opening the serial port you pass the task responsible for handling receptions from it:
(eg.
tInterfaceParameters.Task_to_wake = OWN_TASK;).
There can be one task for each UART input or one single task can handle all inputs.
To handle all inputs in one task, the task has to simply check each one when it is worken (eg.):
while (fnMsgs(SerialPortID)) {
// read reception from this UART
}
while (fnMsgs(SerialPortID1)) {
// read reception from this UART
}
while (fnMsgs(SerialPortID2)) {
// read reception from this UART
}
If there is one task for each input it is a little more efficient since the task only has to check one serial port input.
Since Rx and Tx of a UART are actually independent (apart from Baud and configuration settings) it is possible to implement a connection with Tx from UART0 and Rx from UART1. In this case writes use SerialPortID and reads use SerialPortID1, however usually the RX and TX lines of a physical UART are used together.
To send the same data to all UARTs is very simple:
fnWrite(SerialPortID, buffer, length);
fnWrite(SerialPortID1, buffer, length);
fnWrite(SerialPortID2, buffer, length);
The same message is sent to all three outputs.
The following thread is possibly the best overview for using the serial interface:
http://www.utasker.com/forum/index.php?topic=54.msg220#msg220Regards
Mark