Andes Workshop

It is currently Thu Mar 28, 2024 11:18 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: sio_printf程式分享
PostPosted: Tue Mar 15, 2011 2:56 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
這個程式是一個uart輸出字串的範例,
printf()經過system call,而且它包含各種format轉換,使得程式很龐大。
所以我們改寫printf為sio_printf(),只有簡單的幾種輸出格式,
字串直接由UART的IO輸出。

下面的code中,主程式main()中,若系統尚未initial UART,
必須要執行uart_init();這一行。

Code:
#include <stdio.h>
#include "sio.h"

int main(void)
{
   int i;
   i = 0;
   
   //uart_init();
   while ( i < 1000 ) {
   sio_printf("%05d  hello! world!\n", i);
   i++;
   }
   return 0;
}


程式在這裡
Attachment:
sio_printf.zip [5.06 KiB]
Downloaded 1235 times


注意:您的系統的Uart可能不同,
這個範例是參考用,
請依您的UART做修改。


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group