X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=commands.c;h=6eb034c59b92ade35bdb1673f7b84b3e5f836a3b;hp=a14d098ac6215389da67c68be43260fb0899368e;hb=f97044f0c5ecbbc665bd7ac1d454fd9479476a78;hpb=50f42a7b2f1a2be5be2a2e4207e304ce046d1965 diff --git a/commands.c b/commands.c index a14d098..6eb034c 100644 --- a/commands.c +++ b/commands.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "parse_neighbor.h" #include "parse_monitor.h" +#include "spi_servo.h" #include "rc_proto.h" #include "main.h" #include "cmdline.h" @@ -1258,6 +1260,47 @@ parse_pgm_inst_t cmd_baudrate = { }; #endif +/* this structure is filled when cmd_test_spi is parsed successfully */ +struct cmd_test_spi_result { + fixed_string_t arg0; +}; + +static void cmd_test_spi_parsed(void * parsed_result, + __attribute__((unused)) void *data) +{ + int i; + + + while (1) { + for (i = 0; i < 50; i++) { + spi_servo_set(0, 0); + wait_ms(100); + spi_servo_set(0, 500); + wait_ms(100); + } + + spi_servo_bypass(1); + wait_ms(10000); + spi_servo_bypass(0); + wait_ms(1); + } +} + +prog_char str_test_spi_arg0[] = "test_spi"; +parse_pgm_token_string_t cmd_test_spi_arg0 = + TOKEN_STRING_INITIALIZER(struct cmd_test_spi_result, arg0, + str_test_spi_arg0); + +prog_char help_test_spi[] = "Test the spi"; +parse_pgm_inst_t cmd_test_spi = { + .f = cmd_test_spi_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_test_spi, + .tokens = { /* token list, NULL terminated */ + (prog_void *)&cmd_test_spi_arg0, + NULL, + }, +}; /* in progmem */ parse_pgm_ctx_t main_ctx[] = { @@ -1297,5 +1340,6 @@ parse_pgm_ctx_t main_ctx[] = { #ifndef USE_USB (parse_pgm_inst_t *)&cmd_baudrate, #endif + (parse_pgm_inst_t *)&cmd_test_spi, NULL, };