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

How can i set the key on my project board?

I have a project bord which base on nrf9160, two buttons are set in the hardware circuit, corresponding to the pins of P26 and p15 respectively, and P07 is used as the interrupt. Now i find a problem, that is ncsv1.2.0 default P07 as a key on DK board, which will cause the interrupt signal to be treated as a key. Therefore, how can I shield the default key on DK board(P06,P07,P08,P09) and use my custom key? 

Parents
  • Hello, 

    You are using a nRF9160DK to run your custom project or a sample project? P06,P07,P08,P09 are controlled by board controller.

    Kind regards,
    Øyvind

  • No, i run the project on my own board, in this board, i use p07 as an interrupt signal pin, However, when the interrupt was triggered, I found that it was actually handled by the button handler function, i want to use my custom key, is not use the default button key(P06,P07,P08P,P09), because these pins have already been used for other purposes.

    static void button_handler(u32_t button_state, u32_t has_changed)
    {
    	int err_code;
    
    	u32_t buttons = (button_state & has_changed);
    
    	keycode = has_changed;
    	keytype = button_state/has_changed;
    	
    	switch(keytype)
    	{
    	case KEY_DOWN:
    		k_timer_start(&g_long_press_timer_id, K_MSEC(TIMER_FOR_LONG_PRESSED), K_NO_WAIT);
    		break;
    		
    	case KEY_UP:
    		k_timer_stop(&g_long_press_timer_id);
    		break;
    
    	case KEY_LONG_PRESS:
    		break;
    	}
    
    	key_event_handler(keycode, keytype);
    }
    
    static void long_press_timer_handler(struct k_timer *timer)
    {
        key_event_handler(keycode, KEY_LONG_PRESS);
    }
    
    void key_init(void)
    {
    	int err;
    
    	printk("key_init\n");
    	
    	err = dk_buttons_init(button_handler);
    	if (err)
    	{
    		printk("Could not initialize buttons, err code: %d\n", err);
    		return;
    	}
    
    	k_timer_init(&g_long_press_timer_id, long_press_timer_handler, NULL);
    }

Reply
  • No, i run the project on my own board, in this board, i use p07 as an interrupt signal pin, However, when the interrupt was triggered, I found that it was actually handled by the button handler function, i want to use my custom key, is not use the default button key(P06,P07,P08P,P09), because these pins have already been used for other purposes.

    static void button_handler(u32_t button_state, u32_t has_changed)
    {
    	int err_code;
    
    	u32_t buttons = (button_state & has_changed);
    
    	keycode = has_changed;
    	keytype = button_state/has_changed;
    	
    	switch(keytype)
    	{
    	case KEY_DOWN:
    		k_timer_start(&g_long_press_timer_id, K_MSEC(TIMER_FOR_LONG_PRESSED), K_NO_WAIT);
    		break;
    		
    	case KEY_UP:
    		k_timer_stop(&g_long_press_timer_id);
    		break;
    
    	case KEY_LONG_PRESS:
    		break;
    	}
    
    	key_event_handler(keycode, keytype);
    }
    
    static void long_press_timer_handler(struct k_timer *timer)
    {
        key_event_handler(keycode, KEY_LONG_PRESS);
    }
    
    void key_init(void)
    {
    	int err;
    
    	printk("key_init\n");
    	
    	err = dk_buttons_init(button_handler);
    	if (err)
    	{
    		printk("Could not initialize buttons, err code: %d\n", err);
    		return;
    	}
    
    	k_timer_init(&g_long_press_timer_id, long_press_timer_handler, NULL);
    }

Children
Related