//**************************************** // シリアル掐蝸。掐蝸があるまで略つ //**************************************** uchar ReadCom(void){
do { WDR; } while(!(inp(UCSRA)&(1<<RXC))); return inp(UDR); }
//**************************************** // シリアル叫蝸 //**************************************** void WriteCom(uchar data){
do { ; } while(!(inp(UCSRA)&(1<<UDRE))); outp(data, UDR); }
//**************************************** // 1byteを16渴眶で山績 //**************************************** void WriteHex(uchar data){ uchar c;
c = (data>>4) + '0'; if (c > '9'){ c += 7; } WriteCom(c);
c = (data & 0x0f) + '0'; if (c > '9'){ c += 7; } WriteCom(c); }
//**************************************** // intを 10渴矢機誤恃垂 //**************************************** /* void ItoStr(uint i, uchar str[]){ char *p;
if (i >= 10000){ p = &str[5]; } else if (i >= 1000){ p = &str[4]; } else if (i >= 100){ p = &str[3]; } else if (i >= 10){ p = &str[2]; } else { p = &str[1]; } *p-- = 0;
do { *p-- = (i % 10) + '0'; i /= 10; } while(i); } */
//**************************************** // 蓋年矢機誤叫蝸 // 蝗脫毋¨ // char *s; // s = PSTR("Message OK.\n"); // WriteComMsg(s); //**************************************** void WriteComMsg(PGM_VOID_P msg){ char i; uchar c;
i = 0; while((c = (uchar)PRG_RDB(msg++)) != 0){ WriteCom(c); i++; } }
//**************************************** // バッファ矢機誤叫蝸 //**************************************** void WriteComStr(uchar *msg){ char i; uchar c;
i = 0; while((c = (uchar)(*msg++)) != 0){ WriteCom(c); i++; } }
|