NIOS的一小段程序

2019-03-25 09:41发布

在《NIOS那些事》上看的程序,串行通信一节,有点小疑问
SOP.H中的
typedef struct
{    //接收寄存器
    union{
        struct{
            volatile unsigned long int RECEIVE_DATA         :8;
            volatile unsigned long int NC                   :24;          
        }BITS;
        volatile unsigned long int WORD;
    }RXDATA;
    //发送寄存器
    union{
        struct{
            volatile unsigned long int TRANSMIT_DATA        :8;
            volatile unsigned long int NC                   :24;           
        }BITS;
        volatile unsigned long int WORD;
    }TXDATA;
    //状态寄存器
    union{
        struct{
            volatile unsigned long int PE           :1;
            volatile unsigned long int FE           :1;
            volatile unsigned long int BRK          :1;
            volatile unsigned long int ROE          :1;
            volatile unsigned long int TOE          :1;
            volatile unsigned long int TMT          :1;
            volatile unsigned long int TRDY         :1; //准备信号,准备好为1,否则为0
            volatile unsigned long int RRDY         :1;
            volatile unsigned long int E            :1;
            volatile unsigned long int NC           :1;
            volatile unsigned long int DCTS         :1;
            volatile unsigned long int CTS          :1;
            volatile unsigned long int EOP          :1;
            volatile unsigned long int NC1          :19;           
        } BITS;
        volatile unsigned long int WORD;
    }STATUS;
    //控制寄存器
    union{
        struct{
            volatile unsigned long int IPE          :1;
            volatile unsigned long int IFE          :1;
            volatile unsigned long int IBRK         :1;
            volatile unsigned long int IROE         :1;
            volatile unsigned long int ITOE         :1;
            volatile unsigned long int ITMT         :1;
            volatile unsigned long int ITRDY        :1;
            volatile unsigned long int IRRDY        :1;
            volatile unsigned long int IE           :1;
            volatile unsigned long int TRBK         :1;
            volatile unsigned long int IDCTS        :1;
            volatile unsigned long int RTS          :1;
            volatile unsigned long int IEOP         :1;
            volatile unsigned long int NC           :19;           
        }BITS;
        volatile unsigned long int WORD;
    }CONTROL;
    //波特率寄存器
    union{
        struct{
            volatile unsigned long int BAUD_RATE_DIVISOR    :16;
            volatile unsigned long int NC                   :16;          
        }BITS;
        volatile unsigned  int WORD;
    }DIVISOR;

}UART_ST;
在UART.C中有个语句
UART->STATUS.WORD=0;
说是这个语句对状态寄存器清零了,这是为什么呢?volatile unsigned long int WORD;这个状态寄存器中的WORD定义的是什么意思呢?
还有->是什么用法?C里的吗?
编程能力不好,求指教
此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
5条回答
kdy
2019-03-25 21:31
不用客气。前几天看了坛子里的一些讨论,想做一个低成本实用的Altera Cyclone3的工程开发板包含NIOS 应用。
如果有什么好的建议欢迎到博客留言。

一周热门 更多>