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

Why gpiote_init used 2 times?

Hi All,

     i would like to know in ble_app_hrs example gpiote_init() is called from main
     and then again called in led_start for what purpose it used in 2 place.

     can anyone  please share information related to it.

Thanks

Parents
  • You have two gpiote_init() functions.

    In main.c:

    static void gpiote_init(void)
    {
        APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    }
    

    And in led.c:

    static void gpiote_init(void)
    {
        // Configure the GPIOTE Task to toggle the LED state.
        nrf_gpiote_task_config(GPIOTE_CHAN_FOR_LED_TASK,
                               ADVERTISING_LED_PIN_NO,
                               NRF_GPIOTE_POLARITY_TOGGLE,
                               NRF_GPIOTE_INITIAL_VALUE_LOW);
    }
    

    These are both static functions, meaning that they do not "exist" outside the file that they are declared in. The gpiote_init in main.c initializes the GPIOTE module with APP_GPIOTE_MAX_USERS, while the one in led.c makes use of the GPIOTE task and configures it. The PPI module then assigns the NRF_TIMER1->EVENTS_COMPARE[0] to the previously configured GPIOTE task.

Reply
  • You have two gpiote_init() functions.

    In main.c:

    static void gpiote_init(void)
    {
        APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    }
    

    And in led.c:

    static void gpiote_init(void)
    {
        // Configure the GPIOTE Task to toggle the LED state.
        nrf_gpiote_task_config(GPIOTE_CHAN_FOR_LED_TASK,
                               ADVERTISING_LED_PIN_NO,
                               NRF_GPIOTE_POLARITY_TOGGLE,
                               NRF_GPIOTE_INITIAL_VALUE_LOW);
    }
    

    These are both static functions, meaning that they do not "exist" outside the file that they are declared in. The gpiote_init in main.c initializes the GPIOTE module with APP_GPIOTE_MAX_USERS, while the one in led.c makes use of the GPIOTE task and configures it. The PPI module then assigns the NRF_TIMER1->EVENTS_COMPARE[0] to the previously configured GPIOTE task.

Children
No Data
Related