x @Kurogaraさんの記事を非営利、研究調査で引用して移植しました。
目的
さらに容量に余裕がある場合
ちょつと違うがぞくに言うsprintfを使うというやつ
そもそも、標準シリアルを使えというのは、なし
参考
#include "mbed.h"
//Serial pc(USBTX, USBRX); // tx, rx
//Serial pc(SERIAL_TX, SERIAL_RX); //767
RawSerial pc(PA_2, PA_3); //010
int ns_printf(char* fmt, ...) {
char buff[256];
va_list args;
va_start(args, fmt);
int return_status = vsnprintf(buff, sizeof(buff), fmt, args);
va_end(args);
char *s = buff;
while (*s) pc.putc(*s++);
return return_status;
}
int main() {
char *ss1; //文字のポインター
int ii; //ループカウンター
//無限ループ
while(1) {
ss1="Hello World !\r\n";
ii=0; //ループカウンター
while(ss1[ii]!=0){
//一文字出力
pc.putc(ss1[ii]);ii++;
} //while
ns_printf("%d\n\r",1234);
//1秒の待ち
wait_ms(1000);
} //while
} //main
//容量削減
void error(const char* format, ...){}