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.
|
|
|
|
/*
|
|
|
|
|
* USART0Custom.c
|
|
|
|
|
*
|
|
|
|
|
* Created: 26.10.2023 17:37:08
|
|
|
|
|
* Author: Katya
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "USART0Custom.h"
|
|
|
|
|
|
|
|
|
|
void USART_Init (uint16_t speed) {
|
|
|
|
|
// <20><>. <20> <20><>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UBRR0H = 0;
|
|
|
|
|
UBRR0L = (uint8_t)(speed);
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
|
|
|
|
|
// 8 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 2 <20><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD>
|
|
|
|
|
UCSR0C = (1<<USBS0) | (3<<UCSZ00);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void USART_Transmit (uint8_t data) {
|
|
|
|
|
while (!(UCSR0A & (1<<UDRE0))); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
UDR0 = data; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t USART_Receive() {
|
|
|
|
|
while (!(UCSR0A & (1 << RXC0))); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return UDR0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t USART_DataAvailable() {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
return (UCSR0A & (1 << RXC0)) ? 1 : 0;
|
|
|
|
|
}
|