weAut_01 / weAutSys    R 2.2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Defines | Functions | Variables
Basic serial communication drivers
+ + Low level system services + +

Overview

The primary target hardware for weAutSys is the automation controller weAut_01. It uses AVR's (second) UART1 as an exclusive SPI interface for the Ethernet chip. (All other SPI peripherals use the standard SPI / ISP interface.)

Thus only one UART, namely UART 0 (PD0, PD1 on ATmega 644 /1284) is available. It is handled by the driver software defined here in a way suitable for stdin, stdout and stderr as described in stdio.h. As there is only one UART handled here, just uart resp. UART is used as part of names, without any numbering like uart0, uart1 etc.

As weAutSys' system and user software is organised as cooperating protothreads no blocking is allowed in called (library) functions. (This is one of Protothreads' basic characteristics.)

So no input function defined / implemented here may block in any way. This especially holds for those (indirectly) called via stdio functions. Hence a character / byte input function must immediately return a valid code or an error respectively EOF.

The same is true for output. It must in no way hang on full buffers. Even in that situation (that can easily be avoided) it has to return discarding the output.

For suitable I/O functions see module Serial Communication.

Defines

#define FROM_BUFFER2UART()
 Driver helper.
#define SER_RECVBUF_EMPTY
 The serial input buffer is empty.
#define SER_RECVBUF_NOT_EMPTY
 The serial input buffer is not empty.
#define SER_SENDBUF_EMPTY
 The serial output buffer is empty.
#define SER_SENDBUF_NOT_EMPTY
 The serial output buffer is not empty.
#define UART_CAN_SEND
 UART (0) can get send data.

Functions

uint8_t uartClearOutBuffer (void)
 Clear the internal buffer for serial output.

Variables

uint8_t uartInBuf []
 The serial input buffer.
uint8_t uartInBufRi
 The serial input buffer read/get index.
uint8_t uartInBufWi
 The serial input buffer write/put index.
uint8_t uartOutBuf []
 The serial output buffer.
volatile uint8_t uartOutBufRi
 The serial output buffer read/get index.
volatile uint8_t uartOutBufWi
 The serial output buffer write/put index.

Define Documentation

#define FROM_BUFFER2UART ( )

Driver helper.

This is a low level helper macro for driver programming.
Warning: It is to be used by system software only and not outside atomic locks.

#define UART_CAN_SEND

UART (0) can get send data.

This evaluates to non 0 (true), if the transmit data register is empty.

The serial output buffer is not empty.

This evaluates to true, if the serial output buffer is NOT empty.

Examples:
main.c.

The serial output buffer is empty.

This evaluates to true, if the serial output buffer is empty.

The serial input buffer is empty.

This evaluates to true, if the serial input buffer is empty.

The serial input buffer is not empty.

This evaluates to true, if the serial input buffer is NOT empty.


Function Documentation

uint8_t uartClearOutBuffer ( void  )

Clear the internal buffer for serial output.

This function returns the number of characters forgotten. If 0 is returned the buffer was empty anyway.

This function is to be used to recover from buffer overrun or similar errors or to "forget the past" out of any other reasons.