#include "uart.h"
#define LED1 1
#define LED2 2
#define LED3 4
uint8_t value =0;
int main(void){
DDRB = ( 0 << RxD ) | ( 1 << TxD ); // Port Configuration
PORTB |= ( 1 << TxD ); // UP Transmitting line
Init_UART_Receiving(); // Setting Receiver Interrupt
//Send_BEEP;
uint16_t counter = 0;
uint16_t c2 = 0;
UART_Send_PGM( ( char* ) PGM_String0 );// Send_CR;
UART_Send_PGM( ( char* ) PGM_String1 ); //Send_CR;
UART_Send_PGM( ( char* ) PGM_String2 );// Send_CR;
//Send_CR;
while (1) {
if ( Rx_flags & 0x80 ) { // Test receiving flag
// Send_CLS; // Send clear terminal screen code
// Send_CR; // Send new terminal string
UART_Send("Receive: "); // Send description
UART_Send(Rx_Buf); // Send received buffer
Rx_flags = 0; // Clear receiving flag
}
if ( !(++counter % 4000)) { // Simple timer
value=Rx_Buf[0]-48;
UART_Send(b_2_a(value)); UART_Send(" "); // Send byte in decimal representation //
}
if (value==1){PORTB |=(1<<LED1);} //led1 on
else if (value==2){PORTB &= ~(1<<LED1);} //led2 off
else if (value==3){PORTB |=(1<<LED2);}
else if (value==4){PORTB &= ~(1<<LED2);}
else if (value==5){PORTB |=(1<<LED3);}
else if (value==6){PORTB &= ~(1<<LED3);}
else if (value==7){PORTB = ~0b00000000;} //all on
else if (value==8){PORTB &= 0b00001001;} //all off
}
}
/*
UART_Send(b_2_bin(c2)); UART_Send(" "); // Send byte in binary representation
UART_Send(b_2_hex(c2)); UART_Send(" "); // Send byte in hex representation
UART_Send(b_2_a(c2)); UART_Send(" "); // Send byte in decimal representation
UART_Send(w_2_a(c2++)); // Send word in decimal representation
Send_CR;
counter = 0;
}
// if (++counter==0) c2++; // Simple ping timer
// if ((c2==15)&&(counter==0)) {UART_Send(".");c2=0;}
}
}*/