AVR Z-LINKŪ


usart.h File Reference


Detailed Description

This is the header file for the usart.c.

Application note:
AVR414: User's Guide - ATAVRRZ502 - Accessory Kit
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
Revision
1.2
RCSfile
serialInterface.h,v
Date
2006/09/15 17:02:44

Definition in file usart.h.

#include <stdbool.h>
#include <stdint.h>
#include "compiler.h"

Include dependency graph for usart.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DISABLE_RECEIVE_COMPLETE_INTERRUPT   ( UCSR0B &= ~( 1 << RXCIE0 ) )
#define DISABLE_RECEIVER   ( UCSR0B &= ~( 1 << RXEN0 ) )
#define DISABLE_TRANSMITTER   ( UCSR0B &= ~( 1 << TXEN0 ) )
#define ENABLE_RECEIVE_COMPLETE_INTERRUPT   ( UCSR0B |= ( 1 << RXCIE0 ) )
#define ENABLE_RECEIVER   ( UCSR0B |= ( 1 << RXEN0 ) )
#define ENABLE_TRANSMITTER   ( UCSR0B |= ( 1 << TXEN0 ) )

Enumerations

enum  baudRate_t { BR_9600 = 0x33, BR_19200 = 0x19, BR_38400 = 0x0C }
 Enumeration that defines the available baud rates for
the serial interface. The values cana be found in the datasheet on page 233. More...

Functions

void uartInitialization (const baudRate_t rate)
 Initialize USART0 8-N-1.
void uartSendSymbol (const uint8_t symbol)
 Send one symbol on the serial line.


Define Documentation

#define DISABLE_RECEIVE_COMPLETE_INTERRUPT   ( UCSR0B &= ~( 1 << RXCIE0 ) )

Disables an interrupt each time the receiver completes a symbol.

Definition at line 42 of file usart.h.

#define DISABLE_RECEIVER   ( UCSR0B &= ~( 1 << RXEN0 ) )

Disables receiver.

Definition at line 36 of file usart.h.

#define DISABLE_TRANSMITTER   ( UCSR0B &= ~( 1 << TXEN0 ) )

Disables transmitter.

Definition at line 39 of file usart.h.

#define ENABLE_RECEIVE_COMPLETE_INTERRUPT   ( UCSR0B |= ( 1 << RXCIE0 ) )

Enables an interrupt each time the receiver completes a symbol.

Definition at line 41 of file usart.h.

Referenced by uartInitialization().

#define ENABLE_RECEIVER   ( UCSR0B |= ( 1 << RXEN0 ) )

Enables receiver.

Definition at line 35 of file usart.h.

Referenced by uartInitialization().

#define ENABLE_TRANSMITTER   ( UCSR0B |= ( 1 << TXEN0 ) )

Enables transmitter.

Definition at line 38 of file usart.h.

Referenced by uartInitialization().


Enumeration Type Documentation

enum baudRate_t

Enumeration that defines the available baud rates for
the serial interface. The values cana be found in the datasheet on page 233.

Note:
The members should not be altered. This is possibly harmful for
setting of the baud rate registers in serialInterfaceInitialization.
Enumerator:
BR_9600  Sets the baud rate to 9600.
BR_19200  Sets the baud rate to 19200.
BR_38400  Sets the baud rate to 38400.

Definition at line 52 of file usart.h.

00052             {
00053   
00054   BR_9600  = 0x33, 
00055   BR_19200 = 0x19, 
00056   BR_38400 = 0x0C  
00057 }baudRate_t;


Function Documentation

void uartInitialization ( const baudRate_t  rate  ) 

Initialize USART0 8-N-1.

Parameters:
rate Baudrate to run the USART0 at. The tested rates are: 9600, 19200 and 38400.

Definition at line 39 of file usart.c.

References ENABLE_RECEIVE_COMPLETE_INTERRUPT, ENABLE_RECEIVER, and ENABLE_TRANSMITTER.

Referenced by serialInterfaceInitialization().

00039                                                 {
00040   
00041   //Initialize USART module.
00042   UBRR0H = 0x00;
00043   UBRR0L = rate;
00044   
00045   //Enable USART transmitter module. Always on.
00046   ENABLE_RECEIVER;
00047   ENABLE_TRANSMITTER;
00048         
00049   //8-N-1.
00050   UCSR0C |= ( 1 << UCSZ01 ) | ( 1 << UCSZ00 ); 
00051   
00052   ENABLE_RECEIVE_COMPLETE_INTERRUPT;
00053         
00054   return;
00055 }

void uartSendSymbol ( const uint8_t  symbol  ) 

Send one symbol on the serial line.

This function passes one symbol (8 bits) to the USART module on the AVR.

Note:
serialInterfaceInitialization must be called first.
Parameters:
symbol Symbol to be sent.

Definition at line 66 of file usart.c.

Referenced by sendSymbol().

00066                                            {
00067   
00068         //Wait until the USART module is ready to
00069         //transmit a new symbol.
00070         for( ; !( UCSR0A & ( 1 << UDRE0 ) ); ){
00071     
00072         ;
00073         }
00074         
00075         //Put symbol in data register.
00076         UDR0 = symbol;
00077   
00078         return;
00079 }

@DOC_TITLE@
Generated on Sat Dec 2 16:05:51 2006 for AVR414 User's Guide - ATAVRRZ502 - Accessory Kit by doxygen 1.4.7