//----------------------------------------------------------------------------------- void s_printf (const char* str, ...) { va_list arp; int d, r, w, s, l; char tmp[20]; va_start(arp, str); while ((d = *str++) != 0) { if (d != '%') { Uart2_PutChar(d); continue; } d = *str++; w = r = s = l = 0; if (d == '0') { d = *str++; s = 1; } while ( '0' <= d && d <= '9' ) { w = w * 10 + (d - '0'); d = *str++; } if (s) w = -w; if (d == 'l') { l = 1; d = *str++; } if (!d) break; if (d == 's') { Uart2_Print(va_arg(arp, char *)); continue; } if (d == 'c') { Uart2_PutChar((char)va_arg(arp, int)); continue; } if (d == 'u') r = 10; if (d == 'd') r = -10; if (d == 'x') r = 16; if (d == 'b') r = 2; if (!r) break; if (l) { s_itoa(tmp, (long)va_arg(arp, long), r, w); } else { if (r > 0)
/******************************************************************************* * Function Name : Uart1_PutString * Description : print a string to the uart1 * Input : buf为发送数据的地址 , len为发送字符的个数 * Output : None * Return : None *******************************************************************************/ void Uart2_PutString(u8* buf , u8 len)//发送一个字符串 { u8 i; for(i=0;i<len;i++) { Uart2_PutChar(*buf++); } }