#include "config.h"
#include "conf_usb.h"
#include "cdc_task.h"
#include "lib_mcu/usb/usb_drv.h"
#include "usb_descriptors.h"
#include "modules/usb/device_chap9/usb_standard_request.h"
#include "usb_specific_request.h"
#include "lib_mcu/uart/uart_lib.h"
#include "uart_usb_lib.h"
#include "lib_mcu/util/start_boot.h"
#include <stdio.h>
Go to the source code of this file.
Functions | |
void | cdc_task_init (void) |
void | cdc_task (void) |
void | sof_action () |
__interrupt void | usart_receive_interrupt () |
Variables | |
volatile U8 | cpt_sof |
U8 | rx_counter |
U8 | tx_counter |
volatile U8 | usb_request_break_generation |
S_line_coding | line_coding |
S_line_status | line_status |
S_serial_state | serial_state |
volatile U8 | rs2usb [10] |
Definition in file cdc_task.c.
void cdc_task_init | ( | void | ) |
This function initializes the hardware ressources required for CDC demo.
none |
Definition at line 89 of file cdc_task.c.
References Hwb_button_init, Joy_init, Leds_init, Uart_enable_it_rx, uart_init(), uart_usb_getchar(), uart_usb_putchar, and Usb_enable_sof_interrupt.
00090 { 00091 uart_init(); 00092 Uart_enable_it_rx(); 00093 Leds_init(); 00094 Joy_init(); 00095 Hwb_button_init(); 00096 Usb_enable_sof_interrupt(); 00097 #ifdef __GNUC__ 00098 fdevopen((int (*)(char, FILE*))(uart_usb_putchar),(int (*)(FILE*))uart_usb_getchar); //for printf redirection 00099 #endif 00100 }
void cdc_task | ( | void | ) |
Entry point of the uart cdc management This function links the uart and the USB bus.
none |
Definition at line 111 of file cdc_task.c.
References S_serial_state::bDCD, S_serial_state::bDSR, cdc_update_serial_state(), cpt_sof, S_line_status::DTR, FALSE, Is_btn_left, Is_btn_middle, Is_device_enumerated, Is_joy_down, Is_joy_left, Is_joy_right, Is_joy_up, Led2_toggle, Led3_toggle, REPEAT_KEY_PRESSED, rx_counter, TRUE, uart_putchar(), Uart_tx_ready, uart_usb_getchar(), uart_usb_test_hit(), and usb_request_break_generation.
00112 { 00113 00114 if(Is_device_enumerated() && line_status.DTR) //Enumeration processs OK and COM port openned ? 00115 { 00116 if (Uart_tx_ready()) //USART free ? 00117 { 00118 if (uart_usb_test_hit()) // Something received from the USB ? 00119 { 00120 while (rx_counter) 00121 { 00122 uart_putchar(uart_usb_getchar()); // loop back USB to USART 00123 Led3_toggle(); 00124 } 00125 } 00126 } 00127 00128 if ( cpt_sof>=REPEAT_KEY_PRESSED) //Debounce joystick events 00129 { 00130 if (Is_btn_middle()){ 00131 printf ("Select Pressed !\r\n"); 00132 } 00133 if (Is_joy_right()) { 00134 printf ("Right Pressed !\r\n"); 00135 serial_state.bDCD = TRUE; 00136 } 00137 else 00138 serial_state.bDCD = FALSE; 00139 00140 if (Is_joy_left()) { 00141 printf ("Left Pressed !\r\n"); 00142 serial_state.bDSR = TRUE; 00143 } 00144 else 00145 serial_state.bDSR = FALSE; 00146 00147 if (Is_joy_down()) 00148 printf ("Down Pressed !\r\n"); 00149 00150 if (Is_joy_up()) 00151 printf ("Up Pressed !\r\n"); 00152 00153 if(Is_btn_left()) 00154 printf("Hello from AT90USBXXX !\r\n"); 00155 00156 cdc_update_serial_state(); 00157 } 00158 00159 if(usb_request_break_generation==TRUE) 00160 { 00161 usb_request_break_generation=FALSE; 00162 Led2_toggle(); 00163 } 00164 } 00165 }
__interrupt void usart_receive_interrupt | ( | ) |
Uart Receive interrupt subroutine
none |
Definition at line 193 of file cdc_task.c.
References FALSE, Is_device_enumerated, Is_usb_write_enabled, rs2usb, TX_EP, Uart_get_byte, Uart_rx_ready, uart_usb_send_buffer(), Usb_get_selected_endpoint, and Usb_select_endpoint.
00195 { 00196 U8 i=0; 00197 U8 save_ep; 00198 00199 if(Is_device_enumerated()) 00200 { 00201 save_ep=Usb_get_selected_endpoint(); 00202 Usb_select_endpoint(TX_EP); 00203 do 00204 { 00205 if(Uart_rx_ready()) 00206 { 00207 rs2usb[i]=Uart_get_byte(); 00208 i++; 00209 } 00210 }while(Is_usb_write_enabled()==FALSE ); 00211 uart_usb_send_buffer((U8*)&rs2usb,i); 00212 Usb_select_endpoint(save_ep); 00213 } 00214 }
Definition at line 57 of file uart_usb_lib.c.
Referenced by cdc_task(), uart_usb_getchar(), uart_usb_init(), and uart_usb_test_hit().
volatile U8 usb_request_break_generation |
Definition at line 77 of file usb_specific_request.c.
Referenced by cdc_send_break(), and cdc_task().
Definition at line 74 of file cdc_task.c.
Definition at line 75 of file cdc_task.c.
Definition at line 76 of file cdc_task.c.