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

How Can I use Multiple Interrupts for Keypad

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdbool.h>
#include <stdint.h>
#include "boards.h"
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf.h"
#include "nrf_drv_gpiote.h"
#include "app_error.h"
#include "nrf_drv_timer.h"
#include "app_timer.h"
#include "app_button.h"
#include "nrf_drv_ppi.h"
#define PIN_IN BSP_BUTTON_3
#define PIN_IN_1 BSP_BUTTON_2
#define PIN_OUT BSP_LED_3
#define PIN_OUT_1 BSP_LED_2
//void Tarama_Basla(void)
//{
// nrf_gpio_cfg_output(PIN_OUT);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here is my code. I did it one button but i must add 4 button. How to use multiple pins for interrupt? 

Parents
  • Hi,

    Please have a look at the BSP Example. It should be close to what you need. You can change the event handler to something like this to get events from 4 buttons:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void bsp_evt_handler(bsp_event_t evt)
    {
    uint32_t err_code;
    switch (evt)
    {
    case BSP_EVENT_KEY_0:
    if (actual_state != BSP_INDICATE_FIRST)
    actual_state--;
    else
    actual_state = BSP_INDICATE_LAST;
    break;
    case BSP_EVENT_KEY_1:
    if (actual_state != BSP_INDICATE_LAST)
    actual_state++;
    else
    actual_state = BSP_INDICATE_FIRST;
    break;
    case BSP_EVENT_KEY_2:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Reply
  • Hi,

    Please have a look at the BSP Example. It should be close to what you need. You can change the event handler to something like this to get events from 4 buttons:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void bsp_evt_handler(bsp_event_t evt)
    {
    uint32_t err_code;
    switch (evt)
    {
    case BSP_EVENT_KEY_0:
    if (actual_state != BSP_INDICATE_FIRST)
    actual_state--;
    else
    actual_state = BSP_INDICATE_LAST;
    break;
    case BSP_EVENT_KEY_1:
    if (actual_state != BSP_INDICATE_LAST)
    actual_state++;
    else
    actual_state = BSP_INDICATE_FIRST;
    break;
    case BSP_EVENT_KEY_2:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Children
No Data