Open Sint
3.4-2
|
UART IO functions. More...
#include <stdlib.h>
#include <string.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include "uart.h"
Functions | |
ISR (USART0_RX_vect) | |
Interrupt rx. More... | |
struct uartStruct * | uart_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) |
UART IO functions.
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
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.
multiport not implemented.
this function should be atomic, cannot be interrupted while resetting the pointer.
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.
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.