亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? uart128.c

?? AT45DB161D的測試程序.rar
?? C
字號:
#include<global.h>
//#include<buffer.h>
#include<macros.h>
#include<uart128.h>
//#include<iom128v.h>
/*
#define TRUE 1
#define FALSE 0


// UART global variables
// flag variables
volatile u08   uartReadyTx[2];
volatile u08   uartBufferedTx[2];
 // receive and transmit buffers
cBuffer uartRxBuffer[2];
cBuffer uartTxBuffer[2];
unsigned short uartRxOverflow[2];
#ifndef UART_BUFFERS_EXTERNAL_RAM
     // using internal ram,
     // automatically allocate space in ram for each buffer
     static char uart0RxData[UART0_RX_BUFFER_SIZE];
     static char uart0TxData[UART0_TX_BUFFER_SIZE];
     static char uart1RxData[UART1_RX_BUFFER_SIZE];
     static char uart1TxData[UART1_TX_BUFFER_SIZE];
#endif
 
 typedef void (*voidFuncPtru08)(unsigned char);
 volatile static voidFuncPtru08 UartRxFunc[2];
 
void uartInit(void)
 {
     // initialize both uarts
     uart0Init();
     uart1Init();
 }
 */
 /*
void uart0Init(void)
 {
     // initialize the buffers
     uart0InitBuffers();
     // initialize user receive handlers
     UartRxFunc[0] = 0;
     // enable RxD/TxD and interrupts
//     outb(UCSR0B, (1<<RXCIE)|(1<<TXCIE)|(1<<RXEN)|(1<<TXEN));
		 UCSR0B=//*(1<<RXCIE)|(1<<TXCIE)|
		 (1<<RXEN)|(1<<TXEN);
     // set default baud rate
     uartSetBaudRate(0, UART0_DEFAULT_BAUD_RATE); 
     // initialize states
     uartReadyTx[0] = TRUE;
     uartBufferedTx[0] = FALSE;
     // clear overflow count
     uartRxOverflow[0] = 0;
     // enable interrupts
     SEI();
 }
 
void uart1Init(void)
 {
     // initialize the buffers
     uart1InitBuffers();
     // initialize user receive handlers
     UartRxFunc[1] = 0;
     // enable RxD/TxD and interrupts
   //  outb(UCSR1B, (1<<RXCIE)|(1<<TXCIE)|(1<<RXEN)|(1<<TXEN));
		 UCSR1B=//*(1<<RXCIE)|(1<<TXCIE)|
		 (1<<RXEN)|(1<<TXEN);
     // set default baud rate
     uartSetBaudRate(1, UART1_DEFAULT_BAUD_RATE);
     // initialize states
     uartReadyTx[1] = TRUE;
     uartBufferedTx[1] = FALSE;
     // clear overflow count
     uartRxOverflow[1] = 0;
     // enable interrupts
     SEI();
 }
 
void uart0InitBuffers(void)
 {
     #ifndef UART_BUFFERS_EXTERNAL_RAM
         // initialize the UART0 buffers
         bufferInit(&uartRxBuffer[0], uart0RxData, UART0_RX_BUFFER_SIZE);
         bufferInit(&uartTxBuffer[0], uart0TxData, UART0_TX_BUFFER_SIZE);
     #else
         // initialize the UART0 buffers
         bufferInit(&uartRxBuffer[0], (u08*) UART0_RX_BUFFER_ADDR, UART0_RX_BUFFER_SIZE);
         bufferInit(&uartTxBuffer[0], (u08*) UART0_TX_BUFFER_ADDR, UART0_TX_BUFFER_SIZE);
     #endif
 }
 
void uart1InitBuffers(void)
 {
     #ifndef UART_BUFFERS_EXTERNAL_RAM
         // initialize the UART1 buffers
         bufferInit(&uartRxBuffer[1], uart1RxData, UART1_RX_BUFFER_SIZE);
         bufferInit(&uartTxBuffer[1], uart1TxData, UART1_TX_BUFFER_SIZE);
     #else
         // initialize the UART1 buffers
         bufferInit(&uartRxBuffer[1], (u08*) UART1_RX_BUFFER_ADDR, UART1_RX_BUFFER_SIZE);
         bufferInit(&uartTxBuffer[1], (u08*) UART1_TX_BUFFER_ADDR, UART1_TX_BUFFER_SIZE);
     #endif
 }
 
void uartSetRxHandler(u08 nUart, void (*rx_func)(unsigned char c))
 {
     // make sure the uart number is within bounds
     if(nUart < 2)
     {
         // set the receive interrupt to run the supplied user function
         UartRxFunc[nUart] = rx_func;
     }
 }
 
void uartSetBaudRate(u08 nUart, u32 baudrate)
 {
     // calculate division factor for requested baud rate, and set it
     u08 baudrateDiv;
     baudrateDiv = (u08)((F_CPU+(baudrate*8L))/(baudrate*16L)-1);
     if(nUart)
         outb(UBRR1L, baudrateDiv);
     else
         outb(UBRR0L, baudrateDiv);
 }
 
cBuffer* uartGetRxBuffer(u08 nUart)
 {
     // return rx buffer pointer
     return &uartRxBuffer[nUart];
 }
 
cBuffer* uartGetTxBuffer(u08 nUart)
 {
     // return tx buffer pointer
     return &uartTxBuffer[nUart];
 }
 
void uartSendByte(u08 nUart, u08 txData)
 {
     // wait for the transmitter to be ready
 //  while(!uartReadyTx[nUart]);
     // send byte
     if(nUart)
     {
         while(!(UCSR1A & (1<<UDRE1)));//while(!(UCSR1A & (1<<UDRE)));
         outb(UDR1, txData);
     }
     else
     {
         while(!(UCSR0A & (1<<UDRE0)));//      while(!(UCSR0A & (1<<UDRE)));
         outb(UDR0, txData);
     }
     // set ready state to FALSE
     uartReadyTx[nUart] = FALSE;
 }
 
void uart0SendByte(u08 data)
 {
     // send byte on UART0
     uartSendByte(0, data);
 }
 
void uart1SendByte(u08 data)
 {
     // send byte on UART1
     uartSendByte(1, data);
 }
 
int uart0GetByte(void)
 {
     // get single byte from receive buffer (if available)
     u08 c;
     if(uartReceiveByte(0,&c))
         return c;
     else
         return -1;
 }
 
int uart1GetByte(void)
 {
     // get single byte from receive buffer (if available)
     u08 c;
     if(uartReceiveByte(1,&c))
         return c;
     else
         return -1;
 }
 
 
u08 uartReceiveByte(u08 nUart, u08* rxData)
 {
     // make sure we have a receive buffer
     if(uartRxBuffer[nUart].size)
     {
         // make sure we have data
         if(uartRxBuffer[nUart].datalength)
         {
             // get byte from beginning of buffer
             *rxData = bufferGetFromFront(&uartRxBuffer[nUart]);
             return TRUE;
         }
         else
             return FALSE;           // no data
     }
     else
         return FALSE;               // no buffer
 }
 
 void uartFlushReceiveBuffer(u08 nUart)
 {
     // flush all data from receive buffer
     bufferFlush(&uartRxBuffer[nUart]);
 }
 
 u08 uartReceiveBufferIsEmpty(u08 nUart)
 {
     return (uartRxBuffer[nUart].datalength == 0);
 }
 
 void uartAddToTxBuffer(u08 nUart, u08 data)
 {
     // add data byte to the end of the tx buffer
     bufferAddToEnd(&uartTxBuffer[nUart], data);
 }
 
 void uart0AddToTxBuffer(u08 data)
 {
     uartAddToTxBuffer(0,data);
 }
 
 void uart1AddToTxBuffer(u08 data)
 {
     uartAddToTxBuffer(1,data);
 }
 
 void uartSendTxBuffer(u08 nUart)
 {
     // turn on buffered transmit
     uartBufferedTx[nUart] = TRUE;
     // send the first byte to get things going by interrupts
     uartSendByte(nUart, bufferGetFromFront(&uartTxBuffer[nUart]));
 }
 
 u08 uartSendBuffer(u08 nUart, char *buffer, u16 nBytes)
 {
     register u08 first;
     register u16 i;
 
     // check if there's space (and that we have any bytes to send at all)
     if((uartTxBuffer[nUart].datalength + nBytes < uartTxBuffer[nUart].size) && nBytes)
     {
         // grab first character
         first = *buffer++;
         // copy user buffer to uart transmit buffer
         for(i = 0; i < nBytes-1; i++)
         {
             // put data bytes at end of buffer
             bufferAddToEnd(&uartTxBuffer[nUart], *buffer++);
         }
 
         // send the first byte to get things going by interrupts
         uartBufferedTx[nUart] = TRUE;
         uartSendByte(nUart, first);
         // return success
         return TRUE;
     }
     else
     {
         // return failure
         return FALSE;
     }
 }
 
 // UART Transmit Complete Interrupt Function
 void uartTransmitService(u08 nUart)
 {
     // check if buffered tx is enabled
     if(uartBufferedTx[nUart])
     {
         // check if there's data left in the buffer
         if(uartTxBuffer[nUart].datalength)
         {
             // send byte from top of buffer
             if(nUart)
                 //outb(UDR1,  bufferGetFromFront(&uartTxBuffer[1]) );
					 UDR1=bufferGetFromFront(&uartTxBuffer[1]) ;
             else
                 //outb(UDR0,  bufferGetFromFront(&uartTxBuffer[0]) );
                  UDR0=bufferGetFromFront(&uartTxBuffer[0]) ;
         }
         else
         {
             // no data left
             uartBufferedTx[nUart] = FALSE;
             // return to ready state
             uartReadyTx[nUart] = TRUE;
         }
     }
     else
     {
         // we're using single-byte tx mode
         // indicate transmit complete, back to ready
         uartReadyTx[nUart] = TRUE;
     }
 }
 
 // UART Receive Complete Interrupt Function
 void uartReceiveService(u08 nUart)
 {
     u08 c;
     // get received char
     if(nUart)
         c = UDR1;//inb(UDR1);
     else
         c = UDR0;//inb(UDR0);
 
     // if there's a user function to handle this receive event
     if(UartRxFunc[nUart])
     {
         // call it and pass the received data
         UartRxFunc[nUart](c);
     }
     else
     {
         // otherwise do default processing
         // put received char in buffer
         // check if there's space
         if( !bufferAddToEnd(&uartRxBuffer[nUart], c) )
         {
             // no space in buffer
             // count overflow
             uartRxOverflow[nUart]++;
         }
     }
 }
 /*
//中斷定義 
 
UART_INTERRUPT_HANDLER(SIG_UART0_TRANS)      
 {
     // service UART0 transmit interrupt
     uartTransmitService(0);
 }
 
UART_INTERRUPT_HANDLER(SIG_UART1_TRANS)      
 {
     // service UART1 transmit interrupt
     uartTransmitService(1);
 }
 
UART_INTERRUPT_HANDLER(SIG_UART0_RECV)      
 {
     // service UART0 receive interrupt
     uartReceiveService(0);
 }
 
UART_INTERRUPT_HANDLER(SIG_UART1_RECV)      
 {
     // service UART1 receive interrupt
     uartReceiveService(1);
 }

*/


