Datasheet
/* Define a custom stats group for querying */
STATS_SECT_START(led_stat_section)
STATS_SECT_ENTRY(led_toggles)
STATS_SECT_END
/* Define a few stat name fields for querying */
STATS_NAME_START(led_stat_section)
STATS_NAME(led_stat_section, led_toggles)
STATS_NAME_END(led_stat_section)
/* Add the global variable to access and increment stats */
STATS_SECT_DECL(led_stat_section) g_ledstats;
int
main(int argc, char **argv)
{
int rc;
/* Initialize the task */
os_task_init(&led_task, "blinky", led_task_func, NULL,
LED_TASK_PRIO, OS_WAIT_FOREVER, led_task_stack,
LED_STACK_SIZE);
/* Call this before sysinit to register the command */
#if MYNEWT_VAL(SHELL_TASK)
shell_cmd_register(&shell_test_cmd_struct);
#endif
/* Initialize the OS */
sysinit();
/* Initialise the custom stats section */
rc = stats_init(
STATS_HDR(g_ledstats),
STATS_SIZE_INIT_PARMS(g_ledstats, STATS_SIZE_32),
STATS_NAME_INIT_PARMS(led_stat_section));
assert(rc == 0);
/* Then register the custom section with the stats system */
rc = stats_register("led_stats", STATS_HDR(g_ledstats));
assert(rc == 0);
while (1) {
/* Run the event queue to process background events */
os_eventq_run(os_eventq_dflt_get());
}
return rc;
}
/* Implement the 'test' command handler */
static int
shell_test_cmd(int argc, char **argv)
{
console_printf("Test!\n");
return 0;
}
static void
© Adafruit Industries https://learn.adafruit.com/adafruit-nrf52-pro-feather Page 66 of 87










