Self-Balancing Robot
User Guide
32
www.terasic.com
July 12, 2018
Table 1- 6 Data register bits
Bit
number
Bit/Filed
Name
Read/Write Description
8..0
DATA
R/W
The value to transfer to/from the RS232
UART Core. When writing, the DATA field is
a character to be written to the write FIFO.
When reading, the DATA field is a character
read from the read FIFO.
9
PE
R
Indicates whether the DATA field had a
parity
error.
15
RVALID
R
Indicates whether the DATA and PE fields
contain valid data.
23..16
RVAIL
R
The number of characters remaining in the
read FIFO (including this read).
The following will introduce how to use Nios to read the data transmitted by ESP32 and convert it
to control commands. In the main.cpp (path:\BAL_CAR_Nios_Code\software\DE10_Nano_bal),
the codes for Bluetooth controlling as below:
//
Bluetooth
control
temp=IORD(UART_BT_BASE,0x00);
number=temp>>16;
if
(number!=0)
{
szData[i]=temp&0xff;
i++;
if
((temp&0xff)==0x0a)
{
i=0;
if
(CommandParsing(szData, &Command_EPS32, &Param)){
switch
(Command_EPS32){
case
CMD_FOWARD
:
//Forward