Xmega Application Note | |||||
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/ 00047 #include "config.h" 00048 #include "conf_usb.h" 00049 #include "usb_drv.h" 00050 #include "usb_descriptors.h" 00051 #include "usb_standard_request.h" 00052 #include "usb_specific_request.h" 00053 #include "uart_usb_lib.h" 00054 #include "sw_usart.h" 00055 #include "cdc_task.h" 00056 00057 00058 volatile uint8_t cpt_sof; 00059 S_line_coding line_coding; 00060 extern uint8_t tx_counter; 00061 00062 00065 void cdc_task_init(void) 00066 { 00067 SW_USART_init(); 00068 Usb_enable_sof_interrupt(); 00069 } 00070 00071 00076 void cdc_task(void) 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 } 00106 00107 00114 void sof_action(void) 00115 { 00116 cpt_sof++; 00117 }
Generated on Mon Jan 18 09:26:08 2010 for AVR1907 Xplain USB Gateway by ![]() |