Dear All,
I am fairly new to the nrf9160 and the Zephyr Os.
I am trying to write a simple example code for watchdog. All I want to do is to reset my board if I don't feed it for 2 seconds. I am using trying to use the ncs\zephyr\tests\drivers\watchdog test code as the base for my own code. What I have written so far is this:
#include <zephyr.h>
#include <misc/printk.h>
#include <uart.h>
#include <gpio.h>
#include <watchdog.h>
static struct device *led1;
static struct device *wdt;
static struct wdt_timeout_cfg m_cfg_wdt0;
static void wdt_int_cb(struct device *wdt_dev, int channel_id)
{
printk("Here\n");
}
void main(void)
{
led1 = device_get_binding(LED_PORT1);
/* Set LED pin as output */
gpio_pin_configure(led1, LED1, GPIO_DIR_OUT);
gpio_pin_write(led1, LED1, 1);
wdt = device_get_binding("DT_WDT_0_NAME");
m_cfg_wdt0.flags = WDT_FLAG_RESET_SOC;
m_cfg_wdt0.callback = wdt_int_cb;
m_cfg_wdt0.window.max = 2000U;
if (wdt_install_timeout(wdt, &m_cfg_wdt0) < 0) {
printk("Error installing watchdog");
}
if (wdt_setup(wdt, 0) < 0) {
printk("Error setting up watchdog");
}
printk("Watchdog sample code start!\n");
while (1) {
k_cpu_idle();
}
}
Furthermore my prj.conf looks like this:
CONFIG_TRUSTED_EXECUTION_NONSECURE=y CONFIG_GPIO=y CONFIG_WATCHDOG=y CONFIG_BOOT_BANNER=n
But this code won't run