//this function convert char to ascii
//char2hex 把字符型轉變成ACSII
char char2hex(char t1)
{
if((t1>=00) &&(t1<=0x09))t1=t1+0x30;//'0'--'9'
else 
{
 
 if((t1>=0x0a)&&(t1<=0x0f))//'A'--'F'
 t1=t1-0x0a+0x61;
}
return t1;
}

void sendinthex0(char c)
{

char t2=0;

t2=(c%256)/16;//templ&0xf0;
//t2=t2>>8;
UDR0 = char2hex(t2);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

t2=(c%256)%16;//templ&0x0f;
UDR0 = char2hex(t2);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

}
//sendinthex1把整型轉化成4個ASCII輸出
void sendinthex1(int c)
{
char temph=0,templ=0;
char t1=0,t2=0;

temph=c/256;
templ=c%256;

t1=(c/256)/16;
//t1=t1>>8;
UDR0 = char2hex(t1);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

t1=(c/256)%16;
UDR0 = char2hex(t1);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

t2=(c%256)/16;//templ&0xf0;
//t2=t2>>8;
UDR0 = char2hex(t2);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

t2=(c%256)%16;//templ&0x0f;
UDR0 = char2hex(t2);
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

}


//發送字符
void sendchar1(char c) // 發送 
{
UDR0 = c;
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;
}



