X-Git-Url: http://git.droids-corp.org/?p=protos%2Fimu.git;a=blobdiff_plain;f=uart.c;h=3d218a5290ad840ac27811fb1f0780644934c2c6;hp=df5e1fdc89a9d747e1c50bafc7d0b95b91c0b955;hb=de6cbbfa24c5af2030ab1a46ee94bcc8b35910b9;hpb=b1352af6f340a1b878d46ed15b51d30eb3d3c36a;ds=sidebyside diff --git a/uart.c b/uart.c index df5e1fd..3d218a5 100644 --- a/uart.c +++ b/uart.c @@ -32,7 +32,7 @@ #define RXCIE RXCIE0 #define UCSRC UCSR0C -#define URSEL +#define URSEL #define UCSZ0 UCSZ00 #define UCSZ1 UCSZ01 #define UCSRC_SELECT 0 @@ -80,7 +80,7 @@ void uart_init() void uart_putc(uint8_t c) { if(c == '\n') - uart_putc('\r'); + uart_putc('\r'); /* wait until transmit buffer is empty */ while(!(UCSRA & (1 << UDRE))); @@ -93,15 +93,15 @@ void uart_putc_hex(uint8_t b) { /* upper nibble */ if((b >> 4) < 0x0a) - uart_putc((b >> 4) + '0'); + uart_putc((b >> 4) + '0'); else - uart_putc((b >> 4) - 0x0a + 'a'); + uart_putc((b >> 4) - 0x0a + 'a'); /* lower nibble */ if((b & 0x0f) < 0x0a) - uart_putc((b & 0x0f) + '0'); + uart_putc((b & 0x0f) + '0'); else - uart_putc((b & 0x0f) - 0x0a + 'a'); + uart_putc((b & 0x0f) - 0x0a + 'a'); } void uart_putw_hex(uint16_t w) @@ -123,15 +123,15 @@ void uart_putw_dec(uint16_t w) while(num > 0) { - uint8_t b = w / num; - if(b > 0 || started || num == 1) - { - uart_putc('0' + b); - started = 1; - } - w -= b * num; - - num /= 10; + uint8_t b = w / num; + if(b > 0 || started || num == 1) + { + uart_putc('0' + b); + started = 1; + } + w -= b * num; + + num /= 10; } } @@ -142,33 +142,33 @@ void uart_putdw_dec(uint32_t dw) while(num > 0) { - uint8_t b = dw / num; - if(b > 0 || started || num == 1) - { - uart_putc('0' + b); - started = 1; - } - dw -= b * num; - - num /= 10; + uint8_t b = dw / num; + if(b > 0 || started || num == 1) + { + uart_putc('0' + b); + started = 1; + } + dw -= b * num; + + num /= 10; } } void uart_puts(const char* str) { while(*str) - uart_putc(*str++); + uart_putc(*str++); } void uart_puts_p(PGM_P str) { while(1) { - uint8_t b = pgm_read_byte_near(str++); - if(!b) - break; + uint8_t b = pgm_read_byte_near(str++); + if(!b) + break; - uart_putc(b); + uart_putc(b); } } @@ -180,7 +180,7 @@ uint8_t uart_getc() sei(); while(!(UCSRA & (1 << RXC))) - sleep_mode(); + sleep_mode(); SREG = sreg; #else @@ -189,7 +189,7 @@ uint8_t uart_getc() uint8_t b = UDR; if(b == '\r') - b = '\n'; + b = '\n'; return b; }