uart_usb_lib.h File Reference

,vThis file controls the UART USB functions. More...

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

Go to the source code of this file.

Functions

void uart_usb_init (void)
 Initializes the uart_usb library.
bit uart_usb_test_hit (void)
 This function checks if a character has been received on the USB bus.
char uart_usb_getchar (void)
 This function reads one byte from the USB bus.
bit uart_usb_tx_ready (void)
 This function checks if the USB emission buffer is ready to accept at at least 1 byte.
int uart_usb_putchar (int)
void uart_usb_flush (void)
 This function sends the data stored in the USB transmit buffer.


Detailed Description

,vThis file controls the UART USB functions.

Copyright (c) 2006 Atmel.

Please read file license.txt for copyright notice.

Version:
1.1 at90usb162-cdc-1_0_1
Id
uart_usb_lib.h,v 1.1 2006/09/08 10:55:11 rletendu Exp

Definition in file uart_usb_lib.h.


Function Documentation

void uart_usb_init ( void   ) 

Initializes the uart_usb library.

Definition at line 33 of file uart_usb_lib.c.

References rx_counter, and tx_counter.

00034 {
00035   tx_counter = 0;
00036   rx_counter = 0;
00037 }

bit uart_usb_test_hit ( void   ) 

This function checks if a character has been received on the USB bus.

Returns:
bit (true if a byte is ready to be read)

Definition at line 44 of file uart_usb_lib.c.

References Is_usb_receive_out, rx_counter, RX_EP, Usb_ack_receive_out, Usb_byte_counter, and Usb_select_endpoint.

Referenced by cdc_task(), and uart_usb_getchar().

00045 {
00046   if (!rx_counter)
00047   {
00048     Usb_select_endpoint(RX_EP);
00049     if (Is_usb_receive_out())
00050     {
00051       rx_counter = Usb_byte_counter();
00052       if (!rx_counter)
00053       {
00054         Usb_ack_receive_out();
00055       }
00056     }
00057   }
00058   return (rx_counter!=0);
00059 }

char uart_usb_getchar ( void   ) 

This function reads one byte from the USB bus.

If one byte is present in the USB fifo, this byte is returned. If no data is present in the USB fifo, this function waits for USB data.

Returns:
U8 byte received

Definition at line 69 of file uart_usb_lib.c.

References rx_counter, RX_EP, uart_usb_test_hit(), Usb_ack_receive_out, Usb_read_byte, and Usb_select_endpoint.

Referenced by cdc_task(), and cdc_task_init().

00070 {
00071   register Uchar data_rx;
00072 
00073   Usb_select_endpoint(RX_EP);
00074   if (!rx_counter) while (!uart_usb_test_hit());
00075   data_rx=Usb_read_byte();
00076   rx_counter--;
00077   if (!rx_counter) Usb_ack_receive_out();
00078   return data_rx;
00079 }

Here is the call graph for this function:

bit uart_usb_tx_ready ( void   ) 

This function checks if the USB emission buffer is ready to accept at at least 1 byte.

Returns:
Boolean. TRUE if the firmware can write a new byte to transmit.

Definition at line 88 of file uart_usb_lib.c.

References FALSE, Is_usb_write_enabled, and TRUE.

Referenced by putchar().

00089 {
00090   if (!Is_usb_write_enabled())
00091   {
00092     return FALSE;
00093   }
00094   return TRUE;
00095 }

int uart_usb_putchar ( int   ) 

void uart_usb_flush ( void   ) 

This function sends the data stored in the USB transmit buffer.

This function does nothing if there is no data in the buffer.

Definition at line 124 of file uart_usb_lib.c.

References tx_counter, TX_EP, Usb_select_endpoint, and Usb_send_in.

Referenced by cdc_task(), and putchar().

00125 {
00126    Usb_select_endpoint(TX_EP);
00127    Usb_send_in();
00128    tx_counter = 0;
00129 
00130 }


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