Open Sint  3.4-2
Functions
uart.c File Reference

UART IO functions. More...

#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include "uart.h"
Include dependency graph for uart.c:

Functions

 ISR (USART0_RX_vect)
 Interrupt rx. More...
 
struct uartStructuart_init (const uint8_t port)
 
void uart_shutdown (const uint8_t port)
 shutdown the usart port.
 
void uart_get_msg (const uint8_t port, char *s)
 
void uart_putchar (const uint8_t port, const char c)
 
void uart_printstr (const uint8_t port, const char *s)
 

Detailed Description

UART IO functions.

Bug:
only partially implemented multi-port. Many things are still on port0 only.

Function Documentation

◆ ISR()

ISR ( USART0_RX_vect  )

Interrupt rx.

This function is triggered every incoming char from the serial port.

First copy the rx char from the device rx buffer.

if we fill the rx buffer, which should never happens, then clear the buffer index, the buffer contents and restart.

if the rxc is a valid char

  • copy the rx char to rx buffer
    • increment the pointer to the next slot.

◆ uart_get_msg()

void uart_get_msg ( const uint8_t  port,
char *  s 
)

get the message from the RX buffer.

port the serial port. s the string to copy the message to.

Bug:

multiport not implemented.

this function should be atomic, cannot be interrupted while resetting the pointer.

◆ uart_printstr()

void uart_printstr ( const uint8_t  port,
const char *  s 
)

Send a C (NUL-terminated) string to the serial port.

port the serial port. s the string to send.

◆ uart_putchar()

void uart_putchar ( const uint8_t  port,
const char  c 
)

Send character c to the serial port, wait until tx holding register is empty.

port the serial port. c the char to send.