Xmega Application Note | |||||
00001 /***************************************************************************** 00002 * 00003 * Atmel Corporation 00004 * 00005 * File : serial.c 00006 * Compiler : IAR C 3.10C Kickstart, AVR-GCC/avr-libc(>= 1.2.5) 00007 * Revision : $Revision: 1.7 $ 00008 * Date : $Date: Tuesday, June 07, 200 $ 00009 * Updated by : $Author: raapeland $ 00010 * 00011 * Support mail : avr@atmel.com 00012 * 00013 * Target platform : All AVRs with bootloader support 00014 * 00015 * AppNote : AVR109 - Self-programming 00016 * 00017 * Description : UART communication routines 00018 ****************************************************************************/ 00019 #include "defines.h" 00027 void initbootuart(void) 00028 { 00029 UART_PORT.DIRSET |= UART_TX_PIN; 00030 BAUD_RATE_LOW_REG = BRREG_VALUE; 00031 UART_CONTROL_REG = (1 << ENABLE_RECEIVER_BIT) | 00032 (1 << ENABLE_TRANSMITTER_BIT); // enable receive and transmit 00033 } 00034 00043 void sendchar(unsigned char c) 00044 { 00045 UART_DATA_REG = c; // prepare transmission 00046 while (!(UART_STATUS_REG & (1 << TRANSMIT_COMPLETE_BIT))); 00047 // wait until byte sendt 00048 UART_STATUS_REG |= (1 << TRANSMIT_COMPLETE_BIT); // delete TXCflag 00049 } 00050 00060 unsigned char recchar(void) 00061 { 00062 unsigned char ret; 00063 while(!(UART_STATUS_REG & (1 << RECEIVE_COMPLETE_BIT))); // wait for data 00064 ret = UART_DATA_REG; 00065 return ret; 00066 } 00067
Generated on Fri Mar 27 14:05:25 2009 for AVR1605: XMEGA BOOTLOADER by ![]() |