Main Page   Modules   Data Structures   File List   Globals  

uart.c File Reference

Functions for serial communication. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/pgmspace.h>
#include "otos_cfg.h"
#include "otos_def.h"
#include "types.h"
#include "uart.h"

Go to the source code of this file.

Functions

void otosPrint (uint8_t *string)
 Send a string from RAM over the serial interface.

void otosPrint_P (PGM_P string)
 Send a string from program space over the serial interface.

void otosPutchar (uint8_t c)
 Send a char over the serial interface.

uint8_t otosGetchar (void)
 Read a char from the serial interface.

uint8_t otosUartAvail (void)
 Check if character are available in receive buffer.

 SIGNAL (SIG_UART_RECV)
 Serial Receive Interrupt.

void otosUartClear (void)
 Clear the serial receive buffer.

uint8_t otosPeekchar (void)
 Returns the latest char in serial receive buffer if one is available without removing it from the receive buffer.

uint8_t otosReadline (uint8_t *buffer, uint8_t len)
 Read one line.


Variables

unsigned char rx_buf [UART_BUF_SIZE]
unsigned char buf_read
unsigned char buf_write
volatile unsigned char buf_len


Detailed Description

Functions for serial communication.

Definition in file uart.c.


Function Documentation

uint8_t otosGetchar void   
 

Read a char from the serial interface.

If the receive buffer is empty, the function waits until a char is received.

Returns:
The read character

Definition at line 123 of file uart.c.

References otosUartAvail().

Referenced by otosReadline().

uint8_t otosPeekchar void   
 

Returns the latest char in serial receive buffer if one is available without removing it from the receive buffer.

Returns:
  • 0: no char available
  • else: the latest received character

Definition at line 234 of file uart.c.

References otosUartAvail().

void otosPrint uint8_t *    string
 

Send a string from RAM over the serial interface.

Parameters:
string String to send

Definition at line 60 of file uart.c.

References otosPutchar().

void otosPrint_P PGM_P    string
 

Send a string from program space over the serial interface.

Parameters:
string String to send

Definition at line 75 of file uart.c.

References otosPutchar().

void otosPutchar uint8_t    c [inline]
 

Send a char over the serial interface.

Parameters:
c Character to send

Definition at line 89 of file uart.c.

Referenced by otosPrint(), and otosPrint_P().

uint8_t otosReadline uint8_t *    buffer,
uint8_t    len
 

Read one line.

A line ends on a CR or a CR+LF (depending on definition of macro 'CRLF_IN') or when the maximum number of chars was received.

Parameters:
buffer Buffer for string
len Size of buffer
Returns:
Number of characters stored in buffer (without cr, crlf and ending '')

Definition at line 257 of file uart.c.

References otosGetchar().

uint8_t otosUartAvail void    [inline]
 

Check if character are available in receive buffer.

Returns:
Number of chars in receive buffer

Definition at line 151 of file uart.c.

Referenced by otosGetchar(), and otosPeekchar().

void otosUartClear void   
 

Clear the serial receive buffer.

The receive interrupt is disabled during this function

Definition at line 199 of file uart.c.

SIGNAL SIG_UART_RECV   
 

Serial Receive Interrupt.

Definition at line 170 of file uart.c.


Generated on Sat Jan 25 18:41:43 2003 for otOS by doxygen1.3-rc2