#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 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 |
U8 | usb_configuration_nb |
volatile U8 | cpt_sof = 0 |
U8 | jump_bootloader |
U8 | last_joy = 0 |
void(*) | start_bootloader (void) = (void (*)(void))0xf000 |
Declare function pointer to USB bootloader entry point. |
,v
Copyright (c) 2004 Atmel.
Please read file license.txt for copyright notice.
Definition in file hid_task.c.
void hid_task_init | ( | void | ) |
void hid_task | ( | void | ) |
Entry point of the HID generic communication task.
This function manages IN/OUT repport management.
none |
Check USB HID is enumerated
Get Data repport from Host
RepportOUT[0] is LEDS value
Check if we received DFU mode command from host
Detach actual generic HID application
Wait some time before
Jumping to booltoader
Now we build the Joytick information
Check for UP event
Ready to send these information to the host application
Dummy (not used)
Dummy (not used)
Dummy (not used)
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, Is_device_enumerated, Is_joy_down, Is_joy_left, Is_joy_right, Is_joy_up, Is_usb_receive_out, Is_usb_write_enabled, jump_bootloader, last_joy, Led0_off, Led0_on, Led1_off, Led1_on, Led2_off, Led2_on, Led3_off, Led3_on, Leds_off, Usb_ack_in_ready, Usb_ack_receive_out, Usb_detach, Usb_read_byte, Usb_select_endpoint, and Usb_write_byte.
00079 { 00080 U8 joy; 00081 U32 volatile tempo; 00082 U8 led_state; 00083 U8 led_number; 00084 00085 if(Is_device_enumerated()) 00086 { 00087 Usb_select_endpoint(EP_HID_OUT); 00088 if(Is_usb_receive_out()) 00089 { 00090 led_state=Usb_read_byte()&0x0F; 00091 led_number=Usb_read_byte()&0x0F; 00092 switch (led_number) 00093 { 00094 case 1: 00095 if(led_state) 00096 { Led0_on(); } 00097 else {Led0_off();} 00098 break; 00099 case 2: 00100 if(led_state) 00101 { Led1_on(); } 00102 else {Led1_off();} 00103 break; 00104 case 3: 00105 if(led_state) 00106 { Led2_on(); } 00107 else {Led2_off();} 00108 break; 00109 case 4: 00110 if(led_state) 00111 { Led3_on(); } 00112 else {Led3_off();} 00113 break; 00114 } 00115 Usb_ack_receive_out(); 00116 } 00117 00118 if(jump_bootloader) 00119 { 00120 Leds_off(); 00121 Usb_detach(); 00122 for(tempo=0;tempo<70000;tempo++); 00123 (*start_bootloader)(); 00124 } 00125 00126 00127 joy=0; 00128 if(Is_joy_up()|| Is_joy_down() || Is_joy_right() || Is_joy_left() ) 00129 { 00130 joy=0x01; 00131 } 00132 Usb_select_endpoint(EP_HID_IN); 00133 if(Is_usb_write_enabled()) 00134 { 00135 if(joy!=last_joy) 00136 { 00137 Usb_write_byte(joy); 00138 Usb_write_byte(GPIOR1); 00139 Usb_write_byte(GPIOR1); 00140 Usb_write_byte(GPIOR1); 00141 Usb_write_byte(GPIOR1); 00142 Usb_write_byte(GPIOR1); 00143 Usb_write_byte(GPIOR1); 00144 Usb_write_byte(GPIOR1); 00145 Usb_ack_in_ready(); 00146 last_joy=joy; 00147 } 00148 } 00149 } 00150 00151 }
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 /
Definition at line 46 of file usb_device_task.c.
Referenced by usb_device_task(), and usb_general_interrupt().
Definition at line 70 of file usb_standard_request.c.
Referenced by usb_device_task(), usb_general_interrupt(), usb_get_configuration(), and usb_set_configuration().
Definition at line 42 of file usb_specific_request.c.
Referenced by hid_task(), and usb_hid_user_set_hid_report().
void(*) start_bootloader(void) = (void (*)(void))0xf000 |