This file manages the USB device HID task.
Definition in file device_hid_task.c.
#include <stdio.h>
#include "usart.h"
#include "conf_usb.h"
#include "board.h"
#include "controller.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "device_hid_task.h"
#include "audio_example.h"
#include "cycle_counter.h"
#include "debug.h"
#include "hid.h"
#include "et024006dhu.h"
Go to the source code of this file.
Defines | |
#define | HID_FAST_FWD 32 |
#define | HID_NEXT 8 |
#define | HID_PLAY_PAUSE 4 |
#define | HID_PREV 16 |
#define | HID_REWIND 64 |
#define | HID_VOL_DN 2 |
#define | HID_VOL_UP 1 |
#define | TIMER_STARTUP 100 |
Functions | |
void | device_hid_task (void) |
Entry point of the device HID task management. | |
void | device_hid_task_init (void) |
This function initializes the hardware/software resources required for device HID task. | |
Bool | is_usb_hid_event (void) |
Looks for HID events. | |
Variables | |
U8 | key = 0 |
t_cpu_time | key_timer |
#define HID_FAST_FWD 32 |
Definition at line 88 of file device_hid_task.c.
#define HID_NEXT 8 |
#define HID_PLAY_PAUSE 4 |
#define HID_PREV 16 |
#define HID_REWIND 64 |
Definition at line 89 of file device_hid_task.c.
#define HID_VOL_DN 2 |
#define HID_VOL_UP 1 |
#define TIMER_STARTUP 100 |
Definition at line 79 of file device_hid_task.c.
void device_hid_task | ( | void | ) |
Entry point of the device HID task management.
Write report
Definition at line 224 of file device_hid_task.c.
References EP_KBD_IN, is_usb_hid_event(), and key.
Referenced by main().
00225 { 00226 // First, check the device enumeration state 00227 if (!Is_device_enumerated()) { 00228 return; 00229 } 00230 00231 if (Is_usb_in_ready(EP_KBD_IN)) { 00232 if (is_usb_hid_event()) { 00233 Usb_reset_endpoint_fifo_access(EP_KBD_IN); 00234 00236 Usb_write_endpoint_data(EP_KBD_IN, 8, key); 00237 Usb_ack_in_ready_send(EP_KBD_IN); 00238 } 00239 } 00240 }
void device_hid_task_init | ( | void | ) |
This function initializes the hardware/software resources required for device HID task.
Definition at line 206 of file device_hid_task.c.
References FCPU_HZ, key_timer, and TIMER_STARTUP.
Referenced by main().
00207 { 00208 cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &key_timer ); 00209 00210 #if USB_HOST_FEATURE == ENABLED 00211 // If both device and host features are enabled, check if device mode is engaged 00212 // (accessing the USB registers of a non-engaged mode, even with load operations, 00213 // may corrupt USB FIFO data). 00214 if (Is_usb_device()) 00215 #endif // USB_HOST_FEATURE == ENABLED 00216 Usb_enable_sof_interrupt(); 00217 }
Bool is_usb_hid_event | ( | void | ) |
Looks for HID events.
Definition at line 98 of file device_hid_task.c.
References HID_NEXT, HID_PLAY_PAUSE, HID_PREV, HID_VOL_DN, HID_VOL_UP, is_joystick_down(), is_joystick_left(), is_joystick_pressed(), is_joystick_right(), is_joystick_up(), and key.
Referenced by device_hid_task().
00098 { 00099 static Bool b_on_off = FALSE; 00100 static Bool b_prev = FALSE; 00101 static Bool b_next = FALSE; 00102 static Bool b_vol_up = FALSE; 00103 static Bool b_vol_dn = FALSE; 00104 00105 // Management of Play/Pause 00106 // 00107 if(is_joystick_pressed() && b_on_off==FALSE) 00108 { 00109 b_on_off = TRUE; 00110 key = HID_PLAY_PAUSE; 00111 et024006_PrintString("PLAY", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00112 return TRUE; 00113 } 00114 if(!is_joystick_pressed() && b_on_off==TRUE) 00115 { 00116 b_on_off = FALSE; 00117 key = 0; 00118 et024006_PrintString(" ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00119 return TRUE; 00120 } 00121 00122 // Management of Prev 00123 // 00124 if (is_joystick_left() && b_prev == FALSE) 00125 { 00126 b_prev = TRUE; 00127 key = HID_PREV; 00128 00129 et024006_PrintString("PREV", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00130 return TRUE; 00131 } 00132 if (!is_joystick_left() && b_prev == TRUE) 00133 { 00134 b_prev = FALSE; 00135 key = 0; 00136 00137 et024006_PrintString(" ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00138 return TRUE; 00139 } 00140 00141 // Management of Next 00142 // 00143 if (is_joystick_right() && b_next == FALSE) 00144 { 00145 b_next = TRUE; 00146 key = HID_NEXT; 00147 00148 et024006_PrintString("NEXT", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00149 return TRUE; 00150 } 00151 if (!is_joystick_right() && b_next == TRUE) 00152 { 00153 b_next = FALSE; 00154 key = 0; 00155 00156 et024006_PrintString(" ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00157 return TRUE; 00158 } 00159 00160 00161 // Management of Vol - 00162 // 00163 if (is_joystick_down() && b_vol_dn == FALSE) 00164 { 00165 key = HID_VOL_DN; 00166 b_vol_dn = TRUE; 00167 00168 et024006_PrintString("VOL-", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00169 return TRUE; 00170 } 00171 if (!is_joystick_down() && b_vol_dn == TRUE) 00172 { 00173 b_vol_dn = FALSE; 00174 key = 0; 00175 00176 et024006_PrintString(" ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00177 return TRUE; 00178 } 00179 00180 // Management of Vol + 00181 // 00182 if (is_joystick_up() && b_vol_up == FALSE) 00183 { 00184 key = HID_VOL_UP; 00185 b_vol_up = TRUE; 00186 00187 et024006_PrintString("VOL+", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00188 return TRUE; 00189 } 00190 if (!is_joystick_up() && b_vol_up == TRUE) 00191 { 00192 b_vol_up = FALSE; 00193 key = 0; 00194 00195 et024006_PrintString(" ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE); 00196 return TRUE; 00197 } 00198 00199 return FALSE; 00200 }
U8 key = 0 |
Definition at line 77 of file device_hid_task.c.
Referenced by device_hid_task(), and is_usb_hid_event().
t_cpu_time key_timer |