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

Radio timeslot signal and event callback function timing problem

I have a function with a return value in the time slot, after the function is done inside the time slot signal callback function, I want to use the event callback function to decide the further action according the function's return value. However, it seems the event callback function is started before my function in the time slot is done. the code is like

uint32_t   RETURN_VALUE_TIMESLOT_SIGNAL = 0xff;

/********************************************************************************/
nrf_radio_signal_callback_return_param_t *time_slot_callback(uint8_t signal_type)
{	
  switch(signal_type)
  {
    case NRF_RADIO_CALLBACK_SIGNAL_TYPE_START:
	{
	  /* set the time slot callback return parameters */
      signal_callback_return_param.params.request.p_next = NULL;
      signal_callback_return_param.callback_action = NRF_RADIO_SIGNAL_CALLBACK_ACTION_END;
			
      /* call my function */
	  RETURN_VALUE_TIMESLOT_SIGNAL = my_function_call();
			
	  break;
    }
		
	case ...
	{
			.......
	}
  }

  return (&signal_callback_return_param);
}

/********************************************************************************/
void nrf_evt_signal_handler(uint32_t evt_id)
{
  switch (evt_id)
  {
    case NRF_EVT_RADIO_SESSION_IDLE:
	{
	  if (RETURN_VALUE_TIMESLOT_SIGNAL == 0)
	  {
	    ......
	  }
	  else
	  {
	    ......
	  }
    }
		
	case ...
	{
	  ......
	}
  }
}

My observation is, even my function has a return value of 0, but inside event callback function "nrf_evt_signal_handler", it value is still the initial value 0xff, and after some time it become 0. this means the function "nrf_evt_signal_handler" is started before function "time_slot_callback" finished.

I added several lines code to print out the value of RETURN_VALUE_TIMESLOT_SIGNAL inside "nrf_evt_signal_handler" as:

/********************************************************************************/
void nrf_evt_signal_handler(uint32_t evt_id)
{
  switch (evt_id)
  {
    case NRF_EVT_RADIO_SESSION_IDLE:
    {
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      printf("RETURN_VALUE_TIMESLOT_SIGNAL = %ld\r\n", RETURN_VALUE_TIMESLOT_SIGNAL);
      
      if (RETURN_VALUE_TIMESLOT_SIGNAL == 0)
      {
        ......
      }
      else
      {
        ......
      }
    }

    case ...
    {
      ......
    }
  }
}

The printf output is as

RETURN_VALUE_TIMESLOT_SIGNAL = 255
RETURN_VALUE_TIMESLOT_SIGNAL = 255
RETURN_VALUE_TIMESLOT_SIGNAL = 255
RETURN_VALUE_TIMESLOT_SIGNAL = 255
RETURN_VALUE_TIMESLOT_SIGNAL = 0
RETURN_VALUE_TIMESLOT_SIGNAL = 0
RETURN_VALUE_TIMESLOT_SIGNAL = 0
RETURN_VALUE_TIMESLOT_SIGNAL = 0
RETURN_VALUE_TIMESLOT_SIGNAL = 0

My question is: How to let the time slot event callback function "nrf_evt_signal_handler" is started after function "time_slot_callback" is completely finished?

Thanks a lot.

Parents Reply Children
No Data
Related