Andes Workshop
http://forum.andestech.com/

sio_printf程式分享
http://forum.andestech.com/viewtopic.php?f=6&t=28
Page 1 of 1

Author:  cindy [ Tue Mar 15, 2011 2:56 pm ]
Post subject:  sio_printf程式分享

這個程式是一個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做修改。

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/