[GitHub] [mynewt-newtmgr] rafacouto opened a new pull request #174: Update newtmgr_image.rst

2020-09-20 Thread GitBox


rafacouto opened a new pull request #174:
URL: https://github.com/apache/mynewt-newtmgr/pull/174


   Parameter blank separator



This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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




[GitHub] [mynewt-mcumgr] nwsetec commented on pull request #97: mcuboot: fix for interrupted slot-1 erase

2020-09-20 Thread GitBox


nwsetec commented on pull request #97:
URL: https://github.com/apache/mynewt-mcumgr/pull/97#issuecomment-695838672


   @utzig could you please run your eyes over this.  If you can't see any major 
issues I'll finish testing and remove it from draft.  Thanks



This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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




[GitHub] [mynewt-mcumgr] nwsetec opened a new pull request #97: mcuboot: fix for interrupted slot-1 erase

2020-09-20 Thread GitBox


nwsetec opened a new pull request #97:
URL: https://github.com/apache/mynewt-mcumgr/pull/97


   This is a fix for devices in the field using mcuboot versions v1.6.0 or less.
   
   If a firmware update is attempted with a corrupt image and a power outage or
   reset occurs while the bootloader* is erasing the corrupt image then the
   secondary (slot-1) can be left in a state where the bootloader has not
   properly released slot-1 and a DFU transfer can no longer happen. Attempts
   to upload will transfer 0 bytes as the trailer at the end of the slot remains
   present and indicates the slot is 'in use' blocking the slot erase operation
   that occurs on reception of the 1st image block or when an image erase 
command
   is issued.
   
   This commit fixes this issue by adding an additional requirement to determine
   if a slot is 'in use': the image header magic value located at the beginning
   of the slot must also present. If this additional requirement is not also met
   then the slot is considered not in use.
   
   * The issue was originally discovered with Zephyr v1.14 LTS and mcuboot 
release
   v3.1 and a fix for mcuboot has been applied here:
   https://github.com/JuulLabs-OSS/mcuboot/pull/765
   mcuboot commit: 42335be22bc8fb576845f41e6174f1921fcff5d9
   
   A fix for mcumgr library in Zephyr v1.14 LTS is in progress here:
   https://github.com/zephyrproject-rtos/zephyr/pull/26738
   
   Signed-off-by: Nick Ward 



This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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




[mynewt-core] branch master updated: BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

