Xmega Application Note | |||||
#include "defines.h"
Go to the source code of this file.
Functions | |
void | initbootuart (void) |
Initializing UART communcation. | |
unsigned char | recchar (void) |
Receiving a character in UART communcation. | |
void | sendchar (unsigned char c) |
Transmitting a character UART communcation. |
void initbootuart | ( | void | ) |
Initializing UART communcation.
Generate UART initialisation section.
This function initializes the UART communication with generic parameters
As this is important function of initializing the UART, it has to be called prior to statr the communication.
Definition at line 27 of file serial.c.
References BAUD_RATE_LOW_REG, BRREG_VALUE, ENABLE_RECEIVER_BIT, ENABLE_TRANSMITTER_BIT, UART_CONTROL_REG, UART_PORT, and UART_TX_PIN.
Referenced by main().
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 }
unsigned char recchar | ( | void | ) |
Receiving a character in UART communcation.
Generate UART initialisation section.
This function receives a character in the UART communication and returns the received character to the called function.
This function is called whenever a single charater has to be received from the UART communication.
Definition at line 60 of file serial.c.
References RECEIVE_COMPLETE_BIT, UART_DATA_REG, and UART_STATUS_REG.
Referenced by BlockLoad(), and main().
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 }
void sendchar | ( | unsigned char | c | ) |
Transmitting a character UART communcation.
UART Transmitting section.
This function takes the unsigned char input given to the function and transmits out in the UART communication.
This function is called whenever a single charater has to be transmitted in the UART communication.
c | Character value to be transmitted. |
Definition at line 43 of file serial.c.
References TRANSMIT_COMPLETE_BIT, UART_DATA_REG, and UART_STATUS_REG.
Referenced by BlockRead(), and main().
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 }
Generated on Fri Mar 27 14:05:26 2009 for AVR1605: XMEGA BOOTLOADER by ![]() |