static int lis2dw12_sensor_handle_interrupt(struct sensor * sensor) { struct lis2dw12 * lis2dw12; struct lis2dw12_private_driver_data *pdd; struct sensor_itf *itf; uint8_t int_src; int rc; lis2dw12 = (struct lis2dw12 *)SENSOR_GET_DEVICE(sensor); itf = SENSOR_GET_ITF(sensor); pdd = &lis2dw12->pdd; rc = lis2dw12_clear_int(itf, &int_src); if (rc) { LIS2DW12_ERR("Cound not read int status err=0x%02x\n", rc); return rc; } if ((pdd->registered_mask & LIS2DW12_NOTIFY_MASK) && ((int_src & LIS2DW12_INT_SRC_STAP) || (int_src & LIS2DW12_INT_SRC_DTAP))) { sensor_mgr_put_notify_evt(&pdd->notify_ctx); } return 0; }
/** * Handles and interrupt, firing correct events * * @param Pointer to sensor structure * * @return 0 on success, non-zero on failure */ static int adxl345_sensor_handle_interrupt(struct sensor * sensor) { #if MYNEWT_VAL(ADXL345_INT_ENABLE) struct adxl345 * adxl345; struct adxl345_private_driver_data *pdd; struct sensor_itf *itf; uint8_t int_status; int rc; adxl345 = (struct adxl345 *)SENSOR_GET_DEVICE(sensor); itf = SENSOR_GET_ITF(sensor); pdd = &adxl345->pdd; rc = adxl345_clear_interrupts(itf, &int_status); if (rc != 0) { ADXL345_LOG(ERROR, "Cound not read int status err=0x%02x\n", rc); return rc; } if (pdd->registered_mask & ADXL345_NOTIFY_MASK) { if (int_status & ADXL345_INT_SINGLE_TAP_BIT) { sensor_mgr_put_notify_evt(&pdd->notify_ctx, SENSOR_EVENT_TYPE_SINGLE_TAP); } if (int_status & ADXL345_INT_DOUBLE_TAP_BIT) { sensor_mgr_put_notify_evt(&pdd->notify_ctx, SENSOR_EVENT_TYPE_DOUBLE_TAP); } } if ((pdd->registered_mask & ADXL345_READ_MASK) && ((int_status & ADXL345_INT_ACTIVITY_BIT) || (int_status & ADXL345_INT_INACTIVITY_BIT))) { ADXL345_LOG(ERROR, "READ EVT 0x%02x\n", int_status); sensor_mgr_put_read_evt(&pdd->read_ctx); } return 0; #else return SYS_ENODEV; #endif }