- AVRマイコン総合スレ Part41
574 :774ワット発電中さん[sage]:2019/01/22(火) 23:14:01.59 ID:SUk48xYi - >>572
static int stdPutc( char c, FILE *stream ); static FILE suStream = FDEV_SETUP_STREAM( stdPutc, NULL, _FDEV_SETUP_WRITE ); static int stdPutc( char c, FILE *stream ) { while ( !( UCSRA & (1<<UDRE) ) ); UDR = c; return 0; } int main( void ) { stdout = &suStream; printf_P( PSTR("Hello world") ); } ヘッダファイルとUSARTの初期化は省略しているので注意。(あくまでも標準出力を設定するサンプルなので)
|