mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Revision:
188:bcfe06ba3d64
Parent:
187:0387e8f68319
--- a/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c	Thu Sep 06 13:40:20 2018 +0100
+++ b/targets/TARGET_NUVOTON/TARGET_M2351/us_ticker.c	Thu Nov 08 11:46:34 2018 +0000
@@ -75,8 +75,6 @@
         /* By HAL spec, ticker_init allows the ticker to keep counting and disables the
          * ticker interrupt. */
         us_ticker_disable_interrupt();
-        us_ticker_clear_interrupt();
-        NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
         return;
     }
     ticker_inited = 1;
@@ -125,16 +123,7 @@
 
 void us_ticker_free(void)
 {
-    TIMER_T *timer_base = (TIMER_T *) NU_MODBASE(TIMER_MODINIT.modname);
-
-    /* Stop counting */
-    TIMER_Stop(timer_base);
-
-    /* Wait for timer to stop counting and unset active flag */
-    while((timer_base->CTL & TIMER_CTL_ACTSTS_Msk));
-
     /* Disable interrupt */
-    TIMER_DisableInt(timer_base);
     NVIC_DisableIRQ(TIMER_MODINIT.irq_n);
 
     /* Disable IP clock
@@ -159,6 +148,10 @@
 
 void us_ticker_set_interrupt(timestamp_t timestamp)
 {
+    /* Clear any previously pending interrupts */
+    us_ticker_clear_interrupt();
+    NVIC_ClearPendingIRQ(TIMER_MODINIT.irq_n);
+
     /* In continuous mode, counter will be reset to zero with the following sequence: 
      * 1. Stop counting
      * 2. Configure new CMP value