mbed library sources. Supersedes mbed-src.

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

Revision:
188:bcfe06ba3d64
Parent:
184:08ed48f1de7f
--- a/targets/TARGET_NUVOTON/nu_timer.h	Thu Sep 06 13:40:20 2018 +0100
+++ b/targets/TARGET_NUVOTON/nu_timer.h	Thu Nov 08 11:46:34 2018 +0000
@@ -20,8 +20,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include "cmsis.h"
-#include "mbed_power_mgmt.h"
-#include "mbed_critical.h"
 #include "ticker_api.h"
 #include "us_ticker_api.h"
 
@@ -58,33 +56,26 @@
     bool                    _expired;           // Expired or not
 };
 
-__STATIC_INLINE void nu_countdown_init(struct nu_countdown_ctx_s *ctx, us_timestamp_t interval_us)
-{
-    core_util_critical_section_enter();
-    sleep_manager_lock_deep_sleep();
-    ctx->_ticker_data = get_us_ticker_data();
-    ctx->_interval_end_us = ticker_read_us(ctx->_ticker_data) + interval_us;
-    ctx->_expired = false;
-    core_util_critical_section_exit();
-}
+void nu_countdown_init(struct nu_countdown_ctx_s *ctx, us_timestamp_t interval_us);
+bool nu_countdown_expired(struct nu_countdown_ctx_s *ctx);
+void nu_countdown_free(struct nu_countdown_ctx_s *ctx);
+
 
-__STATIC_INLINE bool nu_countdown_expired(struct nu_countdown_ctx_s *ctx)
-{
-    core_util_critical_section_enter();
-    if (! ctx->_expired) {
-        ctx->_expired = ticker_read_us(ctx->_ticker_data) >= ctx->_interval_end_us;
-    }
-    core_util_critical_section_exit();
-    
-    return ctx->_expired;
-}
+/* Replacement for wait_us when intermediary us ticker layer is disabled
+ *
+ * Use of wait_us directly from the low power ticker causes the system to deadlock during
+ * the sleep test because the sleep test disables the intermediary us ticker layer during
+ * the test.
+ *
+ * To prevent this lockup, nu_busy_wait_us is created to replace wait_us, which uses the us ticker
+ * directly rather than go though the intermediary us ticker layer.
+ *
+ * During wait period through nu_busy_wait_us, CPU would be busy spinning. 
+ */
+void nu_busy_wait_us(uint32_t us);
 
-__STATIC_INLINE void nu_countdown_free(struct nu_countdown_ctx_s *ctx)
-{
-    core_util_critical_section_enter();
-    sleep_manager_unlock_deep_sleep();
-    core_util_critical_section_exit();
-}
+/* Delay 4 cycles per round by hand-counting instruction cycles */
+void nu_delay_cycle_x4(uint32_t rounds);  
 
 #ifdef __cplusplus
 }