#include "config.h"
#include "conf_usb.h"
#include "hid_task.h"
#include "lib_board/stk_525/stk_525.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\adc\adc_drv.h"
Include dependency graph for hid_task.c:
Go to the source code of this file.
Functions | |
void | hid_task_init (void) |
This function initializes the target board ressources. | |
void | hid_task (void) |
Entry point of the HID generic communication task. | |
void | sof_action () |
sof_action | |
Variables | |
bit | usb_connected |
Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /. | |
U8 | usb_configuration_nb |
volatile U8 | cpt_sof = 0 |
void(* | start_bootloader )(void) = (void (*)(void))0xf000 |
Declare function pointer to USB bootloader entry point. |
Copyright (c) 2004 Atmel.
Please read file license.txt for copyright notice.
Definition in file hid_task.c.
|
This function initializes the target board ressources.
Definition at line 58 of file hid_task.c. References init_adc(), Joy_init, and Leds_init.
Here is the call graph for this function: ![]() |
|
Entry point of the HID generic communication task. This function manages IN/OUT repport management.
Get Data repport from Host RepportOUT[0] is LEDS value not used not used In combinaisoon with nex byte allows the host to send an enter DFU mode event Check if we received DFU mode command from host Detach actual generic HID application Wait some time before Jumping to booltoader Get temperature value from ADC converter Get potemtiometer position from ADC converter 3 times because external impedance is differente from temperature sensor Now we build the Joytick information Check for UP event Check for DOWN event Check for RIGHT event Check for LEFT event Ready to send these information to the host application Leds Joystick Potentiometer Temperature Dummy (not used) Dummy (not used) Dummy (not used) Dummy (not used) Send data over the USB Definition at line 78 of file hid_task.c. References EP_HID_IN, EP_HID_OUT, Get_adc_pot_val(), GPIOR1, Is_device_enumerated, Is_joy_down, Is_joy_left, Is_joy_right, Is_joy_up, Is_usb_in_ready, Is_usb_receive_out, Leds_get_val, Leds_set_val, PINE, Read_temperature(), Usb_ack_fifocon, Usb_ack_receive_out, Usb_detach, Usb_read_byte, Usb_select_endpoint, and Usb_write_byte. 00079 { 00080 U8 dummy; 00081 U8 dummy2; 00082 U8 volatile pot; 00083 U8 volatile tempe; 00084 U8 joy; 00085 U32 volatile tempo; 00086 00087 if(Is_device_enumerated()) 00088 { 00089 Usb_select_endpoint(EP_HID_OUT); 00090 if(Is_usb_receive_out()) 00091 { 00092 Leds_set_val(Usb_read_byte()); 00093 GPIOR1=Usb_read_byte(); 00094 GPIOR1=Usb_read_byte(); 00095 dummy=Usb_read_byte(); 00096 dummy2=Usb_read_byte(); 00097 Usb_ack_receive_out(); 00098 } 00099 00100 if(dummy==0x55 && dummy2==0xAA) 00101 { 00102 Usb_detach(); 00103 for(tempo=0;tempo<70000;tempo++); 00104 (*start_bootloader)(); 00105 } 00106 tempe=(S8)Read_temperature(); 00107 tempe=(S8)Read_temperature(); 00108 tempe=(S8)Read_temperature(); 00109 00110 pot= Get_adc_pot_val()>>2; 00111 pot= Get_adc_pot_val()>>2; 00112 pot= Get_adc_pot_val()>>2; 00113 00114 joy=0; 00115 if(Is_joy_up()) 00116 { 00117 joy+=0x01; 00118 } 00119 if(Is_joy_down()) 00120 { 00121 joy+=0x02; 00122 } 00123 if(Is_joy_right()) 00124 { 00125 joy+=0x04; 00126 } 00127 if(Is_joy_left()) 00128 { 00129 joy+=0x08; 00130 } 00131 Usb_select_endpoint(EP_HID_IN); 00132 if(Is_usb_in_ready()) 00133 { 00134 Usb_write_byte(Leds_get_val()); 00135 Usb_write_byte(joy); 00136 Usb_write_byte(pot); 00137 Usb_write_byte(tempe); 00138 Usb_write_byte(GPIOR1); 00139 Usb_write_byte(~PINE); 00140 Usb_write_byte(~PINE); 00141 Usb_write_byte(~PINE); 00142 Usb_ack_fifocon(); 00143 } 00144 } 00145 00146 }
Here is the call graph for this function: ![]() |
|
Public : (bit) usb_connected usb_connected is set to TRUE when VBUS has been detected usb_connected is set to FALSE otherwise /.
Definition at line 46 of file usb_device_task.c. Referenced by usb_device_task(), usb_general_interrupt(), and usb_start_device(). |
|
Definition at line 70 of file usb_standard_request.c. Referenced by usb_device_task(), usb_get_configuration(), and usb_set_configuration(). |
|
Definition at line 42 of file hid_task.c. Referenced by sof_action(). |
|
Declare function pointer to USB bootloader entry point.
Definition at line 45 of file hid_task.c. |