You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/09/22 21:15:34 UTC
[2/2] incubator-mynewt-core git commit: add watchdog implementation
for nordic, simplify hal_watchdog by making hal_watchdog_enable() return void.
add watchdog implementation for nordic, simplify hal_watchdog by making hal_watchdog_enable() return void.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/94737dee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/94737dee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/94737dee
Branch: refs/heads/develop
Commit: 94737dee6a63970586e51f8011a0c0f14e22806a
Parents: 9714934
Author: Sterling Hughes <st...@apache.org>
Authored: Thu Sep 22 14:15:22 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Thu Sep 22 14:15:22 2016 -0700
----------------------------------------------------------------------
hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c | 66 ++++++++++++++++++++++++++
hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c | 66 ++++++++++++++++++++++++++
2 files changed, 132 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/94737dee/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c b/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
new file mode 100644
index 0000000..486aeec
--- /dev/null
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "hal/hal_watchdog.h"
+
+#include <assert.h>
+
+#include "app_util_platform.h"
+#include "nrf.h"
+#include "nrf_wdt.h"
+#include "nrf_drv_wdt.h"
+
+static void
+nrf51_hal_wdt_default_handler(void)
+{
+ assert(0);
+}
+
+int
+hal_watchdog_init(int expire_secs)
+{
+ nrf_drv_wdt_config_t cfg;
+ int rc;
+
+ cfg.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP;
+ cfg.interrupt_priority = WDT_CONFIG_IRQ_PRIORITY;
+ cfg.reload_value = (uint32_t) expire_secs;
+
+ rc = nrf_drv_wdt_init(&cfg, nrf51_hal_wdt_default_handler);
+ if (rc != 0) {
+ goto err;
+ }
+
+ return (0);
+err:
+ return (rc);
+}
+
+void
+hal_watchdog_enable(void)
+{
+ nrf_drv_wdt_enable();
+}
+
+void
+hal_watchdog_tickle(void)
+{
+ nrf_drv_wdt_feed();
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/94737dee/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
new file mode 100644
index 0000000..6ba1aba
--- /dev/null
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "hal/hal_watchdog.h"
+
+#include <assert.h>
+
+#include "app_util_platform.h"
+#include "nrf.h"
+#include "nrf_wdt.h"
+#include "nrf_drv_wdt.h"
+
+static void
+nrf52_hal_wdt_default_handler(void)
+{
+ assert(0);
+}
+
+int
+hal_watchdog_init(int expire_secs)
+{
+ nrf_drv_wdt_config_t cfg;
+ int rc;
+
+ cfg.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP;
+ cfg.interrupt_priority = WDT_CONFIG_IRQ_PRIORITY;
+ cfg.reload_value = (uint32_t) expire_secs;
+
+ rc = nrf_drv_wdt_init(&cfg, nrf52_hal_wdt_default_handler);
+ if (rc != 0) {
+ goto err;
+ }
+
+ return (0);
+err:
+ return (rc);
+}
+
+void
+hal_watchdog_enable(void)
+{
+ nrf_drv_wdt_enable();
+}
+
+void
+hal_watchdog_tickle(void)
+{
+ nrf_drv_wdt_feed();
+}
+