uart_lib.h File Reference

#include "uart_drv.h"
#include "lib_mcu/uart/uart_bdr.h"

Include dependency graph for uart_lib.h:

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

Go to the source code of this file.

Defines

#define UART_CONFIG   MSK_UART_8BIT
#define BAUDRATE   999
#define AUTOBAUD   0

Functions

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


Detailed Description

This file contains Uart lib header file.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file uart_lib.h.


Define Documentation

#define UART_CONFIG   MSK_UART_8BIT

Definition at line 50 of file uart_lib.h.

Referenced by uart_init().

#define BAUDRATE   999

Definition at line 55 of file uart_lib.h.

#define AUTOBAUD   0

Definition at line 58 of file uart_lib.h.


Function Documentation

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 61 of file uart_lib.c.

References BAUDRATE, TRUE, UART_CONFIG, Uart_double_bdr, Uart_enable, Uart_hw_init, and Uart_set_baudrate.

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

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 77 of file uart_lib.c.

References Uart_send_byte, Uart_set_tx_busy, and Uart_tx_ready.

00078 {
00079   while(!Uart_tx_ready());
00080   Uart_set_tx_busy(); // Set Busy flag before sending (always)
00081   Uart_send_byte(ch);
00082    
00083   return ch;
00084 }

char uart_getchar ( void   ) 

This function allows to get a character from the UART

Returns:
character read.

Definition at line 89 of file uart_lib.c.

References c, Uart_ack_rx_byte, Uart_get_byte, and Uart_rx_ready.

00090 {
00091   register char c;
00092 
00093   while(!Uart_rx_ready());
00094   c = Uart_get_byte();
00095   Uart_ack_rx_byte();
00096   return c;
00097 }

bit uart_test_hit ( void   ) 

This function allows to inform if a character was received

Returns:
True if character received.

Definition at line 55 of file uart_lib.c.

References Uart_rx_ready.

00056 {
00057 return Uart_rx_ready();
00058 }


Generated on Wed Sep 23 09:17:15 2009 for ATMEL by  doxygen 1.5.3