diff options
author | Keith Packard <keithp@keithp.com> | 2009-04-25 13:18:37 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-04-25 13:18:37 -0700 |
commit | 0f07803d84b5ac89500ee33a6818c50583e3ff7f (patch) | |
tree | 2960f621869dfdded9751195fdabe48f72fa8f9f | |
parent | 45976af820fc41099928df71ea8304c56eb9fc7c (diff) |
Allow the USB system to be disabled/enabled at run-time
-rw-r--r-- | ao.h | 8 | ||||
-rw-r--r-- | ao_usb.c | 26 |
2 files changed, 33 insertions, 1 deletions
@@ -273,6 +273,14 @@ ao_usb_flush(void); void ao_usb_isr(void) interrupt 6; +/* Enable the USB controller */ +void +ao_usb_enable(void); + +/* Disable the USB controller */ +void +ao_usb_disable(void); + /* Initialize the USB system */ void ao_usb_init(void); @@ -514,7 +514,7 @@ ao_usb_getchar(void) __critical } void -ao_usb_init(void) +ao_usb_enable(void) { /* Turn on the USB controller */ SLEEP |= SLEEP_USB_EN; @@ -537,6 +537,30 @@ ao_usb_init(void) USBCIF = 0; USBOIF = 0; USBIIF = 0; +} + +void +ao_usb_disable(void) +{ + /* Disable USB interrupts */ + USBIIE = 0; + USBOIE = 0; + USBCIE = 0; + IEN2 &= ~IEN2_USBIE; + /* Clear any pending interrupts */ + USBCIF = 0; + USBOIF = 0; + USBIIF = 0; + + /* Turn off the USB controller */ + SLEEP &= ~SLEEP_USB_EN; +} + +void +ao_usb_init(void) +{ + ao_usb_enable(); + ao_add_task(&ao_usb_task, ao_usb_ep0, "usb"); } |