summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2013-06-19 09:14:40 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2013-06-19 09:14:40 +0900
commitb65635756347245c8ea52e9ba2b6f1576834140b (patch)
tree755bbed2cc99967a5205721ea8af93aa7611596e
parent7f2415f3a2c7aa49468d8f9195f3d31c5653b769 (diff)
fix example-cdc/sample.c
-rw-r--r--ChangeLog5
-rw-r--r--example-cdc/sample.c20
2 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index b18f436..199f5a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-06-19 Niibe Yutaka <gniibe@fsij.org>
+
+ * example-cdc/sample.c (usb_intr): No disable/enable interrupt,
+ but call the handler.
+
2013-06-13 Niibe Yutaka <gniibe@fsij.org>
* chopstx.c (chopstx_usec_wait_var): Rename (was:
diff --git a/example-cdc/sample.c b/example-cdc/sample.c
index 0451049..c95680f 100644
--- a/example-cdc/sample.c
+++ b/example-cdc/sample.c
@@ -66,12 +66,24 @@ usb_intr (void *arg)
chopstx_intr_t interrupt;
(void)arg;
- asm volatile ("cpsid i" : : : "memory");
- /* Disable because of usb_lld_init assumes interrupt handler. */
usb_lld_init (0x80); /* Bus powered. */
chopstx_claim_irq (&interrupt, INTR_REQ_USB);
- /* Enable */
- asm volatile ("cpsie i" : : : "memory");
+
+ /*
+ * When USB interrupt occurs between usb_lld_init (which assumes
+ * ISR) and chopstx_claim_irq (which clears pending interrupt),
+ * invocation of usb_interrupt_handler won't occur.
+ *
+ * We can't call usb_lld_init after chopstx_claim_irq, as
+ * usb_lld_init does its own setting for NVIC. Calling
+ * chopstx_claim_irq after usb_lld_init overrides that.
+ *
+ * Calling usb_interrupt_handler is no harm even if there were no
+ * interrupts, thus, we call it unconditionally here, just in case
+ * if there is a request.
+ *
+ */
+ usb_interrupt_handler ();
while (1)
{