0

Multiple GPIOTE ISRs [closed]

jhendr gravatar image

asked 2018-01-11 00:53:53 +0100

I'm working on a custom board with an nRF52382 connected to an IMU over I2C. The IMU provides 2 separate interrupt signals, and I would like to route each of them to a separate ISR. I've tried everything I can find on this site but still can't get the second ISR to fire. I've 'scoped the signal (P0:10 = physical pin 12) and it is pulsing low for 100ms. Here's my code:

   if(!nrf_drv_gpiote_is_init())
   {
       ret_code_t err_code = nrf_drv_gpiote_init();
       APP_ERROR_CHECK(err_code);
   }

  // P0:10 - IMU int2
   nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);        
   APP_ERROR_CHECK(nrf_drv_gpiote_in_init(SENSOR_IMU_INT2_PIN, &config, imu2Isr));   
   nrf_drv_gpiote_in_event_enable(SENSOR_IMU_INT2_PIN, true); 

  // P0:13 - IMU int1
  config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false);        
  APP_ERROR_CHECK(nrf_drv_gpiote_in_init(SENSOR_IMU_INT1_PIN, &config, imu1Isr));     
  nrf_drv_gpiote_in_event_enable(SENSOR_IMU_INT1_PIN, true);

static void imu1Isr(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
   if(SENSOR_IMU_INT1_PIN == pin)
   {    
      //memset(SensorData, 0x11, SENSOR_IMU_FULL_DATA_NBYTES);
      SensorRdSchedEvt_t xferParms;
      xferParms.cb = imuReadCallback; 
      xferParms.buf     = SensorData;
      xferParms.bytes   = SENSOR_IMU_FULL_DATA_NBYTES;  // Pull status and data registers
      xferParms.subAddr = SENSOR_IMU_START_IDX;         // Start at WAKE_UP_SRC
      APP_ERROR_CHECK( app_sched_event_put((void*)&xferParms, sizeof(xferParms), imuReadTask));
   }
   else if(SENSOR_IMU_INT2_PIN == pin)
   {
      SensorRdSchedEvt_t xferParms;
      xferParms.cb      = imuFStatReadCallback; 
      xferParms.buf     = ImuFStatData;
      xferParms.bytes   = SENSOR_IMU_FSTATUS_NBYTES;  // Pull stat%us and data registers
      xferParms.subAddr = LSM_REG_FSTAT1_IDX;         // Start at WAKE_UP_SRC
      APP_ERROR_CHECK( app_sched_event_put((void*)&xferParms, sizeof(xferParms), imuReadTask));
   }
}

static void imu2Isr(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
   if(SENSOR_IMU_INT2_PIN == pin)
   {    
      SensorRdSchedEvt_t xferParms;
      xferParms.cb      = imuFStatReadCallback; 
      xferParms.buf     = ImuFStatData;
      xferParms.bytes   = SENSOR_IMU_FSTATUS_NBYTES;  // Pull stat%us and data registers
      xferParms.subAddr = LSM_REG_FSTAT1_IDX;         // Start at WAKE_UP_SRC
      APP_ERROR_CHECK( app_sched_event_put((void*)&xferParms, sizeof(xferParms), imuReadTask));
   }
}

Can you see what I'm doing wrong? I'm using Segger Embedded Studio. Relatedly - if the interrupt signal is pulsed, I'll likely fire the ISR twice for each interrupt. How would one determine whether this is the first or second edge of the interrupt signal? Is there a better way than reading the signal level in the ISR? It seems that the "action" param of the ISR is going to be "toggle".

edit retag flag offensive reopen delete report spam

Closed as "the question is answered, right answer was accepted" by Martin Børs-Lind at 2018-01-15 17:09:08 +0100

1 answer

Sort by » oldest newest most voted
1
jhendr gravatar image

answered 2018-01-12 20:32:37 +0100

The issue was that P0:10 is associated with NFC by default. Adding the preprocessor definition CONFIG_NFCT_PINS_AS_GPIOS solved my problem.

edit flag offensive delete publish link more

User menu

    or sign up

Recent questions

Question Tools

1 follower

Stats

Asked: 2018-01-11 00:53:53 +0100

Seen: 36 times

Last updated: jan. 12