Skip to content

Commit 19e7e5d

Browse files
committed
drivers/bmp280: Register command statically
Now bmp280 shell command is registered at link time to reduce memory footprint. Signed-off-by: Jerzy Kasenberg <[email protected]>
1 parent e90e368 commit 19e7e5d

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

hw/drivers/sensors/bmp280/pkg.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@ pkg.deps.BUS_DRIVER_PRESENT:
4242
pkg.req_apis:
4343
- stats
4444

45+
pkg.whole_archive: true
46+
47+
pkg.source_files:
48+
- src/bmp280.c
49+
50+
pkg.source_files.BMP280_CLI:
51+
- src/bmp280_shell.c
52+
4553
pkg.deps.BMP280_CLI:
4654
- "@apache-mynewt-core/util/parse"

hw/drivers/sensors/bmp280/src/bmp280_shell.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@
3131
#include "shell/shell.h"
3232
#include "parse/parse.h"
3333

34-
static int bmp280_shell_cmd(int argc, char **argv);
35-
36-
static struct shell_cmd bmp280_shell_cmd_struct = {
37-
.sc_cmd = "bmp280",
38-
.sc_cmd_func = bmp280_shell_cmd
39-
};
40-
4134
#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
4235
static struct sensor_itf g_sensor_itf;
4336
#else
@@ -76,7 +69,7 @@ bmp280_shell_err_invalid_arg(char *cmd_name)
7669
static int
7770
bmp280_shell_help(void)
7871
{
79-
console_printf("%s cmd [flags...]\n", bmp280_shell_cmd_struct.sc_cmd);
72+
console_printf("bmp280 cmd [flags...]\n");
8073
console_printf("cmd:\n");
8174
console_printf("\tr [n_samples]\n");
8275
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 = {
434427

435428
#endif
436429

430+
MAKE_SHELL_CMD(bmp280, bmp280_shell_cmd, NULL)
431+
437432
int
438433
bmp280_shell_init(void)
439434
{
440-
int rc;
435+
int rc = 0;
441436

442437
#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
443438
struct os_dev *dev = NULL;
@@ -457,8 +452,6 @@ bmp280_shell_init(void)
457452
console_printf("Failed to create bmp280_raw device\n");
458453
}
459454
#endif
460-
rc = shell_cmd_register(&bmp280_shell_cmd_struct);
461-
SYSINIT_PANIC_ASSERT(rc == 0);
462455

463456
return rc;
464457
}

0 commit comments

Comments
 (0)