Mercurial > templog
diff simple_ds18b20.c @ 20:878be5e353a0
Untested - calculate crc in uart_putchar
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 22 May 2012 23:23:38 +0800 |
parents | 4838bfcb3504 |
children | ca08442635ca |
line wrap: on
line diff
--- a/simple_ds18b20.c Tue May 22 21:32:52 2012 +0800 +++ b/simple_ds18b20.c Tue May 22 23:23:38 2012 +0800 @@ -126,7 +126,7 @@ } static void -printhex_nibble(const unsigned char b) +printhex_nibble(const unsigned char b, FILE *stream) { unsigned char c = b & 0x0f; if ( c > 9 ) { @@ -135,26 +135,26 @@ else { c += '0'; } - putchar(c); + fputc(c, stream); } void -printhex_byte( const unsigned char b ) +printhex_byte(const unsigned char b, FILE *stream) { - printhex_nibble( b >> 4 ); - printhex_nibble( b ); + printhex_nibble( b >> 4, stream); + printhex_nibble( b, stream); } void -printhex(uint8_t *id, uint8_t n) +printhex(uint8_t *id, uint8_t n, FILE *stream) { for (uint8_t i = 0; i < n; i++) { if (i > 0) { - putchar(' '); + fputc(' ', stream); } - printhex_byte(id[i]); + printhex_byte(id[i], stream); } } @@ -190,7 +190,7 @@ { printf_P(PSTR("CRC fail")); } - printhex(id, OW_ROMCODE_SIZE); + printhex(id, OW_ROMCODE_SIZE, stdout); printf_P(PSTR(" %d.%d ÂșC\n"), decicelsius/10, decicelsius % 10); } printf_P(PSTR("Done sensors\n"));