diff options
| -rw-r--r-- | firmware/export/usb.h | 3 | ||||
| -rw-r--r-- | firmware/usb.c | 16 |
2 files changed, 15 insertions, 4 deletions
diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 089b0f2..f1c2c64 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -26,6 +26,7 @@ void usb_start_monitoring(void); void usb_acknowledge(int id); void usb_wait_for_disconnect(struct event_queue *q); int usb_wait_for_disconnect_w_tmo(struct event_queue *q, int ticks); -bool usb_inserted(void); +bool usb_inserted(void); /* return the official value, what's been reported to the threads */ +bool usb_detect(void); /* return the raw hardware value */ #endif diff --git a/firmware/usb.c b/firmware/usb.c index 2cd5c9b..23edf7b 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -212,12 +212,10 @@ static void usb_thread(void) } } -static void usb_tick(void) +bool usb_detect(void) { bool current_status; - if(usb_monitor_enabled) - { #ifdef ARCHOS_RECORDER current_status = (adc_read(ADC_USB_POWER) > 500)?true:false; #else @@ -227,6 +225,18 @@ static void usb_tick(void) current_status = (PADR & 0x8000)?false:true; #endif #endif + + return current_status; +} + + +static void usb_tick(void) +{ + bool current_status; + + if(usb_monitor_enabled) + { + current_status = usb_detect(); /* Only report when the status has changed */ if(current_status != last_usb_status) |