You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/01/30 14:16:59 UTC

[GitHub] [mynewt-core] utzig opened a new pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

utzig opened a new pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173
 
 
   Plus commit https://github.com/apache/mynewt-core/commit/6d10c795e3dea57c0d64e17b5a07c2fd8748ccb1 applies a small change to `sensors_test` to allow it to work on non-BLE HW.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373034818
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/syscfg.yml
 ##########
 @@ -40,6 +40,15 @@ syscfg.defs:
         description: 'Support for timer 2'
         value: 0
 
+    LSM303DLHC_ONB:
+        description: 'Onboard lsm303dlhc sensor'
 
 Review comment:
   Removed `.` from all syscfg.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#issuecomment-580322562
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#issuecomment-580322562
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373025437
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,58 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
+{
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    int rc;
+    struct os_dev *dev;
+    struct lsm303dlhc_cfg lsmcfg;
+
+    dev = (struct os_dev *) os_dev_open("lsm303dlhc_0", OS_TIMEOUT_NEVER, NULL);
+    assert(dev != NULL);
+
+    /* read once per sec.  API should take this value in ms. */
+    lsmcfg.accel_rate = LSM303DLHC_ACCEL_RATE_1;
+    lsmcfg.accel_range = LSM303DLHC_ACCEL_RANGE_2;
+    /* Device I2C addr for accelerometer */
+    lsmcfg.acc_addr = LSM303DLHC_ADDR_ACCEL;
+    /* Device I2C addr for magnetometer */
+    lsmcfg.mag_addr = LSM303DLHC_ADDR_MAG;
+    /* Set default mag gain to +/-1.3 gauss */
+    lsmcfg.mag_gain = LSM303DLHC_MAG_GAIN_1_3;
+    /* Set default mag sample rate to 15Hz */
+    lsmcfg.mag_rate = LSM303DLHC_MAG_RATE_15;
+
+    lsmcfg.mask = SENSOR_TYPE_ACCELEROMETER |
+                  SENSOR_TYPE_MAGNETIC_FIELD;
+
+    rc = lsm303dlhc_config((struct lsm303dlhc *) dev, &lsmcfg);
+
+    os_dev_close(dev);
+    return rc;
+#endif
+
+    return 0;
+}
+
+static void
+sensor_dev_create(void)
+{
+    int rc;
+    (void)rc;
+
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    rc = os_dev_create((struct os_dev *) &lsm303dlhc, "lsm303dlhc_0",
+      OS_DEV_INIT_PRIMARY, 0, lsm303dlhc_init, (void *)&i2c_0_itf_lis);
 
 Review comment:
   unorthodox indent

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#issuecomment-580317451
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig merged pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig merged pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373026715
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/syscfg.yml
 ##########
 @@ -40,6 +40,15 @@ syscfg.defs:
         description: 'Support for timer 2'
         value: 0
 
+    LSM303DLHC_ONB:
+        description: 'Onboard lsm303dlhc sensor'
 
 Review comment:
   second newly added description ends with .

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373017553
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,58 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
+{
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    int rc;
+    struct os_dev *dev;
+    struct lsm303dlhc_cfg lsmcfg;
+
+    dev = (struct os_dev *) os_dev_open("lsm303dlhc_0", OS_TIMEOUT_NEVER, NULL);
+    assert(dev != NULL);
+
+    /* read once per sec.  API should take this value in ms. */
+    lsmcfg.accel_rate = LSM303DLHC_ACCEL_RATE_1;
+    lsmcfg.accel_range = LSM303DLHC_ACCEL_RANGE_2;
+    /* Device I2C addr for accelerometer */
+    lsmcfg.acc_addr = LSM303DLHC_ADDR_ACCEL;
+    /* Device I2C addr for magnetometer */
+    lsmcfg.mag_addr = LSM303DLHC_ADDR_MAG;
+    /* Set default mag gain to +/-1.3 gauss */
+    lsmcfg.mag_gain = LSM303DLHC_MAG_GAIN_1_3;
+    /* Set default mag sample rate to 15Hz */
+    lsmcfg.mag_rate = LSM303DLHC_MAG_RATE_15;
+
+    lsmcfg.mask = SENSOR_TYPE_ACCELEROMETER |
+                  SENSOR_TYPE_MAGNETIC_FIELD;
+
+    rc = lsm303dlhc_config((struct lsm303dlhc *) dev, &lsmcfg);
 
 Review comment:
   in line 219 there is no space after cast

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373034718
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,58 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
+{
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    int rc;
+    struct os_dev *dev;
+    struct lsm303dlhc_cfg lsmcfg;
+
+    dev = (struct os_dev *) os_dev_open("lsm303dlhc_0", OS_TIMEOUT_NEVER, NULL);
+    assert(dev != NULL);
+
+    /* read once per sec.  API should take this value in ms. */
+    lsmcfg.accel_rate = LSM303DLHC_ACCEL_RATE_1;
+    lsmcfg.accel_range = LSM303DLHC_ACCEL_RANGE_2;
+    /* Device I2C addr for accelerometer */
+    lsmcfg.acc_addr = LSM303DLHC_ADDR_ACCEL;
+    /* Device I2C addr for magnetometer */
+    lsmcfg.mag_addr = LSM303DLHC_ADDR_MAG;
+    /* Set default mag gain to +/-1.3 gauss */
+    lsmcfg.mag_gain = LSM303DLHC_MAG_GAIN_1_3;
+    /* Set default mag sample rate to 15Hz */
+    lsmcfg.mag_rate = LSM303DLHC_MAG_RATE_15;
+
+    lsmcfg.mask = SENSOR_TYPE_ACCELEROMETER |
+                  SENSOR_TYPE_MAGNETIC_FIELD;
+
+    rc = lsm303dlhc_config((struct lsm303dlhc *) dev, &lsmcfg);
+
+    os_dev_close(dev);
+    return rc;
+#endif
+
+    return 0;
+}
+
+static void
+sensor_dev_create(void)
+{
+    int rc;
+    (void)rc;
+
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    rc = os_dev_create((struct os_dev *) &lsm303dlhc, "lsm303dlhc_0",
+      OS_DEV_INIT_PRIMARY, 0, lsm303dlhc_init, (void *)&i2c_0_itf_lis);
 
 Review comment:
   Fixed

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#issuecomment-580385915
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373034526
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -50,6 +50,19 @@
 #include "mcu/mcu.h"
 #include "os/os_cputime.h"
 
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+#include "lsm303dlhc/lsm303dlhc.h"
+static struct lsm303dlhc lsm303dlhc;
+#endif
+
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+static struct sensor_itf i2c_0_itf_lis = {
 
 Review comment:
   I copied it originally from another BSP that uses some lis something. I removed the suffix cause it is not relevant in this context.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373034660
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,58 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
+{
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+    int rc;
+    struct os_dev *dev;
+    struct lsm303dlhc_cfg lsmcfg;
+
+    dev = (struct os_dev *) os_dev_open("lsm303dlhc_0", OS_TIMEOUT_NEVER, NULL);
+    assert(dev != NULL);
+
+    /* read once per sec.  API should take this value in ms. */
+    lsmcfg.accel_rate = LSM303DLHC_ACCEL_RATE_1;
+    lsmcfg.accel_range = LSM303DLHC_ACCEL_RANGE_2;
+    /* Device I2C addr for accelerometer */
+    lsmcfg.acc_addr = LSM303DLHC_ADDR_ACCEL;
+    /* Device I2C addr for magnetometer */
+    lsmcfg.mag_addr = LSM303DLHC_ADDR_MAG;
+    /* Set default mag gain to +/-1.3 gauss */
+    lsmcfg.mag_gain = LSM303DLHC_MAG_GAIN_1_3;
+    /* Set default mag sample rate to 15Hz */
+    lsmcfg.mag_rate = LSM303DLHC_MAG_RATE_15;
+
+    lsmcfg.mask = SENSOR_TYPE_ACCELEROMETER |
+                  SENSOR_TYPE_MAGNETIC_FIELD;
+
+    rc = lsm303dlhc_config((struct lsm303dlhc *) dev, &lsmcfg);
 
 Review comment:
   Removed space.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373013418
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -50,6 +50,19 @@
 #include "mcu/mcu.h"
 #include "os/os_cputime.h"
 
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+#include "lsm303dlhc/lsm303dlhc.h"
+static struct lsm303dlhc lsm303dlhc;
+#endif
+
+#if MYNEWT_VAL(LSM303DLHC_ONB)
+static struct sensor_itf i2c_0_itf_lis = {
 
 Review comment:
   I wander where this _lis came from?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#issuecomment-580317451
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373067981
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,59 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
 
 Review comment:
   This new function has no prototype and it doesn't seem to be used.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [mynewt-core] utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2173: bsp: stm32f3discovery: enable LSM303DLHC sensor
URL: https://github.com/apache/mynewt-core/pull/2173#discussion_r373083990
 
 

 ##########
 File path: hw/bsp/stm32f3discovery/src/hal_bsp.c
 ##########
 @@ -155,6 +168,59 @@ hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
     return pri;
 }
 
+/**
+ * LSM303DLHC sensor default configuration
+ *
+ * @return 0 on success, non-zero on failure
+ */
+int
+config_lsm303dlhc_sensor(void)
 
 Review comment:
   This function is used, and it is "declared" in the `pkg.init` section (included in this PR). I didn't remember how this works, but taking a look at the generated code (under `bin/targets/f3_sensors/generated/src/f3_sensors-sysinit-app.c` on my tree):
   
   ```
   ...
       config_pkg_init_stage2();
   
       /*** Stage 400 */
       /* 400.0: config_lsm303dlhc_sensor (hw/bsp/stm32f3discovery) */
       config_lsm303dlhc_sensor();
   
       /*** Stage 500 */
       /* 500.0: flash_test_init (test/flash_test) */
       flash_test_init();
   ...
   ```
   
   The prototype is also declared in the same file. I did a small change to use `void` as return to match the prototype of all those sysinit funtions.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services