⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uart0driver.c

📁 一个arm7实例
💻 C
字号:
#include"config.h"
//#include"UART0Driver.h"

void delayNs(uint32 x)
{
    uint32 y;
    for(;x>0;x--)
        for(y=0;y<5000;y++);
}

void UART0_init(uint32 UART_BPS)
{
    uint32 Fdiv;
    PINSEL0|=0x00000005;
    U0LCR=0x83;
    Fdiv=((Fpclk/16)/UART_BPS);
    U0DLM=Fdiv/256;
    U0DLL=Fdiv%256;
    U0LCR=0x03; 
   // U0IER = 0x00;                               /* 禁止中断 */
    U0FCR = 0x00; 
}


void    UART0_sendbyte(uint8 data)
{
    U0THR=data;
    while((U0LSR&0x20)==0);
   
}

char    UART0_revbyte(void)
{
    uint8 data;
    while((U0LSR&0x01)==0);
    data=U0RBR;
    return(data);
}

void UART0_sendstr(uint8  *str)
{  
  while(*str)
  {

    UART0_sendbyte(*str++);           //发送数据
    delayNs(1);
  }
  
}

void   UART0_revstr(uint8  *str)
{
    uint8 i;
    while(1)
    {
       
         i=UART0_revbyte();
         UART0_sendbyte(i); 
         if(i=='\r')break; 
        *str++=i;
      //  str++;
        
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -