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

clear external interrupt

link text from this post i am generating interrupt using button 3. when i push my button,interrupt generates,LED turn on. but after turning on LED, i want to clear interrupt. so LED become off.here i don't want to use nrf_drv_gpiote_out_toggle(); function. my code is here

void gpiote_evt_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    switch(action)
    {
       case NRF_GPIOTE_POLARITY_HITOLO:
			
			 nrf_drv_gpiote_out_clear(LED_3);	
            break;
        default:
            
            break;
    }
} 
Parents
  • int main(void) { uint32_t err_code; bool erase_bonds; ret_code_t ret_code;

            // Initialize.
         
            ble_stack_init();
            gap_params_init();
            services_init();
            advertising_init();
        	advertising_start();
            conn_params_init();
            
           
           
             ret_code = nrf_drv_gpiote_init();
           // APP_ERROR_CHECK(ret_code);
            
            // Configure LED_1 pin as output
            nrf_drv_gpiote_out_config_t led_config = GPIOTE_CONFIG_OUT_TASK_LOW;
            
            // Initialize LED_1 pin as output
            ret_code =  nrf_drv_gpiote_out_init(LED_3, &led_config);
          //  APP_ERROR_CHECK(ret_code);
        	    nrf_drv_gpiote_in_config_t config =
            {
                .sense = NRF_GPIOTE_POLARITY_HITOLO,
        			//.sense = NRF_GPIOTE_POLARITY_LOTOHI,
                .pull = NRF_GPIO_PIN_PULLUP , // NRF_GPIO_PIN_NOPULL
        		//.pull = NRF_GPIO_PIN_NOPULL ,
                .is_watcher = false,
                .hi_accuracy = false
            };
                
            // Initialize Interrupt Pin
            ret_code = nrf_drv_gpiote_in_init(INTERRUPT_PIN, &config, gpiote_evt_handler);
          APP_ERROR_CHECK(ret_code);
            
            // Enable Interrupts from interrupt pin
           nrf_drv_gpiote_in_event_enable(INTERRUPT_PIN,true);
            // Enter main loop.
            while(true)
            { 
               	
            }
    
    }
    
Reply
  • int main(void) { uint32_t err_code; bool erase_bonds; ret_code_t ret_code;

            // Initialize.
         
            ble_stack_init();
            gap_params_init();
            services_init();
            advertising_init();
        	advertising_start();
            conn_params_init();
            
           
           
             ret_code = nrf_drv_gpiote_init();
           // APP_ERROR_CHECK(ret_code);
            
            // Configure LED_1 pin as output
            nrf_drv_gpiote_out_config_t led_config = GPIOTE_CONFIG_OUT_TASK_LOW;
            
            // Initialize LED_1 pin as output
            ret_code =  nrf_drv_gpiote_out_init(LED_3, &led_config);
          //  APP_ERROR_CHECK(ret_code);
        	    nrf_drv_gpiote_in_config_t config =
            {
                .sense = NRF_GPIOTE_POLARITY_HITOLO,
        			//.sense = NRF_GPIOTE_POLARITY_LOTOHI,
                .pull = NRF_GPIO_PIN_PULLUP , // NRF_GPIO_PIN_NOPULL
        		//.pull = NRF_GPIO_PIN_NOPULL ,
                .is_watcher = false,
                .hi_accuracy = false
            };
                
            // Initialize Interrupt Pin
            ret_code = nrf_drv_gpiote_in_init(INTERRUPT_PIN, &config, gpiote_evt_handler);
          APP_ERROR_CHECK(ret_code);
            
            // Enable Interrupts from interrupt pin
           nrf_drv_gpiote_in_event_enable(INTERRUPT_PIN,true);
            // Enter main loop.
            while(true)
            { 
               	
            }
    
    }
    
Children
No Data
Related