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

Source code (main.c) of "thingy91_nbiot_legacy_pco_dfu"

Hi everyone!

I'm running my Nordic Thingy 91 with "thingy91_nbiot_legacy_pco_dfu" and it works great!

Now, i want to make some specifics editions in the main code in order to add one new feature for my project. My question is:

Where can i find the "main.c" file to add my new function? And then compile and flash.

Parents Reply Children
  • Hmm. I'm not sure what could cause this. How have you updated your code?

    I had to do quite a lot of changes in order to compile it, so you could have a look at my main.c:

    #include <zephyr.h>
    #include <sys/printk.h>
    #include <drivers/gpio.h>
    
    static const 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_set(gpio_dev, 16, 1));
        }
        else {
            // turn off
            printk("Setting GPIO pin to 0, %d\n", gpio_pin_set(gpio_dev, 16, 0));
        }
    }
    
    void main(void)
    {
        gpio_dev = device_get_binding("GPIO_0");
        gpio_pin_configure(gpio_dev, 16, GPIO_OUTPUT);
    
        while (true) {
            toggle_nmos();
            k_sleep(K_MSEC(3000));
        }
    }


    Best regards,
    Carl Richard

Related