TTK4155 Lab Node 1
Term project in the NTNU course TTK4155 Embedded and Industrial Computer Systems Design
Loading...
Searching...
No Matches
uart.c File Reference
#include <avr/interrupt.h>
#include <avr/io.h>
#include <stdint.h>
#include <util/delay.h>
#include "uart.h"

Go to the source code of this file.

Functions

int USART_init (struct USART_config *config)
 Initialize USART0 with the given configuration.
int USART_endl (void)
 Transmit CRLF as end-of-line.
int USART_Transmit (unsigned char data)
 Transmit a single byte via USART0.
int USART_SendString (char *data)
int USART_Receive (void)
 Receive one byte from USART0. (Minimal implementation.).
int USART_ReceiveHandler ()
 Handle incoming received bytes and simple command echoing.

Variables

char receive_buf = 0

Function Documentation

◆ USART_SendString()

int USART_SendString ( char * data)

Definition at line 51 of file uart.c.

51 {
52 int status;
53 int counter = 0;
54 while (data[counter] != '\0') {
55 if (data[counter] == '\n') {
56 status = USART_Transmit('\x0D');
57 status = USART_Transmit('\x0A');
58 } else {
59 status = USART_Transmit(data[counter]);
60 }
61 counter++;
62 }
63 return status;
64}
int USART_Transmit(unsigned char data)
Transmit a single byte via USART0.
Definition uart.c:39

Referenced by USART_ReceiveHandler().

Variable Documentation

◆ receive_buf

char receive_buf = 0

Definition at line 9 of file uart.c.

Referenced by USART_Receive(), and USART_ReceiveHandler().