comparison Output/pjrcUSB/arm/usb_dev.c @ 327:f7b14e25ca5b

Merge pull request #27 from smasher816/wakeup-devel Inital Remote Wakeup Support
author Jacob Alexander <haata@kiibohd.com>
date Fri, 12 Jun 2015 18:31:55 -0700
parents 4f47971c45c2 05a09eda53fb
children 1beec5f17e64
comparison
equal deleted inserted replaced
325:b2c8581307bc 327:f7b14e25ca5b
165 volatile uint8_t usb_configuration = 0; 165 volatile uint8_t usb_configuration = 0;
166 volatile uint8_t usb_reboot_timer = 0; 166 volatile uint8_t usb_reboot_timer = 0;
167 167
168 static uint8_t reply_buffer[8]; 168 static uint8_t reply_buffer[8];
169 169
170 volatile uint8_t remote_wakeup_enabled = 0;
170 171
171 172
172 // ----- Functions ----- 173 // ----- Functions -----
173 174
174 static void endpoint0_stall() 175 static void endpoint0_stall()
292 reply_buffer[0] = usb_configuration; 293 reply_buffer[0] = usb_configuration;
293 datalen = 1; 294 datalen = 1;
294 data = reply_buffer; 295 data = reply_buffer;
295 break; 296 break;
296 case 0x0080: // GET_STATUS (device) 297 case 0x0080: // GET_STATUS (device)
297 reply_buffer[0] = 0; 298 //I think this is the corrent endianess
299 reply_buffer[0] = (remote_wakeup_enabled)<<1;
298 reply_buffer[1] = 0; 300 reply_buffer[1] = 0;
299 datalen = 2; 301 datalen = 2;
300 data = reply_buffer; 302 data = reply_buffer;
301 break; 303 break;
302 case 0x0082: // GET_STATUS (endpoint) 304 case 0x0082: // GET_STATUS (endpoint)
312 reply_buffer[0] = 1; 314 reply_buffer[0] = 1;
313 data = reply_buffer; 315 data = reply_buffer;
314 datalen = 2; 316 datalen = 2;
315 break; 317 break;
316 case 0x0100: // CLEAR_FEATURE (device) 318 case 0x0100: // CLEAR_FEATURE (device)
319 //Disable DEVICE_REMOTE_WAKEUP feature
320 if (setup.wValue == 0x01) {
321 remote_wakeup_enabled = 0;
322 }
323 break;
317 case 0x0101: // CLEAR_FEATURE (interface) 324 case 0x0101: // CLEAR_FEATURE (interface)
318 // TODO: Currently ignoring, perhaps useful? -HaaTa 325 // TODO: Currently ignoring, perhaps useful? -HaaTa
319 endpoint0_stall(); 326 endpoint0_stall();
320 return; 327 return;
321 case 0x0102: // CLEAR_FEATURE (interface) 328 case 0x0102: // CLEAR_FEATURE (interface)
332 // FIXME: Clearing causes keyboard to freeze, likely an invalid clear 339 // FIXME: Clearing causes keyboard to freeze, likely an invalid clear
333 // XXX: Ignoring seems to work, though this may not be the ideal behaviour -HaaTa 340 // XXX: Ignoring seems to work, though this may not be the ideal behaviour -HaaTa
334 endpoint0_stall(); 341 endpoint0_stall();
335 return; 342 return;
336 case 0x0300: // SET_FEATURE (device) 343 case 0x0300: // SET_FEATURE (device)
344 //Enable DEVICE_REMOTE_WAKEUP feature
345 if (setup.wValue == 0x01) {
346 remote_wakeup_enabled = 1;
347 }
348 break;
337 case 0x0301: // SET_FEATURE (interface) 349 case 0x0301: // SET_FEATURE (interface)
338 // TODO: Currently ignoring, perhaps useful? -HaaTa 350 // TODO: Currently ignoring, perhaps useful? -HaaTa
339 endpoint0_stall(); 351 endpoint0_stall();
340 return; 352 return;
341 case 0x0302: // SET_FEATURE (endpoint) 353 case 0x0302: // SET_FEATURE (endpoint)
1106 if ( (status & USB_ISTAT_SLEEP /* 10 */ ) ) 1118 if ( (status & USB_ISTAT_SLEEP /* 10 */ ) )
1107 { 1119 {
1108 //serial_print("sleep\n"); 1120 //serial_print("sleep\n");
1109 USB0_ISTAT = USB_ISTAT_SLEEP; 1121 USB0_ISTAT = USB_ISTAT_SLEEP;
1110 } 1122 }
1123
1124 if ( (status & USB_ISTAT_RESUME /* 20 */ ) ) {
1125 //serial_print("resume\n");
1126 USB0_ISTAT = USB_ISTAT_RESUME;
1127 }
1111 } 1128 }
1112 1129
1113 1130
1114 1131
1115 uint8_t usb_init() 1132 uint8_t usb_init()