You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/11/23 01:01:07 UTC

[GitHub] ccollins476ad closed pull request #675: apollo2 - Ensure OS tick timer is running.

ccollins476ad closed pull request #675: apollo2 - Ensure OS tick timer is running.
URL: https://github.com/apache/mynewt-core/pull/675
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/ambiq/apollo2/src/hal_os_tick.c b/hw/mcu/ambiq/apollo2/src/hal_os_tick.c
index 7db55cb60..5d376a85a 100644
--- a/hw/mcu/ambiq/apollo2/src/hal_os_tick.c
+++ b/hw/mcu/ambiq/apollo2/src/hal_os_tick.c
@@ -114,6 +114,8 @@ os_tick_idle(os_time_t ticks)
 void
 os_tick_init(uint32_t os_ticks_per_sec, int prio)
 {
+    os_sr_t sr;
+
     /* Reset the timer to 0. */
     am_hal_stimer_counter_clear();
 
@@ -131,4 +133,9 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio)
     NVIC_SetPriority(APOLLO2_OS_TICK_IRQ, prio);
     NVIC_SetVector(APOLLO2_OS_TICK_IRQ, (uint32_t)apollo2_os_tick_handler);
     NVIC_EnableIRQ(APOLLO2_OS_TICK_IRQ);
+
+    /* Schedule timer to interrupt at the next tick. */
+    OS_ENTER_CRITICAL(sr);
+    apollo2_os_tick_set_timer(1);
+    OS_EXIT_CRITICAL(sr);
 }
diff --git a/hw/mcu/ambiq/apollo2/src/hal_timer.c b/hw/mcu/ambiq/apollo2/src/hal_timer.c
index 230d4ac94..c0fbe160c 100644
--- a/hw/mcu/ambiq/apollo2/src/hal_timer.c
+++ b/hw/mcu/ambiq/apollo2/src/hal_timer.c
@@ -206,35 +206,33 @@ apollo2_timer_sdk_cfg(const struct apollo2_timer_cfg *cfg, uint32_t freq_hz,
         entry = apollo2_timer_tbl_find(apollo2_timer_tbl_hfrc, freq_hz);
         *out_actual_hz = entry->freq;
         *out_cfg = entry->cfg;
-        break;
+        return 0;
 
     case APOLLO2_TIMER_SOURCE_XT:
         entry = apollo2_timer_tbl_find(apollo2_timer_tbl_xt, freq_hz);
         *out_actual_hz = entry->freq;
         *out_cfg = entry->cfg;
-        break;
+        return 0;
 
     case APOLLO2_TIMER_SOURCE_LFRC:
         entry = apollo2_timer_tbl_find(apollo2_timer_tbl_lfrc, freq_hz);
         *out_actual_hz = entry->freq;
         *out_cfg = entry->cfg;
-        break;
+        return 0;
 
     case APOLLO2_TIMER_SOURCE_RTC:
         *out_actual_hz = 100;
         *out_cfg = AM_HAL_CTIMER_RTC_100HZ;
-        break;
+        return 0;
 
     case APOLLO2_TIMER_SOURCE_HCLK:
         *out_actual_hz = 48000000;
         *out_cfg = AM_HAL_CTIMER_HCLK;
-        break;
+        return 0;
 
     default:
         return SYS_EINVAL;
     }
-
-    return 0;
 }
 
 /**
@@ -781,8 +779,7 @@ hal_timer_stop(struct hal_timer *timer)
     if (reset_ocmp) {
         timer = TAILQ_FIRST(&bsp_timer->hal_timer_q);
         if (timer != NULL) {
-            TAILQ_REMOVE(&bsp_timer->hal_timer_q, timer, link);
-            hal_timer_start_at(timer, timer->expiry);
+            apollo2_timer_set_ocmp_at(bsp_timer, timer->expiry);
         } else {
             apollo2_timer_clear_ocmp(bsp_timer);
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services