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 58fb8a01ce23b5a1130e911d33b872f7e562df87 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Fri Jun 6 20:23:32 2025 +0200 drivers/bme280: Register command statically Now bme280 shell command is registered at link time to reduce memory footprint. Signed-off-by: Jerzy Kasenberg <[email protected]> --- hw/drivers/sensors/bme280/pkg.yml | 8 ++++++++ hw/drivers/sensors/bme280/src/bme280_shell.c | 15 ++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/hw/drivers/sensors/bme280/pkg.yml b/hw/drivers/sensors/bme280/pkg.yml index c206c4461..ccf7927d2 100644 --- a/hw/drivers/sensors/bme280/pkg.yml +++ b/hw/drivers/sensors/bme280/pkg.yml @@ -39,6 +39,14 @@ pkg.deps.!BUS_DRIVER_PRESENT: pkg.req_apis: - stats +pkg.source_files: + - src/bme280.c + +pkg.source_files.BME280_CLI: + - src/bme280_shell.c + +pkg.whole_archive: true + pkg.deps.BME280_CLI: - "@apache-mynewt-core/util/parse" diff --git a/hw/drivers/sensors/bme280/src/bme280_shell.c b/hw/drivers/sensors/bme280/src/bme280_shell.c index c7f0fe324..7bed5e819 100644 --- a/hw/drivers/sensors/bme280/src/bme280_shell.c +++ b/hw/drivers/sensors/bme280/src/bme280_shell.c @@ -30,13 +30,6 @@ #include "parse/parse.h" #include "bsp/bsp.h" -static int bme280_shell_cmd(int argc, char **argv); - -static struct shell_cmd bme280_shell_cmd_struct = { - .sc_cmd = "bme280", - .sc_cmd_func = bme280_shell_cmd -}; - #if MYNEWT_VAL(BUS_DRIVER_PRESENT) static struct sensor_itf g_sensor_itf; #else @@ -74,7 +67,7 @@ bme280_shell_err_invalid_arg(char *cmd_name) static int bme280_shell_help(void) { - console_printf("%s cmd [flags...]\n", bme280_shell_cmd_struct.sc_cmd); + console_printf("bme280 cmd [flags...]\n"); console_printf("cmd:\n"); console_printf("\tr [n_samples]\n"); console_printf("\tmode [0-sleep | 1/2-forced | 3-normal]\n"); @@ -414,10 +407,12 @@ static const struct bus_spi_node_cfg bme280_raw_cfg = { #endif +MAKE_SHELL_CMD(bme280, bme280_shell_cmd, NULL) + int bme280_shell_init(void) { - int rc; + int rc = 0; #if MYNEWT_VAL(BUS_DRIVER_PRESENT) struct os_dev *dev = NULL; @@ -437,8 +432,6 @@ bme280_shell_init(void) console_printf("Failed to create bme280_raw device\n"); } #endif - rc = shell_cmd_register(&bme280_shell_cmd_struct); - SYSINIT_PANIC_ASSERT(rc == 0); return rc; }
