40 lines
870 B
C
40 lines
870 B
C
|
#include <avr/io.h>
|
||
|
#include <util/delay.h>
|
||
|
#include "uart.h"
|
||
|
|
||
|
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));
|
||
|
}
|
||
|
|
||
|
void uart_print_int16(int16_t x) {
|
||
|
if(x <0) uart_putc('-');
|
||
|
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));
|
||
|
}
|
||
|
|
||
|
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));
|
||
|
}
|
||
|
|
||
|
|