2020-09-20 Thread vipulrahane
This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new a351a4d  BMP388 Pressure/temperature sensor i2c communtication 
optimization (#2376)
a351a4d is described below

commit a351a4dca423d6676e7b8c1e72db6fed87744bd9
Author: Philip Burkhardt <63323391+supervillain...@users.noreply.github.com>
AuthorDate: Sun Sep 20 12:24:52 2020 -0700

BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

* Add hybrid streaming mode that works without an interrupt pin
---
 hw/drivers/sensors/bmp388/include/bmp388/bmp388.h |   2 +
 hw/drivers/sensors/bmp388/src/bmp388.c| 249 +-
 hw/drivers/sensors/bmp388/syscfg.yml  |   5 +
 3 files changed, 253 insertions(+), 3 deletions(-)

diff --git a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h 
b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
index 41b8f94..30d09dc 100644
--- a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
+++ b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
@@ -381,6 +381,7 @@ enum bmp388_int_type {
 enum bmp388_read_mode {
 BMP388_READ_M_POLL = 0,
 BMP388_READ_M_STREAM = 1,
+BMP388_READ_M_HYBRID = 2,
 };
 
 /* Read mode configuration */
@@ -719,6 +720,7 @@ struct bmp388 {
 #endif
 /* Variable used to hold stats data */
 STATS_SECT_DECL(bmp388_stat_section) stats;
+bool bmp388_cfg_complete;
 };
 
 /**
diff --git a/hw/drivers/sensors/bmp388/src/bmp388.c 
b/hw/drivers/sensors/bmp388/src/bmp388.c
index 412f6b9..b3b9aa7 100644
--- a/hw/drivers/sensors/bmp388/src/bmp388.c
+++ b/hw/drivers/sensors/bmp388/src/bmp388.c
@@ -3142,7 +3142,7 @@ bmp388_stream_read(struct sensor *sensor,
 /* FIFO object to be assigned to device structure */
 struct bmp3_fifo fifo;
 /* Pressure and temperature array of structures with maximum frame size */
-struct bmp3_data sensor_data[74];
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
 /* Loop Variable */
 uint8_t i;
 uint16_t frame_length;
@@ -3231,8 +3231,9 @@ bmp388_stream_read(struct sensor *sensor,
 #endif
 
 if (time_ms != 0) {
-if (time_ms > BMP388_MAX_STREAM_MS)
+if (time_ms > BMP388_MAX_STREAM_MS) {
 time_ms = BMP388_MAX_STREAM_MS;
+}
 rc = os_time_ms_to_ticks(time_ms, _ticks);
 if (rc) {
 goto err;
@@ -3366,6 +3367,246 @@ err:
 return rc;
 }
 
+int
+bmp388_hybrid_read(struct sensor *sensor,
+   sensor_type_t sensor_type,
+   sensor_data_func_t read_func,
+   void *read_arg,
+   uint32_t time_ms)
+{
+int rc;
+struct bmp388 *bmp388;
+struct bmp388_cfg *cfg;
+os_time_t time_ticks;
+os_time_t stop_ticks = 0;
+uint16_t try_count;
+
+#if MYNEWT_VAL(BMP388_FIFO_ENABLE)
+/* FIFO object to be assigned to device structure */
+struct bmp3_fifo fifo;
+/* Pressure and temperature array of structures with maximum frame size */
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
+/* Loop Variable */
+uint8_t i;
+uint16_t frame_length;
+/* Enable fifo */
+fifo.settings.mode = BMP3_ENABLE;
+/* Enable Pressure sensor for fifo */
+fifo.settings.press_en = BMP3_ENABLE;
+/* Enable temperature sensor for fifo */
+fifo.settings.temp_en = BMP3_ENABLE;
+/* Enable fifo time */
+fifo.settings.time_en = BMP3_ENABLE;
+/* No subsampling for FIFO */
+fifo.settings.down_sampling = BMP3_FIFO_NO_SUBSAMPLING;
+fifo.sensortime_updated = false;
+uint16_t current_fifo_len;
+#else
+struct bmp3_data sensor_data;
+#endif
+
+/* If the read isn't looking for pressure or temperature data, don't do 
anything. */
+if ((!(sensor_type & SENSOR_TYPE_PRESSURE)) &&
+(!(sensor_type & SENSOR_TYPE_TEMPERATURE))) {
+BMP388_LOG_ERROR("unsupported sensor type for bmp388\n");
+return SYS_EINVAL;
+}
+
+bmp388 = (struct bmp388 *)SENSOR_GET_DEVICE(sensor);
+
+cfg = >cfg;
+
+if (cfg->read_mode.mode != BMP388_READ_M_HYBRID) {
+BMP388_LOG_ERROR("*bmp388_hybrid_read mode is not hybrid\n");
+return SYS_EINVAL;
+}
+
+if (bmp388->bmp388_cfg_complete == false) {
+/* no interrupt feature */
+/* enable normal mode for fifo feature */
+rc = bmp388_set_normal_mode(bmp388);
+if (rc) {
+BMP388_LOG_ERROR("**bmp388_set_normal_mode failed %d\n", rc);
+goto error;
+}
+
+rc = bmp3_fifo_flush(>bmp3_dev); 
+if(rc) {
+BMP388_LOG_ERROR("fifo flush failed, error=0x%02x\n", rc);
+goto error;
+}
+
+rc = bmp388_set_fifo_cfg(bmp388, cfg->fifo_mode, cfg->fifo_threshold);
+  

[mynewt-core] branch master updated: BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

2020-09-20 Thread vipulrahane
This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new a351a4d  BMP388 Pressure/temperature sensor i2c communtication 
optimization (#2376)
a351a4d is described below

commit a351a4dca423d6676e7b8c1e72db6fed87744bd9
Author: Philip Burkhardt <63323391+supervillain...@users.noreply.github.com>
AuthorDate: Sun Sep 20 12:24:52 2020 -0700

BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

* Add hybrid streaming mode that works without an interrupt pin
---
 hw/drivers/sensors/bmp388/include/bmp388/bmp388.h |   2 +
 hw/drivers/sensors/bmp388/src/bmp388.c| 249 +-
 hw/drivers/sensors/bmp388/syscfg.yml  |   5 +
 3 files changed, 253 insertions(+), 3 deletions(-)

diff --git a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h 
b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
index 41b8f94..30d09dc 100644
--- a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
+++ b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
@@ -381,6 +381,7 @@ enum bmp388_int_type {
 enum bmp388_read_mode {
 BMP388_READ_M_POLL = 0,
 BMP388_READ_M_STREAM = 1,
+BMP388_READ_M_HYBRID = 2,
 };
 
 /* Read mode configuration */
@@ -719,6 +720,7 @@ struct bmp388 {
 #endif
 /* Variable used to hold stats data */
 STATS_SECT_DECL(bmp388_stat_section) stats;
+bool bmp388_cfg_complete;
 };
 
 /**
diff --git a/hw/drivers/sensors/bmp388/src/bmp388.c 
b/hw/drivers/sensors/bmp388/src/bmp388.c
index 412f6b9..b3b9aa7 100644
--- a/hw/drivers/sensors/bmp388/src/bmp388.c
+++ b/hw/drivers/sensors/bmp388/src/bmp388.c
@@ -3142,7 +3142,7 @@ bmp388_stream_read(struct sensor *sensor,
 /* FIFO object to be assigned to device structure */
 struct bmp3_fifo fifo;
 /* Pressure and temperature array of structures with maximum frame size */
-struct bmp3_data sensor_data[74];
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
 /* Loop Variable */
 uint8_t i;
 uint16_t frame_length;
@@ -3231,8 +3231,9 @@ bmp388_stream_read(struct sensor *sensor,
 #endif
 
 if (time_ms != 0) {
-if (time_ms > BMP388_MAX_STREAM_MS)
+if (time_ms > BMP388_MAX_STREAM_MS) {
 time_ms = BMP388_MAX_STREAM_MS;
+}
 rc = os_time_ms_to_ticks(time_ms, _ticks);
 if (rc) {
 goto err;
@@ -3366,6 +3367,246 @@ err:
 return rc;
 }
 
+int
+bmp388_hybrid_read(struct sensor *sensor,
+   sensor_type_t sensor_type,
+   sensor_data_func_t read_func,
+   void *read_arg,
+   uint32_t time_ms)
+{
+int rc;
+struct bmp388 *bmp388;
+struct bmp388_cfg *cfg;
+os_time_t time_ticks;
+os_time_t stop_ticks = 0;
+uint16_t try_count;
+
+#if MYNEWT_VAL(BMP388_FIFO_ENABLE)
+/* FIFO object to be assigned to device structure */
+struct bmp3_fifo fifo;
+/* Pressure and temperature array of structures with maximum frame size */
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
+/* Loop Variable */
+uint8_t i;
+uint16_t frame_length;
+/* Enable fifo */
+fifo.settings.mode = BMP3_ENABLE;
+/* Enable Pressure sensor for fifo */
+fifo.settings.press_en = BMP3_ENABLE;
+/* Enable temperature sensor for fifo */
+fifo.settings.temp_en = BMP3_ENABLE;
+/* Enable fifo time */
+fifo.settings.time_en = BMP3_ENABLE;
+/* No subsampling for FIFO */
+fifo.settings.down_sampling = BMP3_FIFO_NO_SUBSAMPLING;
+fifo.sensortime_updated = false;
+uint16_t current_fifo_len;
+#else
+struct bmp3_data sensor_data;
+#endif
+
+/* If the read isn't looking for pressure or temperature data, don't do 
anything. */
+if ((!(sensor_type & SENSOR_TYPE_PRESSURE)) &&
+(!(sensor_type & SENSOR_TYPE_TEMPERATURE))) {
+BMP388_LOG_ERROR("unsupported sensor type for bmp388\n");
+return SYS_EINVAL;
+}
+
+bmp388 = (struct bmp388 *)SENSOR_GET_DEVICE(sensor);
+
+cfg = >cfg;
+
+if (cfg->read_mode.mode != BMP388_READ_M_HYBRID) {
+BMP388_LOG_ERROR("*bmp388_hybrid_read mode is not hybrid\n");
+return SYS_EINVAL;
+}
+
+if (bmp388->bmp388_cfg_complete == false) {
+/* no interrupt feature */
+/* enable normal mode for fifo feature */
+rc = bmp388_set_normal_mode(bmp388);
+if (rc) {
+BMP388_LOG_ERROR("**bmp388_set_normal_mode failed %d\n", rc);
+goto error;
+}
+
+rc = bmp3_fifo_flush(>bmp3_dev); 
+if(rc) {
+BMP388_LOG_ERROR("fifo flush failed, error=0x%02x\n", rc);
+goto error;
+}
+
+rc = bmp388_set_fifo_cfg(bmp388, cfg->fifo_mode, cfg->fifo_threshold);
+  

[mynewt-core] branch master updated: BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

2020-09-20 Thread vipulrahane
This is an automated email from the ASF dual-hosted git repository.

vipulrahane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
 new a351a4d  BMP388 Pressure/temperature sensor i2c communtication 
optimization (#2376)
a351a4d is described below

commit a351a4dca423d6676e7b8c1e72db6fed87744bd9
Author: Philip Burkhardt <63323391+supervillain...@users.noreply.github.com>
AuthorDate: Sun Sep 20 12:24:52 2020 -0700

BMP388 Pressure/temperature sensor i2c communtication optimization (#2376)

* Add hybrid streaming mode that works without an interrupt pin
---
 hw/drivers/sensors/bmp388/include/bmp388/bmp388.h |   2 +
 hw/drivers/sensors/bmp388/src/bmp388.c| 249 +-
 hw/drivers/sensors/bmp388/syscfg.yml  |   5 +
 3 files changed, 253 insertions(+), 3 deletions(-)

diff --git a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h 
b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
index 41b8f94..30d09dc 100644
--- a/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
+++ b/hw/drivers/sensors/bmp388/include/bmp388/bmp388.h
@@ -381,6 +381,7 @@ enum bmp388_int_type {
 enum bmp388_read_mode {
 BMP388_READ_M_POLL = 0,
 BMP388_READ_M_STREAM = 1,
+BMP388_READ_M_HYBRID = 2,
 };
 
 /* Read mode configuration */
@@ -719,6 +720,7 @@ struct bmp388 {
 #endif
 /* Variable used to hold stats data */
 STATS_SECT_DECL(bmp388_stat_section) stats;
+bool bmp388_cfg_complete;
 };
 
 /**
diff --git a/hw/drivers/sensors/bmp388/src/bmp388.c 
b/hw/drivers/sensors/bmp388/src/bmp388.c
index 412f6b9..b3b9aa7 100644
--- a/hw/drivers/sensors/bmp388/src/bmp388.c
+++ b/hw/drivers/sensors/bmp388/src/bmp388.c
@@ -3142,7 +3142,7 @@ bmp388_stream_read(struct sensor *sensor,
 /* FIFO object to be assigned to device structure */
 struct bmp3_fifo fifo;
 /* Pressure and temperature array of structures with maximum frame size */
-struct bmp3_data sensor_data[74];
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
 /* Loop Variable */
 uint8_t i;
 uint16_t frame_length;
@@ -3231,8 +3231,9 @@ bmp388_stream_read(struct sensor *sensor,
 #endif
 
 if (time_ms != 0) {
-if (time_ms > BMP388_MAX_STREAM_MS)
+if (time_ms > BMP388_MAX_STREAM_MS) {
 time_ms = BMP388_MAX_STREAM_MS;
+}
 rc = os_time_ms_to_ticks(time_ms, _ticks);
 if (rc) {
 goto err;
@@ -3366,6 +3367,246 @@ err:
 return rc;
 }
 
+int
+bmp388_hybrid_read(struct sensor *sensor,
+   sensor_type_t sensor_type,
+   sensor_data_func_t read_func,
+   void *read_arg,
+   uint32_t time_ms)
+{
+int rc;
+struct bmp388 *bmp388;
+struct bmp388_cfg *cfg;
+os_time_t time_ticks;
+os_time_t stop_ticks = 0;
+uint16_t try_count;
+
+#if MYNEWT_VAL(BMP388_FIFO_ENABLE)
+/* FIFO object to be assigned to device structure */
+struct bmp3_fifo fifo;
+/* Pressure and temperature array of structures with maximum frame size */
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
+/* Loop Variable */
+uint8_t i;
+uint16_t frame_length;
+/* Enable fifo */
+fifo.settings.mode = BMP3_ENABLE;
+/* Enable Pressure sensor for fifo */
+fifo.settings.press_en = BMP3_ENABLE;
+/* Enable temperature sensor for fifo */
+fifo.settings.temp_en = BMP3_ENABLE;
+/* Enable fifo time */
+fifo.settings.time_en = BMP3_ENABLE;
+/* No subsampling for FIFO */
+fifo.settings.down_sampling = BMP3_FIFO_NO_SUBSAMPLING;
+fifo.sensortime_updated = false;
+uint16_t current_fifo_len;
+#else
+struct bmp3_data sensor_data;
+#endif
+
+/* If the read isn't looking for pressure or temperature data, don't do 
anything. */
+if ((!(sensor_type & SENSOR_TYPE_PRESSURE)) &&
+(!(sensor_type & SENSOR_TYPE_TEMPERATURE))) {
+BMP388_LOG_ERROR("unsupported sensor type for bmp388\n");
+return SYS_EINVAL;
+}
+
+bmp388 = (struct bmp388 *)SENSOR_GET_DEVICE(sensor);
+
+cfg = >cfg;
+
+if (cfg->read_mode.mode != BMP388_READ_M_HYBRID) {
+BMP388_LOG_ERROR("*bmp388_hybrid_read mode is not hybrid\n");
+return SYS_EINVAL;
+}
+
+if (bmp388->bmp388_cfg_complete == false) {
+/* no interrupt feature */
+/* enable normal mode for fifo feature */
+rc = bmp388_set_normal_mode(bmp388);
+if (rc) {
+BMP388_LOG_ERROR("**bmp388_set_normal_mode failed %d\n", rc);
+goto error;
+}
+
+rc = bmp3_fifo_flush(>bmp3_dev); 
+if(rc) {
+BMP388_LOG_ERROR("fifo flush failed, error=0x%02x\n", rc);
+goto error;
+}
+
+rc = bmp388_set_fifo_cfg(bmp388, cfg->fifo_mode, cfg->fifo_threshold);
+  

[GitHub] [mynewt-core] vrahane merged pull request #2376: BMP388 Pressure/temperature sensor i2c communtication optimization

2020-09-20 Thread GitBox


vrahane merged pull request #2376:
URL: https://github.com/apache/mynewt-core/pull/2376


   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2376: BMP388 Pressure/temperature sensor i2c communtication optimization

2020-09-20 Thread GitBox


vrahane commented on a change in pull request #2376:
URL: https://github.com/apache/mynewt-core/pull/2376#discussion_r491719800



##
File path: hw/drivers/sensors/bmp388/src/bmp388.c
##
@@ -3366,6 +3367,226 @@ bmp388_stream_read(struct sensor *sensor,
 return rc;
 }
 
+int
+bmp388_hybrid_read(struct sensor *sensor,
+   sensor_type_t sensor_type,
+   sensor_data_func_t read_func,
+   void *read_arg,
+   uint32_t time_ms)
+{
+int rc;
+struct bmp388 *bmp388;
+struct bmp388_cfg *cfg;
+os_time_t time_ticks;
+os_time_t stop_ticks = 0;
+uint16_t try_count;
+
+#if MYNEWT_VAL(BMP388_FIFO_ENABLE)
+/* FIFO object to be assigned to device structure */
+struct bmp3_fifo fifo;
+/* Pressure and temperature array of structures with maximum frame size */
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
+/* Loop Variable */
+uint8_t i;
+uint16_t frame_length;
+/* Enable fifo */
+fifo.settings.mode = BMP3_ENABLE;
+/* Enable Pressure sensor for fifo */
+fifo.settings.press_en = BMP3_ENABLE;
+/* Enable temperature sensor for fifo */
+fifo.settings.temp_en = BMP3_ENABLE;
+/* Enable fifo time */
+fifo.settings.time_en = BMP3_ENABLE;
+/* No subsampling for FIFO */
+fifo.settings.down_sampling = BMP3_FIFO_NO_SUBSAMPLING;
+fifo.sensortime_updated = false;
+uint16_t current_fifo_len;
+#else
+struct bmp3_data sensor_data;
+#endif
+
+/* If the read isn't looking for pressure or temperature data, don't do 
anything. */
+if ((!(sensor_type & SENSOR_TYPE_PRESSURE)) &&
+(!(sensor_type & SENSOR_TYPE_TEMPERATURE))) {
+BMP388_LOG_ERROR("unsupported sensor type for bmp388\n");
+return SYS_EINVAL;
+}
+
+bmp388 = (struct bmp388 *)SENSOR_GET_DEVICE(sensor);
+
+cfg = >cfg;
+
+if (cfg->read_mode.mode != BMP388_READ_M_HYBRID) {
+BMP388_LOG_ERROR("*bmp388_hybrid_read mode is not hybrid\n");
+return SYS_EINVAL;
+}
+
+if (bmp388->bmp388_cfg_complete == false) {
+/* no interrupt feature */
+/* enable normal mode for fifo feature */
+rc = bmp388_set_normal_mode(bmp388);
+if (rc) {
+BMP388_LOG_ERROR("**bmp388_set_normal_mode failed %d\n", rc);
+goto error;
+}
+
+bmp3_fifo_flush(>bmp3_dev); 
+bmp388_set_fifo_cfg(bmp388, cfg->fifo_mode, cfg->fifo_threshold);
+#if MYNEWT_VAL(BMP388_INT_ENABLE)
+bmp388_set_int_enable(bmp388, 1, bmp388->cfg.read_mode.int_type);
+bmp388_clear_int(bmp388);

Review comment:
   For all the function calls above return code handling is missing.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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




[GitHub] [mynewt-core] vrahane commented on a change in pull request #2376: BMP388 Pressure/temperature sensor i2c communtication optimization

2020-09-20 Thread GitBox


vrahane commented on a change in pull request #2376:
URL: https://github.com/apache/mynewt-core/pull/2376#discussion_r491719696



##
File path: hw/drivers/sensors/bmp388/src/bmp388.c
##
@@ -3366,6 +3367,226 @@ bmp388_stream_read(struct sensor *sensor,
 return rc;
 }
 
+int
+bmp388_hybrid_read(struct sensor *sensor,
+   sensor_type_t sensor_type,
+   sensor_data_func_t read_func,
+   void *read_arg,
+   uint32_t time_ms)
+{
+int rc;
+struct bmp388 *bmp388;
+struct bmp388_cfg *cfg;
+os_time_t time_ticks;
+os_time_t stop_ticks = 0;
+uint16_t try_count;
+
+#if MYNEWT_VAL(BMP388_FIFO_ENABLE)
+/* FIFO object to be assigned to device structure */
+struct bmp3_fifo fifo;
+/* Pressure and temperature array of structures with maximum frame size */
+struct bmp3_data sensor_data[MYNEWT_VAL(BMP388_FIFO_CONVERTED_DATA_SIZE)];
+/* Loop Variable */
+uint8_t i;
+uint16_t frame_length;
+/* Enable fifo */
+fifo.settings.mode = BMP3_ENABLE;
+/* Enable Pressure sensor for fifo */
+fifo.settings.press_en = BMP3_ENABLE;
+/* Enable temperature sensor for fifo */
+fifo.settings.temp_en = BMP3_ENABLE;
+/* Enable fifo time */
+fifo.settings.time_en = BMP3_ENABLE;
+/* No subsampling for FIFO */
+fifo.settings.down_sampling = BMP3_FIFO_NO_SUBSAMPLING;
+fifo.sensortime_updated = false;
+uint16_t current_fifo_len;
+#else
+struct bmp3_data sensor_data;
+#endif
+
+/* If the read isn't looking for pressure or temperature data, don't do 
anything. */
+if ((!(sensor_type & SENSOR_TYPE_PRESSURE)) &&
+(!(sensor_type & SENSOR_TYPE_TEMPERATURE))) {
+BMP388_LOG_ERROR("unsupported sensor type for bmp388\n");
+return SYS_EINVAL;
+}
+
+bmp388 = (struct bmp388 *)SENSOR_GET_DEVICE(sensor);
+
+cfg = >cfg;
+
+if (cfg->read_mode.mode != BMP388_READ_M_HYBRID) {
+BMP388_LOG_ERROR("*bmp388_hybrid_read mode is not hybrid\n");
+return SYS_EINVAL;
+}
+
+if (bmp388->bmp388_cfg_complete == false) {
+/* no interrupt feature */
+/* enable normal mode for fifo feature */
+rc = bmp388_set_normal_mode(bmp388);
+if (rc) {
+BMP388_LOG_ERROR("**bmp388_set_normal_mode failed %d\n", rc);
+goto error;
+}
+
+bmp3_fifo_flush(>bmp3_dev); 

Review comment:
   The return code is not accounted for. Please do this.
   ```
   3516 if (rc) {
   3517 BMP388_LOG_ERROR("fifo flush failed, err=0x%02x\n", rc);
   3518 goto err;
   3519 }
   ```





This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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