//發送整型常數
void sendint1( int c) // 發送 
{
UDR0 = (c&0xff00)>>8;
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;

UDR0 = c&0xff;
while(!(UCSR0A & 0x40));
UCSR0A |=0x40;
}

//發送字符串函數
void sendstring1(unsigned char * txbuf) // 發送 
{
unsigned int j;
for (j = 0; *txbuf; j++, txbuf++)sendchar1(*txbuf);
//for(;*txbuf!='/0';txbuf++)

}

//UART0 initialisation
// desired baud rate:115200
// actual baud rate:111111 (3.7%)
// char size: 8 bit
// parity: Disabled

void uart0_init(void)
{
 #ifdef MCUBAUD9600
// UBRRL = (fosc / 16 / (baud + 1)) % 256; 
// UBRRH = (fosc / 16 / (baud + 1)) / 256; 
 UCSR0B = 0x00; //disable while setting baud rate
 UCSR0A = 0x00;
 UCSR0C = 0x06;
 UBRR0L = 0x67; //set baud rate lo
 UBRR0H = 0x00; //set baud rate hi
 UCSR0B = 0x18;
#else 
//baud115200
 UCSR0B = 0x00; //disable while setting baud rate
 UCSR0A = 0x00;
 UCSR0C = 0x06;
 UBRR0L = (F_CPU / 16 / (baud + 1)) % 256;//0x03;//0x08; //set baud rate lo
 UBRR0H = (F_CPU / 16 / (baud + 1)) / 256;//0x00; //set baud rate hi
 UCSR0B = 0x18;//0x98;
#endif 
 /*
//115200

 UCSR0B = 0x00; //disable while setting baud rate
 UCSR0A = 0x00;
 UCSR0C = 0x06;

// UBRRL = (fosc / 16 / (baud + 1)) % 256; 
// UBRRH = (fosc / 16 / (baud + 1)) / 256; 

 UBRR0L = (F_CPU / 16 / (baud + 1)) % 256;//0x03;//0x08; //set baud rate lo
 UBRR0H = (F_CPU / 16 / (baud + 1)) / 256;//0x00; //set baud rate hi
 UCSR0B = 0x18;//0x98;
 */
}

