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

how to disable interrupts before SD gets active

Hi there,

I am using the uart example with SD130 and added neopixel code from GIT to drive the WS2812B LEDs using bit banging. I want to update the LED every ms. The bitbanging sequence used in neopixel_show(&m_strip); must not be interrupted. To achieve this I am using this code

ble_radio_notification_init(NRF_RADIO_PRIORITY_NORMAL ,
       NRF_RADIO_NOTIFICATION_DISTANCE_800US,
       led_radio_callback_handler);

void led_radio_callback_handler(bool radio_active)                    
{
			if (radio_active == false)
			{
				softdevice_active = false;                                                                                 
			} else {                                                                       
				softdevice_active = true;
			}					             
}

static void ms_timeout_handler(void * p_context)																// 1ms Timer
{
    // uint32_t err_code;
    UNUSED_PARAMETER(p_context);
	
		// nrf_drv_gpiote_out_toggle(BSP_LED_2);
		// ms_timer_ticks++;
	  if (softdevice_active == false)
		{
			// CRITICAL_REGION_ENTER(); 
			// sd_nvic_critical_region_enter(&p_is_nested_critical_region);
			__disable_irq();
			neopixel_show(&m_strip);
			__enable_irq(); 
			// CRITICAL_REGION_EXIT();
			// sd_nvic_critical_region_exit(p_is_nested_critical_region);
                } else {
			nrf_drv_gpiote_out_toggle(BSP_LED_2);
		}
}

The above code works but I read in a different thread that it is not recommened to use __disable_irq() together with a SD. The the other two methods that are outcommented do not work proberly. I still get interrupts just before the notfication:

image description

The question is:

Can I use __disable_irq() in this special case or what would be your recommendation?

Thanks

Peter

Related