[an error occurred while processing this directive]
|
//
// ** InitUART -- the routine initiates the UART module
//
void InitUART(void)
{
UBRRL = UBRR_VALUE & 0xFF; // Set the Baud Rate register
UBRRH = UBRR_VALUE >> 8; //
UCSRB |= RXEN_BIT | TXEN_BIT; // Enable UART transiver
UCSRA |= RXC_BIT; // Reset pending interrupt request
UCSRB |= RXCIE_BIT; // Enable UART receiver interrupt
}
//
// ** ReceiveByte -- the function gets one byte from UART
//
char ReceiveByte(void)
{
while (!(IntFlags & UART_BIT)); // Wait for a data
IntFlags &= ~UART_BIT; // Reset rhe flag
return RxByte;
}
//
// ** TxByte -- the function sends one byte to UART
//
void TxByte(char _byte)
{
while (!(UCSRA & UDRE_BIT)); // Wait for the transmitter buffer is empty
UDR = _byte; // Transmit the data
}//
// **** UART interrupt handlers ***
//
// UART reciever handler
//
#pragma vector = USART_RXC_vect
__interrupt void RX_Int(void)
{
RxByte = UDR; // Get the just received byte
IntFlags |= UART_BIT; // and set the flag
}
E-mail: info@telesys.ru