AVR Z-LINKŪ


usart.c File Reference


Detailed Description

This files contains the functions for initializing and sending data using the USART0 of the AVR microcontroller.

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
callbacks.c,v
Date
2006/09/15 17:02:19

Definition in file usart.c.

#include "usart.h"

Include dependency graph for usart.c:

Go to the source code of this file.

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.


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