uart_lib.c File Reference

#include "config.h"
#include "lib_mcu/uart/uart_lib.h"

Include dependency graph for uart_lib.c:

Go to the source code of this file.

Functions

bit uart_test_hit (void)
bit uart_init (void)
r_uart_ptchar uart_putchar (p_uart_ptchar ch)
char uart_getchar (void)


Detailed Description

This file provides a minimal VT100 terminal access through UART and compatibility with Custom I/O support - Compiler: IAR EWAVR and GNU GCC for AVR

Definition in file uart_lib.c.


Function Documentation

bit uart_test_hit ( void   ) 

This function allows to inform if a character was received

Returns:
True if character received.

Definition at line 58 of file uart_lib.c.

00059 {
00060 return Uart_rx_ready();
00061 }

bit uart_init ( void   ) 

This function configures the UART configuration and timming following the constant definition of BAUDRATE and enables the UART controller.

Precondition:
before calling this function some declaration must be define in config.h:
  • FOSC Frequency of crystal in kHz (mandatory)Standard crystals available
  • BAUDRATE Baudrate in bit per second used for UART configuration (mandatory)
  • UART_CONFIG : (by default 8 bits| 1 bit stop |without parity)

Definition at line 64 of file uart_lib.c.

00065 {
00066 #ifndef UART_U2
00067   Uart_set_baudrate(BAUDRATE);
00068   Uart_hw_init(UART_CONFIG);
00069 #else
00070   Uart_set_baudrate(BAUDRATE/2);
00071   Uart_double_bdr();
00072   Uart_hw_init(UART_CONFIG);
00073 
00074 #endif
00075   Uart_enable();
00076   return TRUE;
00077 }

r_uart_ptchar uart_putchar ( p_uart_ptchar  uc_wr_byte  ) 

This function allows to send a character on the UART

Parameters:
uc_wr_byte character to print on UART.
Returns:
character sent.
Note:
the type p_uart_ptchar and r_uart_ptchar can be define to macth with a printf need.

Definition at line 80 of file uart_lib.c.

00081 {
00082   while(!Uart_tx_ready());
00083   Uart_set_tx_busy(); // Set Busy flag before sending (always)
00084   Uart_send_byte(ch);
00085    
00086   return ch;
00087 }

char uart_getchar ( void   ) 

This function allows to get a character from the UART

Returns:
character read.

Definition at line 92 of file uart_lib.c.

00093 {
00094   register char c;
00095 
00096   while(!Uart_rx_ready());
00097   c = Uart_get_byte();
00098   Uart_ack_rx_byte();
00099   return c;
00100 }


Generated on Fri Sep 11 14:23:53 2009 for ATMEL by  doxygen 1.5.3