zoukankan      html  css  js  c++  java
  • HI3531串口测试程序(arm) 分类: arm-linux-Ubuntu HI3531 2013-12-10 15:56 749人阅读 评论(3) 收藏

    #include<stdio.h>
    unsigned int UART0_ADDR = 0x20080000;
    unsigned int retu=0;
    int i=0;
    void delay_x(unsigned short cycles)
    {    
        unsigned short t;
        t = cycles;
        while ( --t != 0 );
    }

    int  main()
    {
    ///////////初始化部分////////////////////////////////////////////////////
        retu = *(unsigned int *)(UART0_ADDR  + 0X30);//uart_cr
        *(unsigned int *)(UART0_ADDR  + 0X30) = 0x300;
      //  retu = *(unsigned int *)(UART0_ADDR  + 0X24);//ibrd
      //  retu = *(unsigned int *)(UART0_ADDR  + 0X28);//fbrd
       *(unsigned int *)(UART0_ADDR  + 0X24) = 1;
       *(unsigned int *)(UART0_ADDR  + 0X28) = 40;
       *(unsigned int *)(UART0_ADDR  + 0X30) = 0x300;
      
       *(unsigned int *)(UART0_ADDR  + 0X2c) = 0x60;//UART_LCR_H
       *(unsigned int *)(UART0_ADDR  + 0X34) = 0x12; //UART_IFLS
       *(unsigned int *)(UART0_ADDR  + 0X38) = 0x0;//UART_IMSC
      
      
        retu = *(unsigned int *)(UART0_ADDR  + 0X30);//uart_cr
       
        *(unsigned int *)(UART0_ADDR  + 0X30) = retu | 0x01;//使能串口
    //////////////////////////////////////////////////////////   
        while(1)
        {
       // retu = *(unsigned int *)(UART0_ADDR  + 0X18);
      //  retu = retu&0x40;
        if(((*(unsigned int *)(UART0_ADDR  + 0X18))&0x40)==0x40)
        {
            retu = *(unsigned int *)(UART0_ADDR  + 0X00);
            retu = retu&0xff;
            *(unsigned int *)(UART0_ADDR  + 0X00) = retu;
        }
        retu = 0;
        delay_x(0X7000);
        }
        return 0;
    }

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    Spring Jdbc事例说明(三)
    Spring 在+publicId+和+systemId+之间需要有空格
    Spring 开发环境搭建(二)
    Spring 基础概念——DI、IOC(一)
    SHELL字符串使用总结
    POSTGRESQL 创建表结构、修改字段、导入导出数据库(支持CSV)
    Spring+mybatis+postgresql整合
    Mybatis 自动生成代码,数据库postgresql
    POSTGRESQL 自动登录
    POSTGRESQL表分区
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706703.html
Copyright © 2011-2022 走看看