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 2018/12/14 09:27:41 UTC
[GitHub] andrzej-kaczmarek closed pull request #1565: hw/drivers/lps33thw:
Fix CLI for bus driver
andrzej-kaczmarek closed pull request #1565: hw/drivers/lps33thw: Fix CLI for bus driver
URL: https://github.com/apache/mynewt-core/pull/1565
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/hw/drivers/sensors/lps33thw/src/lps33thw_shell.c b/hw/drivers/sensors/lps33thw/src/lps33thw_shell.c
index 8eead64b16..03154ceea9 100644
--- a/hw/drivers/sensors/lps33thw/src/lps33thw_shell.c
+++ b/hw/drivers/sensors/lps33thw/src/lps33thw_shell.c
@@ -38,9 +38,13 @@ static struct shell_cmd lps33thw_shell_cmd_struct = {
};
static struct sensor_itf g_sensor_itf = {
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+ .si_dev = NULL, /* will be updated on 1st access */
+#else
.si_type = MYNEWT_VAL(LPS33THW_SHELL_ITF_TYPE),
.si_num = MYNEWT_VAL(LPS33THW_SHELL_ITF_NUM),
.si_addr = MYNEWT_VAL(LPS33THW_SHELL_ITF_ADDR)
+#endif
};
static int
@@ -119,6 +123,17 @@ lps33thw_shell_cmd(int argc, char **argv)
return lps33thw_shell_help();
}
+ if (!g_sensor_itf.si_dev) {
+ g_sensor_itf.si_dev = os_dev_open(MYNEWT_VAL(LPS33THW_SHELL_NODE_NAME),
+ 0, NULL);
+
+ if (!g_sensor_itf.si_dev) {
+ console_printf("Cannot open device '%s'\n",
+ MYNEWT_VAL(LPS33THW_SHELL_NODE_NAME));
+ return 0;
+ }
+ }
+
/* Read pressure */
if (argc > 1 && strcmp(argv[1], "rp") == 0) {
return lps33thw_shell_cmd_read_press(argc, argv);
diff --git a/hw/drivers/sensors/lps33thw/syscfg.yml b/hw/drivers/sensors/lps33thw/syscfg.yml
index ba1aa29624..b10819cc52 100644
--- a/hw/drivers/sensors/lps33thw/syscfg.yml
+++ b/hw/drivers/sensors/lps33thw/syscfg.yml
@@ -17,18 +17,6 @@
#
syscfg.defs:
- LPS33THW_SHELL_ITF_NUM:
- description: 'Shell interface number for the LPS33THW'
- value: 0
- LPS33THW_SHELL_ITF_TYPE:
- description: 'Shell interface type for the LPS33THW'
- value: 1
- LPS33THW_SHELL_CSPIN:
- description: 'CS pin for LPS33THW'
- value : -1
- LPS33THW_SHELL_ITF_ADDR:
- description: 'Slave address for LPS33THW'
- value : 0x5C
LPS33THW_CLI:
description: 'Enable shell support for the LPS33THW'
value: 0
@@ -47,3 +35,22 @@ syscfg.defs:
description: >
Number of OS ticks to wait for each I2C transaction to complete.
value: 3
+
+syscfg.defs.!BUS_DRIVER_PRESENT:
+ LPS33THW_SHELL_ITF_NUM:
+ description: 'Shell interface number for the LPS33THW'
+ value: 0
+ LPS33THW_SHELL_ITF_TYPE:
+ description: 'Shell interface type for the LPS33THW'
+ value: 1
+ LPS33THW_SHELL_CSPIN:
+ description: 'CS pin for LPS33THW'
+ value : -1
+ LPS33THW_SHELL_ITF_ADDR:
+ description: 'Slave address for LPS33THW'
+ value : 0x5C
+
+syscfg.defs.BUS_DRIVER_PRESENT:
+ LPS33THW_SHELL_NODE_NAME:
+ description: 'Bus node name for the LPS33THW'
+ value: '"lps33thw"'
----------------------------------------------------------------
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