Xmega Application Note


cdc_task.c File Reference


Detailed Description

Sourcecode for the CDC task manager.

Application note:
AVR1907: Xplain Evaluation Board
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
3119
Date
2010-01-12 15:53:30 +0100 (ti, 12 jan 2010)

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 cdc_task.c.

#include "config.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"
#include "uart_usb_lib.h"
#include "sw_usart.h"
#include "cdc_task.h"

Include dependency graph for cdc_task.c:

Go to the source code of this file.

Functions

void cdc_task (void)
 Entry point of the uart cdc management.
void cdc_task_init (void)
 This function initializes the hardware resources required for CDC.
void sof_action (void)
 Start of frame action.

Variables

volatile uint8_t cpt_sof
S_line_coding line_coding
uint8_t tx_counter


Function Documentation

void cdc_task ( void   ) 

Entry point of the uart cdc management.

This function links the software UART and the USB bus.

Definition at line 76 of file cdc_task.c.

References cpt_sof, Is_device_enumerated, Led_tgl, NB_MS_BEFORE_FLUSH, SW_USART_PutChar(), SW_USART_RX_Buffer_GetByte(), SW_USART_Test_Hit(), tx_counter, uart_usb_flush(), uart_usb_getchar(), uart_usb_putchar(), and uart_usb_test_hit().

Referenced by main().

00077 {
00078         
00079          /* Check if the device is enumerated.
00080           * If it is, run the code.
00081           * Otherwise, skip this section. */
00082         if(Is_device_enumerated()){
00083                 
00084                 /* Flush buffer if timeout. */
00085                 if(cpt_sof>=NB_MS_BEFORE_FLUSH && tx_counter!=0 ){
00086                         cpt_sof=0;
00087                         uart_usb_flush();
00088                 }
00089                 
00090                 /* Check if something is received on the Soft UART and forward
00091                  * it the USB UART if necessary. */
00092                 if (SW_USART_Test_Hit()){
00093                         Led_tgl();
00094                         uart_usb_putchar(SW_USART_RX_Buffer_GetByte());
00095                 }
00096                 
00097                 /* Check if something is received on USB UART and forward
00098                  * it to the Soft UART if necessary. */
00099                 if (uart_usb_test_hit()){
00100                         Led_tgl();
00101                         SW_USART_PutChar(uart_usb_getchar());
00102                 }
00103                 
00104         }
00105 }

Here is the call graph for this function:

void cdc_task_init ( void   ) 

This function initializes the hardware resources required for CDC.

Definition at line 65 of file cdc_task.c.

References SW_USART_init(), and Usb_enable_sof_interrupt.

Referenced by main().

00066 {
00067         SW_USART_init();
00068         Usb_enable_sof_interrupt();
00069 }

Here is the call graph for this function:

void sof_action ( void   ) 

Start of frame action.

This function increments the cpt_sof counter each times the USB Start Of Frame interrupt subroutine is executed (1ms) Usefull to manage time delays

Definition at line 114 of file cdc_task.c.

References cpt_sof.

00115 {
00116         cpt_sof++;
00117 }


Variable Documentation

volatile uint8_t cpt_sof

Definition at line 58 of file cdc_task.c.

Referenced by cdc_task(), and sof_action().

Definition at line 59 of file cdc_task.c.

uint8_t tx_counter

Definition at line 53 of file uart_usb_lib.c.

Referenced by cdc_task(), uart_usb_flush(), uart_usb_init(), and uart_usb_putchar().

@DOC_TITLE@
Generated on Mon Jan 18 09:26:09 2010 for AVR1907 Xplain USB Gateway by doxygen 1.5.5