You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2025/11/07 16:53:24 UTC
(mynewt-core) 24/26: drivers/bmp280: Register command statically
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 188617c688c6ac65805da02a0431a7bc5cd73e4e
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Jun 6 20:31:05 2025 +0200
drivers/bmp280: Register command statically
Now bmp280 shell command is registered at link time to
reduce memory footprint.
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/drivers/sensors/bmp280/pkg.yml | 8 ++++++++
hw/drivers/sensors/bmp280/src/bmp280_shell.c | 15 ++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/hw/drivers/sensors/bmp280/pkg.yml b/hw/drivers/sensors/bmp280/pkg.yml
index c5065306d..003c272e7 100644
--- a/hw/drivers/sensors/bmp280/pkg.yml
+++ b/hw/drivers/sensors/bmp280/pkg.yml
@@ -42,5 +42,13 @@ pkg.deps.BUS_DRIVER_PRESENT:
pkg.req_apis:
- stats
+pkg.whole_archive: true
+
+pkg.source_files:
+ - src/bmp280.c
+
+pkg.source_files.BMP280_CLI:
+ - src/bmp280_shell.c
+
pkg.deps.BMP280_CLI:
- "@apache-mynewt-core/util/parse"
diff --git a/hw/drivers/sensors/bmp280/src/bmp280_shell.c b/hw/drivers/sensors/bmp280/src/bmp280_shell.c
index 3b0c0e558..573a5d1c2 100644
--- a/hw/drivers/sensors/bmp280/src/bmp280_shell.c
+++ b/hw/drivers/sensors/bmp280/src/bmp280_shell.c
@@ -31,13 +31,6 @@
#include "shell/shell.h"
#include "parse/parse.h"
-static int bmp280_shell_cmd(int argc, char **argv);
-
-static struct shell_cmd bmp280_shell_cmd_struct = {
- .sc_cmd = "bmp280",
- .sc_cmd_func = bmp280_shell_cmd
-};
-
#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
static struct sensor_itf g_sensor_itf;
#else
@@ -76,7 +69,7 @@ bmp280_shell_err_invalid_arg(char *cmd_name)
static int
bmp280_shell_help(void)
{
- console_printf("%s cmd [flags...]\n", bmp280_shell_cmd_struct.sc_cmd);
+ console_printf("bmp280 cmd [flags...]\n");
console_printf("cmd:\n");
console_printf("\tr [n_samples]\n");
console_printf("\tmode [0-sleep | 1/2-forced | 3-normal]\n");
@@ -434,10 +427,12 @@ static const struct bus_spi_node_cfg bmp280_raw_cfg = {
#endif
+MAKE_SHELL_CMD(bmp280, bmp280_shell_cmd, NULL)
+
int
bmp280_shell_init(void)
{
- int rc;
+ int rc = 0;
#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
struct os_dev *dev = NULL;
@@ -457,8 +452,6 @@ bmp280_shell_init(void)
console_printf("Failed to create bmp280_raw device\n");
}
#endif
- rc = shell_cmd_register(&bmp280_shell_cmd_struct);
- SYSINIT_PANIC_ASSERT(rc == 0);
return rc;
}