GPIO interrupt not linked using zephyr API


Vikrant More <vikrant8051@...>
 

Hello,

//----------------------------------------------------------------------------------------------------------------------------

#include <zephyr.h>
#include <misc/printk.h>

#include "nrf_delay.h"
#include "nrf_gpio.h"

#include "board.h"


#define  SETB(x,y)   (x|=(1<<y))     //for o/p
#define  CLRB(x,y)   (x&=(~(1<<y)))  //for o/p
#define  TGLB(x,y)   (x^=(1<<y))     //for o/p
#define  CHECKB(x,y) (x&(1<<y))      //for i/p

void GPIOTE_IRQHandler(void *arg)
{
  if(NRF_GPIOTE->EVENTS_IN[0]==1)
  {
    NRF_GPIOTE->EVENTS_IN[0]=0;
    NRF_P0->OUT ^= (1<<15); //LED3
  }
}

void gpio_init(void)
{
 
  NRF_P0->DIR |= 0x0001E000;
  NRF_P0->OUTSET |= 0x0001E000;

  NRF_P0->PIN_CNF[11]=0x0000000C;


  NRF_GPIOTE->INTENSET |= 0x00000001;                         
  NRF_GPIOTE->CONFIG[0] |= 0x00000001 | (11<<8) | (2<<16);

  //NVIC_EnableIRQ(GPIOTE_IRQn);

  IRQ_CONNECT(6,1,GPIOTE_IRQHandler,0,0);
  irq_enable(6);
}

void main(void)
{
    printk("Hello World! %s\n", CONFIG_ARCH);
    gpio_init();

    while(1)
    {
        NRF_P0->OUT ^= (1<<13); //LED1
        nrf_delay_ms(20);

        /*(Polling Method)
        if(CHECKB(NRF_P0->IN,11)==0)
        {

            while(CHECKB(NRF_P0->IN,11)==0){} 

            printk("Button Pressed !!\n\r");

            NRF_P0->OUT ^= (1<<16); //LED4

        }
        */
    }
}

//---------------------------------------------------------------------------------------------------------------------------------------

This is my simple code in which I want to enable button pressed interrupt.

My board is nrf52840_pca10056.

Button1 is attached to P0.11.
Using polling method, I'm able to toggle on board LED4. But same is not happing with interrupt.
Code gets compile without any error. But don't know why interrupt is not working.

I've also add following config parameters in prj.conf

CONFIG_GPIO=y
CONFIG_GPIO_NRF5_P0=y
CONFIG_GPIO_NRF5_P0_DEV_NAME="SW0_GPIO_PIN"
CONFIG_GPIO_NRF5_PORT_P0_PRI=6



For reference I'm using this link -> http://docs.zephyrproject.org/kernel/other/interrupts.html

Join {users@lists.zephyrproject.org to automatically receive all group messages.