Instant SoC Class Library  3.1
FC_IO_UART_RX Class Reference

UART Receiver. More...

Inheritance diagram for FC_IO_UART_RX:
FC_Base

Public Member Functions

 FC_IO_UART_RX (int baudrate, int fifo_depth=16)
 
int Read (char *pD, int nData)
 
int ReadString (char *pD, int pD_size)
 
bool ReadString (char *buff, int buff_size, char eop)
 
 operator char ()
 
char GetByte ()
 
int NumValid ()
 

Detailed Description

UART Receiver.

Adds to interface:
<name> : in std_logic
where <name> is c++ object name.
Any number of instances are allowed.

// This example shows how to use the FC_IO_UART_RX, FC_IO_UART_TX and FC_IO_SegmentDisplay classes.
// When started the application sends a hello world message on the tx uart.
// When receiving a char the char is scrolled on the the segment display
// The received bytes are sent on tx (echoed).
#include "fc_io.h"
#include "fc_system.h"
U32 ToSeg(char c); // Translates char to active segments
int main()
{
//% hw_begin
FC_IO_Clk clk(100);
FC_IO_UART_RX rx(115200);
FC_IO_UART_TX tx(115200);
//% hw_end
tx << "Hello world!!\r\n";
U32 seg[4] = {0,0,0,0}; // Init all segments
for (;;)
{
if( rx.NumValid() > 0 ) {
char b = rx.GetByte(); // Read one byte
for(int i=3;i>=0;i--) { // Shift the segments
if(i==0)
seg[i] = ToSeg(b);
else
seg[i] = seg[i-1];
sd.SetDisplay( seg[i], i );
}
tx << b; // Echo the received byte
}
}
}
FC_IO_Clk
System clock input.
Definition: fc_io.h:55
FC_IO_UART_TX
UART Transmitter.
Definition: fc_io.h:348
FC_IO_UART_RX
UART Receiver.
Definition: fc_io.h:399
FC_IO_SegmentDisplay
Segment Display controller.
Definition: fc_io.h:688