aboutsummaryrefslogtreecommitdiff
path: root/example-cdc/sample.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-05-16 14:59:05 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-05-16 14:59:05 +0900
commit06d046b9634568a7fd474fab49610a7070bd0e08 (patch)
tree284be1c1b1f6a74d5c5509ea8508561bac44bdaf /example-cdc/sample.c
parentb7c6dadcfbc8313e548f8e6c616bf1d7076144d7 (diff)
Improve system routines API for STM32F103
Diffstat (limited to 'example-cdc/sample.c')
-rw-r--r--example-cdc/sample.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/example-cdc/sample.c b/example-cdc/sample.c
index ee6d23f..9b9a4a6 100644
--- a/example-cdc/sample.c
+++ b/example-cdc/sample.c
@@ -65,24 +65,31 @@ usb_intr (void *arg)
chopstx_intr_t interrupt;
(void)arg;
- usb_lld_init (0x80); /* Bus powered. */
- chopstx_claim_irq (&interrupt, INTR_REQ_USB);
-
+#if defined(OLDER_SYS_H)
/*
+ * Historically (before sys < 3.0), NVIC priority setting for USB
+ * interrupt was done in usb_lld_sys_init. Thus this code.
+ *
* 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.
*
+ * 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.
+ *
*/
+ usb_lld_init (0x80); /* Bus powered. */
+ chopstx_claim_irq (&interrupt, INTR_REQ_USB);
usb_interrupt_handler ();
+#else
+ chopstx_claim_irq (&interrupt, INTR_REQ_USB);
+ usb_lld_init (0x80); /* Bus powered. */
+#endif
while (1)
{