Tux Leon / mbed-dev

Fork of mbed-dev by mbed official

Revision:
181:96ed750bd169
Parent:
174:b96e65c34a4d
--- a/targets/TARGET_RENESAS/TARGET_RZ_A1H/us_ticker.c	Thu Dec 07 14:01:42 2017 +0000
+++ b/targets/TARGET_RENESAS/TARGET_RZ_A1H/us_ticker.c	Wed Jan 17 15:23:54 2018 +0000
@@ -21,6 +21,7 @@
 #include "RZ_A1_Init.h"
 #include "MBRZA1H.h"
 #include "vfp_neon_push_pop.h"
+#include "mbed_critical.h"
 
 #define US_TICKER_TIMER_IRQn (OSTMI1TINT_IRQn)
 #define CPG_STBCR5_BIT_MSTP50   (0x01u) /* OSTM1 */
@@ -62,6 +63,7 @@
     // INTC settings
     InterruptHandlerRegister(US_TICKER_TIMER_IRQn, (void (*)(uint32_t))us_ticker_interrupt);
     GIC_SetPriority(US_TICKER_TIMER_IRQn, 5);
+    GIC_SetConfiguration(US_TICKER_TIMER_IRQn, 3);
     GIC_EnableIRQ(US_TICKER_TIMER_IRQn);
 }
 
@@ -92,21 +94,13 @@
 }
 
 uint32_t us_ticker_read() {
-    int check_irq_masked;
-
-#if defined ( __ICCARM__)
-    check_irq_masked = __disable_irq_iar();
-#else
-    check_irq_masked = __disable_irq();
-#endif /* __ICCARM__ */
+    core_util_critical_section_enter();
 
     __vfp_neon_push();
     us_ticker_read_last();
     __vfp_neon_pop();
 
-    if (!check_irq_masked) {
-        __enable_irq();
-    }
+    core_util_critical_section_exit();
 
     /* clock to us */
     return (uint32_t)ticker_us_last64;