|
|
|
@ -30,7 +30,7 @@ uart_init(void) {
|
|
|
|
|
(1<<RXCIE0); /* enable Receive interrupts */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initiate read- and write-pointers */
|
|
|
|
|
/* Initiate read- and write-pointers with 0 */
|
|
|
|
|
pTxBuffer->Readpointer = 0;
|
|
|
|
|
pTxBuffer->Writepointer = 0;
|
|
|
|
|
pRxBuffer->Readpointer = 0;
|
|
|
|
@ -71,7 +71,7 @@ uart_send_byte(char c) {
|
|
|
|
|
UCSR0B |= (1<<TXCIE0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* when data (a data frame) is to be send */
|
|
|
|
|
/* when data (a data frame) is to be send (written to UDR0) */
|
|
|
|
|
ISR(USART0_TX_vect) {
|
|
|
|
|
/* check if the read and write pointer of the send buffer are not aligned
|
|
|
|
|
if not aligned -> read the next byte and write it to UDR0 register
|
|
|
|
@ -117,7 +117,7 @@ uart_get_data(void) {
|
|
|
|
|
if yes -> data is available and can be read */
|
|
|
|
|
if(pRxBuffer->Readpointer != pRxBuffer->Writepointer)
|
|
|
|
|
{
|
|
|
|
|
/* read a char from the buffer and increment the readpointer */
|
|
|
|
|
/* read a char from the buffer and increment the read pointer */
|
|
|
|
|
data = pRxBuffer->data[pRxBuffer->Readpointer++];
|
|
|
|
|
if(pRxBuffer->Readpointer >= SIZE_BUFFER){
|
|
|
|
|
pRxBuffer->Readpointer = 0;
|
|
|
|
|