summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/main.cpp b/main.cpp
index baad038..04fcae8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -19,9 +19,9 @@ static Pin& usb_vbus = PA9;
template<>
void interrupt<(Interrupt::IRQ)67>() {
- led_blue.toggle();
led_red.toggle();
-
+
+ // USB reset.
if(OTG_FS.reg.GINTSTS & (1 << 12)) {
led_yellow.toggle();
OTG_FS.dev_oep_reg[0].DOEPCTL = (1 << 27);
@@ -32,6 +32,13 @@ void interrupt<(Interrupt::IRQ)67>() {
OTG_FS.dev_oep_reg[0].DOEPTSIZ = (3 << 29);
}
+ // OTG interrupt.
+ if(OTG_FS.reg.GINTSTS & (1 << 2)) {
+ led_blue.toggle();
+
+ OTG_FS.reg.GOTGINT = (1 << 2); // SEDET
+ }
+
OTG_FS.reg.GINTSTS = 0xffffffff;
}
@@ -49,8 +56,9 @@ int main() {
led_red.set_mode(Pin::Output);
led_blue.set_mode(Pin::Output);
- led_red.on();
+ led_red.off();
led_blue.off();
+ led_yellow.off();
usb_vbus.set_mode(Pin::AF);
usb_vbus.set_pull(Pin::PullNone);