Xmega Application Note | |||||
Copyright (c) 2010, Atmel Corporation All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file uart_usb_lib.h.
Go to the source code of this file.
Functions | |
void | uart_usb_flush (void) |
This function sends the data stored in the USB transmit buffer. | |
uint8_t | uart_usb_getchar (void) |
This function reads one byte from the USB bus. | |
void | uart_usb_init (void) |
Initializes the uart_usb library. | |
int16_t | uart_usb_putchar (int16_t) |
uint8_t | uart_usb_test_hit (void) |
This function checks if a character has been received on the USB bus. | |
uint8_t | uart_usb_tx_ready (void) |
This function checks if the USB emission buffer is ready to accept at at least 1 byte. |
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 160 of file uart_usb_lib.c.
References tx_counter, TX_EP, Usb_select_endpoint, and Usb_send_in.
Referenced by cdc_task(), and uart_usb_putchar().
00161 { 00162 Usb_select_endpoint(TX_EP); 00163 Usb_send_in(); 00164 tx_counter = 0; 00165 00166 }
uint8_t 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.
Definition at line 101 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().
00102 { 00103 register uint8_t data_rx; 00104 00105 Usb_select_endpoint(RX_EP); 00106 if (!rx_counter){ 00107 while (!uart_usb_test_hit()); 00108 } 00109 00110 data_rx = Usb_read_byte(); 00111 rx_counter--; 00112 00113 if (!rx_counter){ 00114 Usb_ack_receive_out(); 00115 } 00116 00117 return data_rx; 00118 }
void uart_usb_init | ( | void | ) |
Initializes the uart_usb library.
Definition at line 58 of file uart_usb_lib.c.
References rx_counter, and tx_counter.
00059 { 00060 tx_counter = 0; 00061 rx_counter = 0; 00062 }
int16_t uart_usb_putchar | ( | int16_t | ) |
uint8_t uart_usb_test_hit | ( | void | ) |
This function checks if a character has been received on the USB bus.
Definition at line 68 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().
00069 { 00070 if (!rx_counter) 00071 { 00072 Usb_select_endpoint(RX_EP); 00073 if (Is_usb_receive_out()) 00074 { 00075 00076 #ifdef __ICCAVR__ 00077 #pragma diag_suppress=Pa082 /* Suppress warning for undefined order of volatile access. */ 00078 #endif 00079 rx_counter = Usb_byte_counter(); 00080 #ifdef __ICCAVR__ 00081 #pragma diag_default=Pa082 /* Back to default.*/ 00082 #endif 00083 00084 if (!rx_counter) 00085 { 00086 Usb_ack_receive_out(); 00087 } 00088 } 00089 } 00090 return (rx_counter!=0); 00091 }
uint8_t uart_usb_tx_ready | ( | void | ) |
This function checks if the USB emission buffer is ready to accept at at least 1 byte.
Definition at line 125 of file uart_usb_lib.c.
References Is_usb_write_enabled.
Referenced by uart_usb_putchar().
00126 { 00127 if (!Is_usb_write_enabled()) 00128 { 00129 return false; 00130 } 00131 return true; 00132 }
Generated on Mon Jan 18 09:26:11 2010 for AVR1907 Xplain USB Gateway by ![]() |