/* src/main.c
 * Copyright (c) 2016 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>

LOG_MODULE_REGISTER(blinky_app, LOG_LEVEL_INF); // You can choose a different name than "blinky_app"


/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS   1000

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)
#define DBG_PIN NRF_GPIO_PIN_MAP(1,5)                 // LED0 P1.8

/*
 * A build error on this line means your board is unsupported.
 * See the sample documentation for information on how to fix this.
 */
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);

int main(void)
{
	int ret;

	if (!gpio_is_ready_dt(&led)) {
		return 0;
	}

	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
	if (ret < 0) {
		return 0;
	}
    ret = nrf_gpio_cfg_output(DBG_PIN); // config the as output pin
	if (ret < 0){
		LOG_INF("LINE ERROR  %d",__LINE__);
	}

	while (1) {
		ret = nrf_gpio_pin_toggle(DBG_PIN);
		if (ret < 0){
			LOG_INF("LINE ERROR  %d",__LINE__);
		}

		ret = gpio_pin_toggle_dt(&led);
		if (ret < 0) {
			return 0;
		}
		printf("Hello World! HI MOM, its me %s\n", CONFIG_BOARD);
		LOG_INF("LINE a %d",__LINE__);


		k_msleep(SLEEP_TIME_MS);
	}
	return 0;
}

