This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Build application from main.c

Hi everyone!

I'm new using Nordic Semiconductor products, I have a Nordic Thingy 91  running Asset Tracker application by default.

I want to test only specific things first, this case I want to run this main.c file in order to toggle the NMOS pins.  

#include <zephyr.h>
#include <misc/printk.h>
#include <gpio.h>

static struct device *gpio_dev;
static bool nmos_state = false;

void toggle_nmos() {
    nmos_state = !nmos_state;

    if (nmos_state) {
        // turn on 
        printk("Setting GPIO pin to 1, %d\n", gpio_pin_write(gpio_dev, 13, 1));
    }
    else {
        // turn off
        printk("Setting GPIO pin to 0, %d\n", gpio_pin_write(gpio_dev, 13, 0));
    }
}

void main(void)
{
    gpio_dev = device_get_binding("GPIO_0");
    gpio_pin_configure(gpio_dev, 16, GPIO_DIR_OUT);

    while (true) {
        toggle_nmos();
        k_sleep(2000);
    }
}

What other files or libraries I have to write in order to correctly build this application? The idea is to generate the app_signed.hex file, flash and test.

Thanks in advance,

Alejandro Ch.

Related