Skip to content

Commit 95d404b

Browse files
committed
drivers/adxl345: Register command statically
Now adxl345 shell command is registered at link time to reduce memory footprint. Command was register before by function adxl345_shell_init() Now command is added when syscfg value ADXL345_CLI is 1 Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
1 parent 05968ca commit 95d404b

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

hw/drivers/sensors/adxl345/include/adxl345/adxl345.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,6 @@ int adxl345_config(struct adxl345 *, struct adxl345_cfg *);
193193

194194
int adxl345_get_accel_data(struct sensor_itf *itf, struct sensor_accel_data *sad);
195195

196-
#if MYNEWT_VAL(ADXL345_CLI)
197-
int adxl345_shell_init(void);
198-
#endif
199-
200196
#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
201197
int adxl345_create_i2c_sensor_dev(struct bus_i2c_node *node, const char *name,
202198
const struct bus_i2c_node_cfg *i2c_cfg,

hw/drivers/sensors/adxl345/pkg.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,13 @@ pkg.deps:
3737
pkg.req_apis:
3838
- stats
3939

40+
pkg.whole_archive: true
41+
42+
pkg.srouce_files:
43+
- src/ds1307.c
44+
45+
pkg.srouce_files.ADXL345_CLI:
46+
- src/ds1307_shell.c
47+
4048
pkg.deps.ADXL345_CLI:
4149
- "@apache-mynewt-core/util/parse"

hw/drivers/sensors/adxl345/src/adxl345_shell.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@
2929

3030
#if MYNEWT_VAL(ADXL345_CLI)
3131

32-
static int adxl345_shell_cmd(int argc, char **argv);
33-
34-
static struct shell_cmd adxl345_shell_cmd_struct = {
35-
.sc_cmd = "adxl345",
36-
.sc_cmd_func = adxl345_shell_cmd
37-
};
38-
3932
static struct sensor_itf g_sensor_itf = {
4033
.si_type = MYNEWT_VAL(ADXL345_SHELL_ITF_TYPE),
4134
.si_num = MYNEWT_VAL(ADXL345_SHELL_ITF_NUM),
@@ -70,7 +63,7 @@ adxl345_shell_err_invalid_arg(char *cmd_name)
7063
static int
7164
adxl345_shell_help(void)
7265
{
73-
console_printf("%s cmd [flags...]\n", adxl345_shell_cmd_struct.sc_cmd);
66+
console_printf("adxl345 cmd [flags...]\n");
7467
console_printf("cmd:\n");
7568
console_printf("\tr [n_samples]\n");
7669
console_printf("\tchipid\n");
@@ -249,15 +242,6 @@ adxl345_shell_cmd(int argc, char **argv)
249242
return adxl345_shell_err_unknown_arg(argv[1]);
250243
}
251244

252-
int
253-
adxl345_shell_init(void)
254-
{
255-
int rc;
256-
257-
rc = shell_cmd_register(&adxl345_shell_cmd_struct);
258-
SYSINIT_PANIC_ASSERT(rc == 0);
259-
260-
return rc;
261-
}
245+
MAKE_SHELL_CMD(adxl345, adxl345_shell_cmd, NULL)
262246

263247
#endif

0 commit comments

Comments
 (0)