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

nrf5_calendar example callback function?

Hello,

I am using nrf52840 and SDK 16.0.0

I am doing some work with the calendar example and got some questions.

Q1.

Inside the main function in main.c file there is nrf_cal_set_callback(calendar_updated, 4); function. How it can be called multiple times even though it is defined before the while(true) loop? How does it work?

Q2.

I am integrating ble_app_template example with this calendar example. My beacon is broadcasting advertisement packets. If I wanna update manufacturer specific data(lets say a time stamp) every 1 second, is it possible to locate advertisement update function inside this call back function(nrf_cal_set_callback())?

Thank you.

Parents
  • Hi,

    Q1. When you call nrf_cal_set_callback(), this tells the nrf_calendar library which function to call with events. The callback will be called whenever the nrf_calendar library has an event for the application. The calendar library uses the RTC peripheral to keep track of time, which will generate interrupts on given conditions. From the interrupt handler, the application callback will be called if there are relevant events for the application.

    Q2. This looks ok to me.

    Best regards,
    Jørgen

  • Hello,

    Could you let me know if I understand everything correctly?

    So, inside the nrf_calendar.c file, this function below is the interrupt handler right?

    void CAL_RTC_IRQHandler(void)
    {
        if(CAL_RTC->EVENTS_COMPARE[0])
        {
            CAL_RTC->EVENTS_COMPARE[0] = 0;
            
            CAL_RTC->TASKS_CLEAR = 1;
            
            m_time += m_rtc_increment;
            if(cal_event_callback) cal_event_callback();
        }
    }

    Now, I have questions, what does this line mean?

    CAL_RTC->EVENTS_COMPARE[0]

Reply
  • Hello,

    Could you let me know if I understand everything correctly?

    So, inside the nrf_calendar.c file, this function below is the interrupt handler right?

    void CAL_RTC_IRQHandler(void)
    {
        if(CAL_RTC->EVENTS_COMPARE[0])
        {
            CAL_RTC->EVENTS_COMPARE[0] = 0;
            
            CAL_RTC->TASKS_CLEAR = 1;
            
            m_time += m_rtc_increment;
            if(cal_event_callback) cal_event_callback();
        }
    }

    Now, I have questions, what does this line mean?

    CAL_RTC->EVENTS_COMPARE[0]

Children
No Data
Related