You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
766 B
55 lines
766 B
|
|
#include "main.h"
|
|
|
|
#define DEBUG
|
|
|
|
#ifdef DEBUG
|
|
void tx( char data ){
|
|
while ( !( UCSR0A & (1<<UDRE0)) );
|
|
UDR0 = data;
|
|
}
|
|
|
|
void sendstr( char* str){
|
|
while(str[0]!=0){
|
|
tx(str[0]);
|
|
str++;
|
|
}
|
|
}
|
|
|
|
void sendunum(uint32_t num){
|
|
char text[11] = {0,0,0,0,0,0,0,0,0,0,0};
|
|
uint32_t tmp=1;
|
|
char leadingzero=0;
|
|
char digit=0;
|
|
char i;
|
|
if(num==0){
|
|
tx('0');
|
|
return;
|
|
}
|
|
for(i=1;i<=10;i++){
|
|
digit = '0'+((num/tmp)%10);
|
|
tmp*=10;
|
|
if(digit=='0'){
|
|
leadingzero++;
|
|
}else{
|
|
leadingzero=0;
|
|
}
|
|
text[10-i]=digit;
|
|
}
|
|
sendstr( text+leadingzero );
|
|
}
|
|
|
|
char rx( void ){
|
|
while ( !(UCSR0A & (1<<RXC0)) );
|
|
return UDR0;
|
|
}
|
|
#endif //DEBUG
|
|
|
|
int main(void) __attribute__((noreturn));
|
|
int __attribute__((OS_main)) main(void) {
|
|
sendstr("Hello");
|
|
for(;;){
|
|
|
|
}
|
|
}
|
|
|
|
|