uart_lib.h File Reference

,vThis file contains Uart lib header file. More...

#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)
 This function configures the UART configuration and timming following the constant definition of BAUDRATE and enables the UART controller.
r_uart_ptchar uart_putchar (p_uart_ptchar uc_wr_byte)
 This function allows to send a character on the UART.
char uart_getchar (void)
 This function allows to get a character from the UART.
bit uart_test_hit (void)
 This function allows to inform if a character was received.


Detailed Description

,vThis file contains Uart lib header file.

Copyright (c) 2004 Atmel.

Please read file license.txt for copyright notice.

Version:
1.14.4.4 at90usb162-cdc-1_0_1
Todo:
Bug:

Definition in file uart_lib.h.


Define Documentation

#define UART_CONFIG   MSK_UART_8BIT

Definition at line 25 of file uart_lib.h.

Referenced by uart_init().

#define BAUDRATE   999

Definition at line 30 of file uart_lib.h.

#define AUTOBAUD   0

Definition at line 33 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 33 of file uart_lib.c.

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

Referenced by cdc_task_init().

00034 {
00035 #ifndef UART_U2
00036   Uart_set_baudrate(BAUDRATE);
00037   Uart_hw_init(UART_CONFIG);
00038 #else
00039   Uart_set_baudrate(BAUDRATE/2);
00040   Uart_double_bdr();
00041   Uart_hw_init(UART_CONFIG);
00042 
00043 #endif
00044   Uart_enable();
00045   return TRUE;
00046 }

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.

char uart_getchar ( void   ) 

This function allows to get a character from the UART.

Returns:
character read.

Definition at line 61 of file uart_lib.c.

References Uart_ack_rx_byte, Uart_get_byte, and Uart_rx_ready.

Referenced by cdc_task().

00062 {
00063   register char c;
00064 
00065   while(!Uart_rx_ready());
00066   c = Uart_get_byte();
00067   Uart_ack_rx_byte();
00068   return c;
00069 }

bit uart_test_hit ( void   ) 

This function allows to inform if a character was received.

Returns:
True if character received.

Definition at line 27 of file uart_lib.c.

References Uart_rx_ready.

Referenced by cdc_task().

00028 {
00029 return Uart_rx_ready();
00030 }


Generated on Fri Jun 15 14:15:45 2007 for Atmel by  doxygen 1.5.1-p1