Class UART6

  • All Implemented Interfaces:
    Impc5200, Ippc32

    public class UART6
    extends Object
    implements Impc5200

    Driver for the UART of the Freescale MPC5200.

    Remember:
    Depending on the baudrate configured, the effective baudrate can be different. This may cause miss interpretation of the bytes sent at the receiver!

    • Constructor Detail

      • UART6

        public UART6()
    • Method Detail

      • start

        public static void start​(int baudRate,
                                 short parity,
                                 short data)

        Initialize and start the UART 6.

        This method has to be called before using the UART6! The number of stop bits can't be set. There is always one stop bit!

        Parameters:
        baudRate - The baud rate. Allowed Range: 64 to 500'000 bits/s.
        parity - Parity bits configuration. Possible values: NO_PARITY, ODD_PARITY or EVEN_PARITY.
        data - Number of data bits. Allowed values are 5 to 8 bits.
      • write

        public static void write​(byte b)
                          throws IOException
        Writes a given byte into the transmit buffer. A call of this method is not blocking! That means the byte is lost if the buffer is already full!
        Parameters:
        b - Byte to write.
        Throws:
        IOException - if an error occurs while writing to this stream.
      • write

        public static int write​(byte[] buffer)
                         throws IOException
        Writes a given number of bytes into the transmit fifo. A call of this method is not blocking! There will only as many bytes written, which are free in the fifo.
        Parameters:
        buffer - Array of bytes to send.
        Returns:
        the number of bytes written.
        Throws:
        IOException - if an error occurs while writing to this stream.
      • write

        public static int write​(byte[] buffer,
                                int off,
                                int count)
                         throws IOException
        Writes a given number of bytes into the transmit fifo. A call of this method is not blocking! There will only as many bytes written, which are free in the fifo.
        Parameters:
        buffer - Array of bytes to send.
        off - Offset to the data which should be sent.
        count - Number of bytes to send.
        Returns:
        the number of bytes written.
        Throws:
        IOException - if an error occurs while writing to this stream.
        NullPointerException - if buffer is null.
        IndexOutOfBoundsException - if off < 0 or count < 0, or if off + count is bigger than the length of buffer.
      • availToWrite

        public static int availToWrite()
        Returns the number of free bytes available in the transmit fifo. It is possible, to send the returned number of bytes in one nonblocking transfer.
        Returns:
        the available free bytes in the transmit fifo.
      • availToRead

        public static int availToRead()
        Returns the number of bytes available in the receive fifo.
        Returns:
        number of bytes in the receive fifo.
      • read

        public static int read()
                        throws IOException
        Reads one byte from the receive fifo. A call of this method is not blocking!
        Returns:
        byte read.
        Throws:
        IOException - if no byte available.
      • read

        public static int read​(byte[] buffer)
                        throws IOException
        Reads the given number of bytes from the UART6. A call of this method is not blocking!
        Parameters:
        buffer - Byte array to write the received data.
        Returns:
        the number of bytes read.
        Throws:
        IOException - if no data available.
      • read

        public static int read​(byte[] buffer,
                               int off,
                               int count)
                        throws IOException
        Reads the given number of bytes from the UART6. A call of this method is not blocking!
        Parameters:
        buffer - Byte aray to write the received data.
        off - Offset in the array to start writing the data.
        count - Length (number of bytes) to read.
        Returns:
        the number of bytes read.
        Throws:
        IOException - if an error occurs while reading from this stream.
        NullPointerException - if buffer is null.
        IndexOutOfBoundsException - if off < 0 or count < 0, or if off + count is bigger than the length of buffer.