#include "config.h"
Go to the source code of this file.
Functions | |
void | device_template_task_init (void) |
void | device_template_task (void) |
void | sof_action (void) |
Definition in file device_template_task.h.
void device_template_task_init | ( | void | ) |
This function initializes the hardware/software resources required for device application task.
none |
Definition at line 81 of file device_template_task.c.
References cpt_sof, FALSE, Hwb_button_init, Joy_init, Leds_init, rxok, and Usb_enable_sof_interrupt.
00082 { 00083 Joy_init(); 00084 Hwb_button_init(); 00085 Leds_init(); 00086 cpt_sof=0; 00087 Usb_enable_sof_interrupt(); 00088 rxok=FALSE; 00089 }
void device_template_task | ( | void | ) |
Entry point of the device application This function links the application with the USB bus.
none |
Definition at line 98 of file device_template_task.c.
References buf, cpt_sof, EP_IN_LENGTH_TEMP1, EP_TEMP_IN, EP_TEMP_INT_IN, EP_TEMP_OUT, FALSE, i, Is_device_enumerated, Is_usb_read_control_enabled, Is_usb_receive_out, Is_usb_write_enabled, Led0_off, Led0_on, rxok, TRUE, Usb_ack_in_ready, Usb_ack_receive_out, Usb_byte_counter, Usb_read_byte, Usb_select_endpoint, and Usb_write_byte.
00099 { 00100 U8 i; 00101 U8 *ptr; 00102 static U8 dummy_data; 00103 00104 //.. FIRST CHECK THE DEVICE ENUMERATION STATE 00105 if (Is_device_enumerated()) 00106 { 00107 //.. HERE START THE USB DEVICE APPLICATIVE CODE 00108 //.. The example bellow just perform a loop back transmition/reception 00109 //.. All data received wth the OUT endpoint are store in a ram buffer and 00110 //.. send back to the IN endpoint 00111 00112 //.. For example, blink a led with start of frame counter 00113 if(cpt_sof>0x7F) 00114 { Led0_on(); } 00115 else { Led0_off();} 00116 00117 //.. First interface management 00118 //.. Select the OUT endpoint declared in descriptors 00119 //.. load the endpoint with the content of a ram buffer for example 00120 Usb_select_endpoint(EP_TEMP_OUT); 00121 if ( Is_usb_receive_out()) 00122 { 00123 ptr=buf; 00124 for(i=Usb_byte_counter();i;i--) 00125 { 00126 *ptr++=Usb_read_byte(); 00127 } 00128 Usb_ack_receive_out(); 00129 rxok=TRUE; 00130 } 00131 //.. First interface management (cont) 00132 //.. Select the IN endpoint declared in descriptors 00133 //.. If we receive something, just store in the ram buffer 00134 Usb_select_endpoint(EP_TEMP_IN); 00135 if ( Is_usb_read_control_enabled()&&(rxok==TRUE)) 00136 { 00137 ptr=buf; 00138 for(i=0;i<EP_IN_LENGTH_TEMP1;i++) 00139 Usb_write_byte(*ptr++); 00140 Usb_ack_in_ready(); 00141 rxok=FALSE; 00142 } 00143 00144 //.. Second interface management (interrupt IN endpoint) 00145 //.. Just Send dummy data bytes 00146 Usb_select_endpoint(EP_TEMP_INT_IN); // Select this enpoint 00147 if (Is_usb_write_enabled()) // Check data can be loaded 00148 { // And load dummy data... 00149 Usb_write_byte(dummy_data); 00150 Usb_write_byte(dummy_data+1); 00151 Usb_write_byte(dummy_data+2); 00152 Usb_write_byte(dummy_data+3); 00153 Usb_ack_in_ready(); 00154 dummy_data+=4; 00155 } 00156 } 00157 }