Package org.deepjava.flink.subdevices
Class FlinkUART
- java.lang.Object
- 
- org.deepjava.flink.subdevices.FlinkUART
 
- 
- All Implemented Interfaces:
- FlinkDefinitions
 
 public class FlinkUART extends Object implements FlinkDefinitions The flink UART subdevice realizes an UART function within a flink device. It offers several channels. Each channel has its own baudrate generator together with transmit and receive queues.- Author:
- Urs Graf
 
- 
- 
Field SummaryFields Modifier and Type Field Description FlinkUARTInputStreaminInput stream to read from this UART..FlinkUARTOutputStreamoutOutput stream to write to this UART.static intpUART0static intpUART1static intpUART2static intpUART3static intpUART4static intpUART5static intpUART6static intpUART7static intTX_FULL- 
Fields inherited from interface org.deepjava.flink.core.FlinkDefinitionsANALOG_INPUT_INTERFACE_ID, ANALOG_OUTPUT_INTERFACE_ID, CHANNEL_OFFSET, COUNTER_INTERFACE_ID, GPIO_INTERFACE_ID, HEADER_SIZE, INFO_DEVICE_ID, INFO_DEVICE_SIZE, INTERFACE_TYPE_MASK, MOD_CONF_OFFSET, MOD_STATUS_OFFSET, PPWA_INTERFACE_ID, PWM_INTERFACE_ID, REGISTER_WIDTH, REGISTER_WIDTH_BIT, SIZE_OFFSET, SUBHEADER_SIZE, TOTAL_HEADER_SIZE, TYPE_OFFSET, UART_INTERFACE_ID, UNIQUE_ID_OFFSET, WD_INTERFACE_ID
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailToRead()Returns the number of bytes available in the receive buffer.static FlinkUARTgetInstance(FlinkSubDevice dev, int uartNr)Returns an instance of FlinkUART Interface operating one of the UARTS in the flink UART subdevice.intread()Reads one byte from the UART.intread(byte[] buffer)Reads the given number of bytes from the UART.intread(byte[] buffer, int off, int count)Reads the given number of bytes from the UART.voidreset()Resets the UART.voidstart(int baudRate)Initialize and start the flink Universal Asynchronous Receiver Transmitter.voidwrite(byte b)Writes a given byte into the transmit buffer.intwrite(byte[] buffer)Writes a given number of bytes into the transmit buffer.intwrite(byte[] buffer, int off, int count)Writes a given number of bytes into the transmit buffer.
 
- 
- 
- 
Field Detail- 
pUART0public static final int pUART0 - See Also:
- Constant Field Values
 
 - 
pUART1public static final int pUART1 - See Also:
- Constant Field Values
 
 - 
pUART2public static final int pUART2 - See Also:
- Constant Field Values
 
 - 
pUART3public static final int pUART3 - See Also:
- Constant Field Values
 
 - 
pUART4public static final int pUART4 - See Also:
- Constant Field Values
 
 - 
pUART5public static final int pUART5 - See Also:
- Constant Field Values
 
 - 
pUART6public static final int pUART6 - See Also:
- Constant Field Values
 
 - 
pUART7public static final int pUART7 - See Also:
- Constant Field Values
 
 - 
TX_FULLpublic static final int TX_FULL - See Also:
- Constant Field Values
 
 - 
outpublic FlinkUARTOutputStream out Output stream to write to this UART.
 - 
inpublic FlinkUARTInputStream in Input stream to read from this UART..
 
- 
 - 
Method Detail- 
getInstancepublic static FlinkUART getInstance(FlinkSubDevice dev, int uartNr) Returns an instance of FlinkUART Interface operating one of the UARTS in the flink UART subdevice.- Parameters:
- dev- handle to the subdevice
- uartNr- 0 selects UART0, 1 selects UART1, ..
- Returns:
- instance of UART
 
 - 
startpublic void start(int baudRate) Initialize and start the flink Universal Asynchronous Receiver Transmitter. This method have to be called before using the flink UART! The number of stop bits, the parity mode and number of data bits can't be set. There is always one stop bit. Parity is off. Number of data bits is 8. - Parameters:
- baudRate- The baud rate. Allowed Range: 64 to 1'000'000 bits/s.
 
 - 
resetpublic void reset() Resets the UART. All the pending transmissions will be stopped, the buffers will be emptied and the UART will be restarted.
 - 
writepublic void write(byte b) throws IOExceptionWrites a given byte into the transmit buffer. A call of this method is blocking! If the buffer is full, the method blocks for a short period of time until a small amount of space is available again. After this an IOException is thrown.- Parameters:
- b- Byte to write.
- Throws:
- IOException- if an error occurs while writing to this stream.
 
 - 
writepublic int write(byte[] buffer) throws IOExceptionWrites a given number of bytes into the transmit buffer. A call of this method is not blocking! There will only as many bytes written, which are free in the buffer.- Parameters:
- buffer- Array of bytes to send.
- Returns:
- the number of bytes written.
- Throws:
- IOException- if an error occurs while writing to this stream.
 
 - 
writepublic int write(byte[] buffer, int off, int count) throws IOExceptionWrites a given number of bytes into the transmit buffer. A call of this method is not blocking! There will only as many bytes written, which are free in the buffer.- 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- bufferis null.
- IndexOutOfBoundsException- if- off < 0or- count < 0, or if- off + countis bigger than the length of- buffer.
 
 - 
availToReadpublic int availToRead() Returns the number of bytes available in the receive buffer.- Returns:
- number of bytes in the receive buffer.
 
 - 
readpublic int read() throws IOExceptionReads one byte from the UART. A call of this method is not blocking!- Returns:
- byte read.
- Throws:
- IOException- if no byte available.
 
 - 
readpublic int read(byte[] buffer) throws IOExceptionReads the given number of bytes from the UART. 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.
 
 - 
readpublic int read(byte[] buffer, int off, int count) throws IOExceptionReads the given number of bytes from the UART. 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- bufferis null.
- IndexOutOfBoundsException- if- off < 0or- count < 0, or if- off + countis bigger than the length of- buffer.
 
 
- 
 
-