//UART1 initialisation
// desired baud rate:115200
// actual baud rate:111111 (3.7%)
// char size: 8 bit
// parity: Disabled
void uart1_init(void)
{
 
#ifdef MCUBAUD9600
// UBRRL = (fosc / 16 / (baud + 1)) % 256; 
// UBRRH = (fosc / 16 / (baud + 1)) / 256; 
 UCSR1B = 0x00; //disable while setting baud rate
 UCSR1A = 0x00;
 UCSR1C = 0x06;
 UBRR1L = 0x67; //set baud rate lo
 UBRR1H = 0x00; //set baud rate hi
 UCSR1B = 0x18;
#else 
//baud115200
 UCSR1B = 0x00; //disable while setting baud rate
 UCSR1A = 0x00;
 UCSR1C = 0x06;
 UBRR1L = (F_CPU / 16 / (baud + 1)) % 256;//0x03;//0x08; //set baud rate lo
 UBRR1H = (F_CPU / 16 / (baud + 1)) / 256;//0x00; //set baud rate hi
 UCSR1B = 0x18;//0x98;
#endif 
}
signed int debug_check_rx(void)
{
return 1;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一级片网址| 亚洲欧美国产77777| ...xxx性欧美| 老汉av免费一区二区三区| 91伊人久久大香线蕉| 久久夜色精品一区| 日本美女一区二区| 91丝袜国产在线播放| 26uuu国产在线精品一区二区| 亚洲精品免费看| 成人av在线播放网址| 日韩女优电影在线观看| 亚洲已满18点击进入久久| 国产伦理精品不卡| 日韩三级免费观看| 偷拍亚洲欧洲综合| 欧美最新大片在线看| 成人欧美一区二区三区| 国产精品一品二品| 久久免费看少妇高潮| 热久久一区二区| 717成人午夜免费福利电影| 亚洲黄色免费网站| 91久久精品一区二区二区| 亚洲欧洲日韩在线| 成人国产精品免费观看视频| 国产欧美日韩中文久久| 狠狠色丁香九九婷婷综合五月| 日韩三级视频在线看| 蜜臀av一区二区在线观看| 欧美精品视频www在线观看 | 亚洲天堂2014| 色先锋资源久久综合| 亚洲人成小说网站色在线| 99久久精品国产导航| 亚洲欧美国产毛片在线| 欧洲国内综合视频| 午夜精品福利一区二区三区蜜桃| 欧美日韩日日摸| 热久久一区二区| 久久综合色之久久综合| 国产精品综合二区| 中文在线资源观看网站视频免费不卡| 国产成人夜色高潮福利影视| 国产欧美一区二区在线| 91在线porny国产在线看| 一区二区三区成人| 91精品国产综合久久婷婷香蕉| 日本最新不卡在线| 久久免费国产精品| 91麻豆自制传媒国产之光| 一区二区欧美国产| 4hu四虎永久在线影院成人| 激情综合色播五月| 中文字幕+乱码+中文字幕一区| 色综合久久综合网97色综合| 午夜伦理一区二区| 国产视频亚洲色图| 色94色欧美sute亚洲13| 蜜臀精品一区二区三区在线观看 | 日韩欧美123| a在线播放不卡| 污片在线观看一区二区| 国产欧美一区二区在线| 欧美性高清videossexo| 狠狠色综合日日| 一区二区在线观看av| 欧美www视频| 97久久人人超碰| 六月婷婷色综合| 亚洲欧美国产77777| 日韩欧美亚洲一区二区| 日本高清不卡一区| 国产一区二区三区美女| 亚洲图片一区二区| 国产精品色婷婷| 欧美一级二级三级蜜桃| 99久久久免费精品国产一区二区 | 91精品国产综合久久香蕉麻豆 | 中文字幕久久午夜不卡| 欧美老肥妇做.爰bbww| 国产成人高清在线| 免费在线观看精品| 一区二区三区在线观看动漫| 日韩美女视频一区二区在线观看| 91女神在线视频| 国产精品 欧美精品| 日韩专区欧美专区| 亚洲欧洲av一区二区三区久久| 日韩欧美一区中文| 欧美色精品在线视频| 99热这里都是精品| 国产精品一线二线三线精华| 午夜精品久久久久久久久久久 | 国产视频一区二区在线观看| 欧美精品tushy高清| 色欧美日韩亚洲| 成人av动漫在线| 成人妖精视频yjsp地址| 国产一区欧美日韩| 日本视频免费一区| 五月天一区二区| 一区二区高清免费观看影视大全| 国产精品免费看片| 中文欧美字幕免费| 国产欧美精品一区二区三区四区 | 亚洲人成网站影音先锋播放| 国产精品色一区二区三区| 国产三级精品视频| 日本一区二区三区dvd视频在线| 91麻豆精品国产无毒不卡在线观看| 色婷婷综合五月| 91社区在线播放| 日本韩国一区二区三区视频| 一本色道久久综合狠狠躁的推荐 | 不卡电影免费在线播放一区| 国产精品白丝av| 国产成人在线视频网站| 国产精品白丝av| 不卡一二三区首页| 色成人在线视频| 欧美日韩在线播放一区| 欧美丰满一区二区免费视频 | 欧美视频日韩视频在线观看| 欧美性xxxxxx少妇| 7777精品伊人久久久大香线蕉完整版 | 欧美影视一区在线| 欧美精品aⅴ在线视频| 欧美一区二区三区色| 日韩女优毛片在线| 日本一区二区三区免费乱视频| 国产精品动漫网站| 亚洲福利视频三区| 久久精品久久综合| 国产盗摄一区二区| 色哟哟精品一区| 日韩西西人体444www| 国产日韩精品一区二区三区 | 欧美亚洲国产一区在线观看网站| 欧美无砖砖区免费| 欧美精品一区二区三区很污很色的| 久久久美女艺术照精彩视频福利播放| 国产亚洲欧洲997久久综合| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 亚洲另类在线一区| 男人的天堂亚洲一区| 成人免费高清在线| 8x福利精品第一导航| 国产亚洲人成网站| 亚洲v中文字幕| 国产精品夜夜嗨| 欧美日韩色一区| 中文av一区二区| 午夜日韩在线电影| 成人国产一区二区三区精品| 欧美美女bb生活片| 国产精品美女久久久久高潮| 视频一区二区欧美| 不卡的av中国片| 欧美成人高清电影在线| 亚洲视频香蕉人妖| 国产资源在线一区| 欧美日韩一区二区不卡| 国产精品理论片在线观看| 日本中文字幕一区二区视频| 成人看片黄a免费看在线| 制服丝袜一区二区三区| 综合久久国产九一剧情麻豆| 日本成人中文字幕在线视频| 91美女在线看| 欧美极品美女视频| 免费成人在线影院| 欧美日韩国产一级片| 中文字幕日韩精品一区| 国产一区二区三区四区五区入口 | 精品无人区卡一卡二卡三乱码免费卡| 99re热这里只有精品视频| 久久久久久麻豆| 五月婷婷综合激情| 欧美视频在线观看一区二区| 欧美国产综合一区二区| 国产美女视频91| 欧美成人r级一区二区三区| 亚洲国产中文字幕在线视频综合| av高清不卡在线| 国产精品乱码人人做人人爱 | 国产无人区一区二区三区| 免费精品视频最新在线| 欧美日本国产一区| 亚洲一区免费视频| 日本乱人伦一区| 亚洲激情五月婷婷| 91免费视频观看| 国产精品美女一区二区| 大胆欧美人体老妇| 国产精品高清亚洲| 99re亚洲国产精品| 亚洲欧美另类在线| 欧美中文字幕一区二区三区 | 亚洲欧美一区二区久久|