bikegenerator/display/software/powerboard/src/utils.c

37 lines
768 B
C
Raw Normal View History

2013-06-11 12:47:29 +00:00
#include <avr/io.h>
#include <util/delay.h>
#include "uart.h"
2013-06-11 12:47:29 +00:00
void wait(uint8_t count) {
uint8_t i;
if(count == 0) count = 100;
for(i=0;i<count;i++) {
_delay_ms(10);
}
}
void uart_print_voltage(uint16_t x) {
uart_putc(48 + (x / 10000));
uart_putc(48 + (x % 10000 /1000));
uart_putc('.');
uart_putc(48 + (x % 1000 / 100 ));
//uart_putc(48 + (x % 100 / 10 ));
//uart_putc(48 + (x % 10));
}
2013-06-14 10:47:35 +00:00
void uart_print_uint8(uint8_t x) {
uart_putc(48 + (x / 100 ));
uart_putc(48 + (x % 100 / 10 ));
uart_putc(48 + (x % 10));
}
void uart_print_uint16(uint16_t x) {
uart_putc(48 + (x / 10000));
uart_putc(48 + (x % 10000 /1000));
uart_putc(48 + (x % 1000 / 100 ));
uart_putc(48 + (x % 100 / 10 ));
uart_putc(48 + (x % 10));
}
2013-06-11 12:47:29 +00:00