@@ -358,22 +358,29 @@ __xdata uint8_t scratch[512];
358
358
uint16_t ep0_xfer_bytes_left ;
359
359
uint8_t * ep0_xfer_src ;
360
360
361
- uint8_t received_usb_addr ;
362
-
361
+ // usb state
362
+ uint8_t __xdata received_usb_addr ;
363
363
uint8_t __xdata interface0_protocol ;
364
364
uint8_t __xdata interface1_protocol ;
365
+ uint8_t __xdata idle_time ;
366
+ uint8_t __xdata active_configution ;
367
+ uint8_t __xdata ep0_xfer_state ;
365
368
366
369
// TODO: remove
367
370
volatile __bit device_remote_wakeup_f ;
368
- volatile uint8_t __xdata configution_value ;
369
371
370
- uint8_t __xdata EP1_IDLE_TIME ;
371
-
372
- uint8_t __xdata ep0_xfer_state ;
373
372
374
373
void usb_init ()
375
374
{
376
375
received_usb_addr = 0 ;
376
+ idle_time = 0 ;
377
+ interface0_protocol = 0 ;
378
+ interface1_protocol = 0 ;
379
+ active_configution = 0 ;
380
+ ep0_xfer_state = 0 ;
381
+ ep0_xfer_bytes_left = 0 ;
382
+ ep0_xfer_src = 0 ;
383
+
377
384
USBADDR = 0 ;
378
385
USBIE1 = (_OVERIE | _SETUPIE | _SOFIA | _RESMIE | _SUSPIE | _PBRSTIE );
379
386
USBIE2 = (_OEP0IE | _IEP0IE );
@@ -710,7 +717,7 @@ static void usb_set_configuration_handler(__xdata struct usb_req_setup *req)
710
717
if (USBADDR ) {
711
718
// TODO: can this actually support 2 configs?
712
719
if ((req -> wValue == 0 ) || (req -> wValue == 1 )) {
713
- configution_value = req -> wValue ;
720
+ active_configution = req -> wValue ;
714
721
// TODO: save config set state
715
722
IEP0CNT_CLR ;
716
723
IN0_SET_READY ;
@@ -934,7 +941,7 @@ static void usb_get_configuration_handler()
934
941
{
935
942
ep0_xfer_state = OUT0_STATUS_PHASE ;
936
943
937
- EP0_IN_BUF [0 ] = configution_value ;
944
+ EP0_IN_BUF [0 ] = active_configution ;
938
945
939
946
IEP0CNT_SET (1 );
940
947
IN0_SET_READY ;
@@ -979,7 +986,7 @@ static void usb_hid_set_report_handler(__xdata struct usb_req_setup *req)
979
986
static void usb_hid_set_idle_handler (__xdata struct usb_req_setup * req )
980
987
{
981
988
// TODO: finish implementaiton to use the set idle time
982
- EP1_IDLE_TIME = req -> wValue >> 8 ;
989
+ idle_time = req -> wValue >> 8 ;
983
990
984
991
IEP0CNT_CLR ;
985
992
IN0_SET_READY ;
@@ -988,7 +995,7 @@ static void usb_hid_set_idle_handler(__xdata struct usb_req_setup *req)
988
995
static void usb_hid_get_idle_handler ()
989
996
{
990
997
// TODO: finish implementaiton to use the set idle time
991
- EP0_IN_BUF [0 ] = EP1_IDLE_TIME ;
998
+ EP0_IN_BUF [0 ] = idle_time ;
992
999
993
1000
IEP0CNT_SET (1 );
994
1001
IN0_SET_READY ;
0 commit comments