mkiiskila commented on a change in pull request #505: [WIP, DO NOT MERGE] MYNEWT-828 SensorAPI: Sensor OIC notifications/triggers URL: https://github.com/apache/mynewt-core/pull/505#discussion_r136128276
########## File path: hw/drivers/sensors/lis2dh12/src/lis2dh12.c ########## @@ -628,6 +644,58 @@ lis2dh12_get_rate(struct sensor_itf *itf, uint8_t *rate) } /** + * Set FIFO mode + * + * @param the sensor interface + * @param mode + * @return 0 on success, non-zero on failure + */ +int +lis2dh12_set_fifo_mode(struct sensor_itf *itf, uint8_t mode) +{ + int rc; + uint8_t reg; + + rc = lis2dh12_readlen(itf, LIS2DH12_REG_CTRL_REG5, ®, 1); + if (rc) { + goto err; + } + + reg |= LIS2DH12_CTRL_REG5_FIFO_EN; + + rc = lis2dh12_writelen(itf, LIS2DH12_REG_CTRL_REG5, ®, 1); + if (rc) { + goto err; + } + + rc = lis2dh12_readlen(itf, LIS2DH12_REG_FIFO_CTRL_REG, ®, 1); + if (rc) { + goto err; + } + + reg |= mode; + + rc = lis2dh12_writelen(itf, LIS2DH12_REG_FIFO_CTRL_REG, ®, 1); + if (rc) { + goto err; + } + + rc = lis2dh12_readlen(itf, LIS2DH12_REG_FIFO_SRC_REG, ®, 1); + if (rc) { + goto err; + } + + if (mode == LIS2DH12_FIFO_M_BYPASS && reg != 0x20) { Review comment: Maybe 0x20 should be a define? ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services