From commits-return-17950-archive-asf-public=cust-asf.ponee.io@mynewt.apache.org Mon Apr 16 22:04:11 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 48C9A180608 for ; Mon, 16 Apr 2018 22:04:11 +0200 (CEST) Received: (qmail 87442 invoked by uid 500); 16 Apr 2018 20:04:10 -0000 Mailing-List: contact commits-help@mynewt.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mynewt.apache.org Delivered-To: mailing list commits@mynewt.apache.org Received: (qmail 87433 invoked by uid 99); 16 Apr 2018 20:04:10 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Apr 2018 20:04:10 +0000 From: GitBox To: commits@mynewt.apache.org Subject: [GitHub] vrahane commented on a change in pull request #1024: lis2dw12: Support sleep change event for notifications Message-ID: <152390904982.18308.17540244931574141115.gitbox@gitbox.apache.org> Date: Mon, 16 Apr 2018 20:04:09 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit vrahane commented on a change in pull request #1024: lis2dw12: Support sleep change event for notifications URL: https://github.com/apache/mynewt-core/pull/1024#discussion_r181867561 ########## File path: hw/drivers/sensors/lis2dw12/src/lis2dw12.c ########## @@ -1946,89 +1943,106 @@ init_intpin(struct lis2dw12 * lis2dw12, hal_gpio_irq_handler_t handler, if (rc != 0) { LIS2DW12_ERR("Failed to initialise interrupt pin %d\n", pin); return rc; - } + } return 0; } static int -enable_interrupt(struct sensor * sensor, uint8_t int_to_enable) +enable_interrupt(struct sensor *sensor, uint8_t int_to_enable, uint8_t int_num) { struct lis2dw12 *lis2dw12; - struct lis2dw12_private_driver_data *pdd; + struct lis2dw12_pdd *pdd; struct sensor_itf *itf; uint8_t reg; int rc; + if (!int_to_enable) { + rc = SYS_EINVAL; + goto err; + } + lis2dw12 = (struct lis2dw12 *)SENSOR_GET_DEVICE(sensor); itf = SENSOR_GET_ITF(sensor); pdd = &lis2dw12->pdd; rc = lis2dw12_clear_int(itf, ®); if (rc) { - return rc; + goto err; } - + /* if no interrupts are currently in use enable int pin */ - if (pdd->int_enable == 0) { - hal_gpio_irq_enable(itf->si_ints[pdd->int_num].host_pin); + if (!pdd->int_enable) { + hal_gpio_irq_enable(itf->si_ints[int_num].host_pin); rc = lis2dw12_set_int_enable(itf, 1); if (rc) { - return rc; + goto err; } } - /*update which interrupts are enabled */ - pdd->int_enable |= int_to_enable; - + pdd->int_enable++; + /* enable interrupt in device */ - rc = lis2dw12_set_int1_pin_cfg(itf, pdd->int_enable); + if (int_num == 0) { + rc = lis2dw12_set_int1_pin_cfg(itf, int_to_enable); Review comment: I see what you mean here, `lis2dw12_set_int1_pin_cfg()` probably should just OR it then if we were to support multiple APIs from enabling interrupts and we can add a interrupt clear API to clear the int cfg. The initial thought was, notification/config would just override each other but that sounds like might be too limiting. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services