device_template_task.h File Reference

#include "config.h"

Include dependency graph for device_template_task.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void device_template_task_init (void)
void device_template_task (void)
void sof_action (void)


Detailed Description

This file contains the function declarations - Compiler: IAR EWAVR and GNU GCC for AVR

Definition in file device_template_task.h.


Function Documentation

void device_template_task_init ( void   ) 

This function initializes the hardware/software resources required for device application task.

Parameters:
none 
Returns:
none
/

Definition at line 78 of file device_template_task.c.

References cpt_sof, FALSE, Hwb_button_init, Joy_init, Leds_init, rxok, and Usb_enable_sof_interrupt.

00079 {
00080    Joy_init();
00081    Hwb_button_init();
00082    Leds_init();
00083    cpt_sof=0;
00084    Usb_enable_sof_interrupt();
00085    rxok=FALSE;
00086 }

void device_template_task ( void   ) 

Entry point of the device application This function links the application with the USB bus.

Parameters:
none 
Returns:
none

Definition at line 95 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.

00096 {
00097    U8 i;
00098    U8 *ptr;
00099    static U8 dummy_data;
00100 
00101    //.. FIRST CHECK THE DEVICE ENUMERATION STATE
00102    if (Is_device_enumerated())
00103    {
00104       //.. HERE START THE USB DEVICE APPLICATIVE CODE
00105       //.. The example bellow just perform a loop back transmition/reception
00106       //.. All data received wth the OUT endpoint are store in a ram buffer and
00107       //.. send back to the IN endpoint
00108 
00109       //.. For example, blink a led with start of frame counter
00110       if(cpt_sof>0x7F)
00111       {  Led0_on(); }
00112       else { Led0_off();}
00113 
00114       //.. First interface management
00115       //.. Select the OUT endpoint declared in descriptors
00116       //.. load the endpoint with the content of a ram buffer for example
00117       Usb_select_endpoint(EP_TEMP_OUT);
00118       if ( Is_usb_receive_out())
00119       {
00120          ptr=buf;
00121          for(i=Usb_byte_counter();i;i--)
00122          {
00123             *ptr++=Usb_read_byte();
00124          }
00125          Usb_ack_receive_out();
00126          rxok=TRUE;
00127       }
00128       //.. First interface management (cont)
00129       //.. Select the IN endpoint declared in descriptors
00130       //.. If we receive something, just store in the ram buffer
00131       Usb_select_endpoint(EP_TEMP_IN);
00132       if ( Is_usb_read_control_enabled()&&(rxok==TRUE))
00133       {
00134          ptr=buf;
00135          for(i=0;i<EP_IN_LENGTH_TEMP1;i++)
00136          Usb_write_byte(*ptr++);
00137          Usb_ack_in_ready();
00138          rxok=FALSE;
00139       }
00140 
00141       //.. Second interface management (interrupt IN endpoint)
00142       //.. Just Send dummy data bytes
00143       Usb_select_endpoint(EP_TEMP_INT_IN);    // Select this enpoint
00144       if (Is_usb_write_enabled())             // Check data can be loaded
00145       {                                       // And load dummy data...
00146          Usb_write_byte(dummy_data);
00147          Usb_write_byte(dummy_data+1);
00148          Usb_write_byte(dummy_data+2);
00149          Usb_write_byte(dummy_data+3);
00150          Usb_ack_in_ready();
00151          dummy_data+=4;
00152       }
00153    }
00154 }


Generated on Mon Nov 3 10:08:24 2008 for ATMEL by  doxygen 1.5.3