ballboard
authorzer0 <zer0@carbon.local>
Sat, 3 Apr 2010 13:00:50 +0000 (15:00 +0200)
committerzer0 <zer0@carbon.local>
Sat, 3 Apr 2010 13:00:50 +0000 (15:00 +0200)
projects/microb2010/ballboard/Makefile
projects/microb2010/ballboard/actuator.c
projects/microb2010/ballboard/actuator.h
projects/microb2010/ballboard/commands.c
projects/microb2010/ballboard/commands_ballboard.c
projects/microb2010/ballboard/cs.c
projects/microb2010/ballboard/i2c_protocol.c
projects/microb2010/ballboard/main.c
projects/microb2010/ballboard/main.h
projects/microb2010/common/i2c_commands.h

index afa396b..9f197fd 100644 (file)
@@ -8,10 +8,10 @@ CFLAGS += -Werror
 LDFLAGS = -T ../common/avr6.x
 
 # List C source files here. (C dependencies are automatically generated.)
-SRC  = $(TARGET).c cmdline.c commands_ax12.c commands_gen.c 
+SRC  = $(TARGET).c cmdline.c commands_ax12.c commands_gen.c
 SRC += commands_cs.c commands_ballboard.c commands.c
 SRC += i2c_protocol.c sensor.c actuator.c cs.c ax12_user.c
-
+SRC += state.c
 
 # List Assembler source files here.
 # Make them always end in a capital .S.  Files ending in a lowercase .s
@@ -20,7 +20,7 @@ SRC += i2c_protocol.c sensor.c actuator.c cs.c ax12_user.c
 # Even though the DOS/Win* filesystem matches both .s and .S the same,
 # it will preserve the spelling of the filenames, and gcc itself does
 # care about how the name is spelled on its command-line.
-ASRC = 
+ASRC =
 
 ########################################
 
index 367e241..2509d7c 100644 (file)
 
 #include "main.h"
 
+#define ROLLER_ON      800
+#define ROLLER_OFF     0
+#define ROLLER_REVERSE -800
+
+#define FORKROT_DEPLOYED 1000
+#define FORKROT_PACKED   0
+
+#define FORKTRANS_LEFT   0
+#define FORKTRANS_MIDDLE 500
+#define FORKTRANS_RIGHT  1000
+
+void roller_on(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_ON);
+}
+
+void roller_off(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_OFF);
+}
+
+void roller_reverse(void)
+{
+       cs_set_consign(&ballboard.roller.cs, ROLLER_REVERSE);
+}
+
+void fork_deploy(void)
+{
+       cs_set_consign(&ballboard.forkrot.cs, FORKROT_DEPLOYED);
+}
+
+void fork_pack(void)
+{
+       cs_set_consign(&ballboard.forkrot.cs, FORKROT_PACKED);
+}
+
+void fork_left(void)
+{
+       cs_set_consign(&ballboard.forktrans.cs, FORKTRANS_LEFT);
+}
+
+void fork_right(void)
+{
+       cs_set_consign(&ballboard.forktrans.cs, FORKTRANS_RIGHT);
+}
+
+void fork_middle(void)
+{
+       cs_set_consign(&ballboard.forktrans.cs, FORKTRANS_MIDDLE);
+}
index a6320be..34bd4ef 100644 (file)
@@ -1,6 +1,6 @@
-/*  
- *  Copyright Droids Corporation (2009)
- * 
+/*
+ *  Copyright Droids Corporation (2010)
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
  *
  */
 
+void roller_on(void);
+void roller_off(void);
+void roller_reverse(void);
+
+void fork_deploy(void);
+void fork_pack(void);
+void fork_left(void);
+void fork_right(void);
+void fork_middle(void);
index 9ab33ad..7273855 100644 (file)
@@ -62,6 +62,14 @@ extern parse_pgm_inst_t cmd_blocking_i_show;
 
 /* commands_ballboard.c */
 extern parse_pgm_inst_t cmd_event;
+extern parse_pgm_inst_t cmd_color;
+extern parse_pgm_inst_t cmd_state1;
+extern parse_pgm_inst_t cmd_state2;
+extern parse_pgm_inst_t cmd_state3;
+extern parse_pgm_inst_t cmd_state_debug;
+extern parse_pgm_inst_t cmd_state_machine;
+extern parse_pgm_inst_t cmd_fork;
+extern parse_pgm_inst_t cmd_roller;
 extern parse_pgm_inst_t cmd_test;
 
 /* in progmem */
@@ -105,6 +113,14 @@ parse_pgm_ctx_t main_ctx[] = {
 
        /* commands_ballboard.c */
        (parse_pgm_inst_t *)&cmd_event,
+       (parse_pgm_inst_t *)&cmd_color,
+       (parse_pgm_inst_t *)&cmd_state1,
+       (parse_pgm_inst_t *)&cmd_state2,
+       (parse_pgm_inst_t *)&cmd_state3,
+       (parse_pgm_inst_t *)&cmd_state_debug,
+       (parse_pgm_inst_t *)&cmd_state_machine,
+       (parse_pgm_inst_t *)&cmd_fork,
+       (parse_pgm_inst_t *)&cmd_roller,
        (parse_pgm_inst_t *)&cmd_test,
 
        NULL,
index cae215e..fd45914 100644 (file)
@@ -44,6 +44,7 @@
 #include <parse_num.h>
 
 #include "main.h"
+#include "state.h"
 #include "cmdline.h"
 #include "../common/i2c_commands.h"
 #include "i2c_protocol.h"
@@ -168,6 +169,289 @@ parse_pgm_inst_t cmd_color = {
 
 
 /**********************************************************/
+/* State1 */
+
+/* this structure is filled when cmd_state1 is parsed successfully */
+struct cmd_state1_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+};
+
+/* function called when cmd_state1 is parsed successfully */
+static void cmd_state1_parsed(void *parsed_result,
+                             __attribute__((unused)) void *data)
+{
+       struct cmd_state1_result *res = parsed_result;
+
+       if (!strcmp_P(res->arg1, PSTR("init")))
+               state_init();
+       else if (!strcmp_P(res->arg1, PSTR("off")))
+               state_set_mode(I2C_BALLBOARD_MODE_OFF);
+       else if (!strcmp_P(res->arg1, PSTR("eject")))
+               state_set_mode(I2C_BALLBOARD_MODE_EJECT);
+       else if (!strcmp_P(res->arg1, PSTR("harvest")))
+               state_set_mode(I2C_BALLBOARD_MODE_HARVEST);
+
+       /* other commands */
+}
+
+prog_char str_state1_arg0[] = "ballboard";
+parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
+prog_char str_state1_arg1[] = "init#eject#harvest#off";
+parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
+
+prog_char help_state1[] = "set ballboard mode";
+parse_pgm_inst_t cmd_state1 = {
+       .f = cmd_state1_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_state1,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_state1_arg0,
+               (prog_void *)&cmd_state1_arg1,
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* State2 */
+
+/* this structure is filled when cmd_state2 is parsed successfully */
+struct cmd_state2_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+       fixed_string_t arg2;
+};
+
+/* function called when cmd_state2 is parsed successfully */
+static void cmd_state2_parsed(void *parsed_result,
+                             __attribute__((unused)) void *data)
+{
+       struct cmd_state2_result *res = parsed_result;
+       uint8_t mode;
+
+       if (!strcmp_P(res->arg2, PSTR("left"))) {
+               if (!strcmp_P(res->arg1, PSTR("prepare")))
+                       mode = I2C_BALLBOARD_MODE_PREP_L_FORK;
+               else if (!strcmp_P(res->arg1, PSTR("take")))
+                       mode = I2C_BALLBOARD_MODE_TAKE_L_FORK;
+       }
+       else {
+               if (!strcmp_P(res->arg1, PSTR("prepare")))
+                       mode = I2C_BALLBOARD_MODE_PREP_R_FORK;
+               else if (!strcmp_P(res->arg1, PSTR("take")))
+                       mode = I2C_BALLBOARD_MODE_TAKE_R_FORK;
+       }
+       //state_set_mode(mode);
+}
+
+prog_char str_state2_arg0[] = "ballboard";
+parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0);
+prog_char str_state2_arg1[] = "prepare#take";
+parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1);
+prog_char str_state2_arg2[] = "left#right";
+parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2);
+
+prog_char help_state2[] = "set ballboard mode";
+parse_pgm_inst_t cmd_state2 = {
+       .f = cmd_state2_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_state2,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_state2_arg0,
+               (prog_void *)&cmd_state2_arg1,
+               (prog_void *)&cmd_state2_arg2,
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* State3 */
+
+/* this structure is filled when cmd_state3 is parsed successfully */
+struct cmd_state3_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+       uint8_t arg2;
+};
+
+/* function called when cmd_state3 is parsed successfully */
+static void cmd_state3_parsed(void *parsed_result, 
+                             __attribute__((unused)) void *data)
+{
+       struct cmd_state3_result *res = parsed_result;
+
+       if (!strcmp_P(res->arg1, PSTR("xxx"))) {
+               /* xxx = res->arg2 */
+       }
+       else if (!strcmp_P(res->arg1, PSTR("yyy"))) {
+       }
+       state_set_mode(0);
+}
+
+prog_char str_state3_arg0[] = "ballboard";
+parse_pgm_token_string_t cmd_state3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg0, str_state3_arg0);
+prog_char str_state3_arg1[] = "xxx";
+parse_pgm_token_string_t cmd_state3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg1, str_state3_arg1);
+parse_pgm_token_num_t cmd_state3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_state3_result, arg2, UINT8);
+
+prog_char help_state3[] = "set ballboard mode";
+parse_pgm_inst_t cmd_state3 = {
+       .f = cmd_state3_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_state3,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_state3_arg0, 
+               (prog_void *)&cmd_state3_arg1, 
+               (prog_void *)&cmd_state3_arg2, 
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* State_Machine */
+
+/* this structure is filled when cmd_state_machine is parsed successfully */
+struct cmd_state_machine_result {
+       fixed_string_t arg0;
+};
+
+/* function called when cmd_state_machine is parsed successfully */
+static void cmd_state_machine_parsed(__attribute__((unused)) void *parsed_result,
+                                    __attribute__((unused)) void *data)
+{
+       state_machine();
+}
+
+prog_char str_state_machine_arg0[] = "state_machine";
+parse_pgm_token_string_t cmd_state_machine_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_machine_result, arg0, str_state_machine_arg0);
+
+prog_char help_state_machine[] = "launch state machine";
+parse_pgm_inst_t cmd_state_machine = {
+       .f = cmd_state_machine_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_state_machine,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_state_machine_arg0, 
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* State_Debug */
+
+/* this structure is filled when cmd_state_debug is parsed successfully */
+struct cmd_state_debug_result {
+       fixed_string_t arg0;
+       uint8_t on;
+};
+
+/* function called when cmd_state_debug is parsed successfully */
+static void cmd_state_debug_parsed(void *parsed_result,
+                                  __attribute__((unused)) void *data)
+{
+       struct cmd_state_debug_result *res = parsed_result;
+       state_debug = res->on;
+}
+
+prog_char str_state_debug_arg0[] = "state_debug";
+parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0);
+parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8);
+
+prog_char help_state_debug[] = "Set debug for state machine";
+parse_pgm_inst_t cmd_state_debug = {
+       .f = cmd_state_debug_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_state_debug,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_state_debug_arg0, 
+               (prog_void *)&cmd_state_debug_on, 
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* Fork */
+
+/* this structure is filled when cmd_fork is parsed successfully */
+struct cmd_fork_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+};
+
+/* function called when cmd_fork is parsed successfully */
+static void cmd_fork_parsed(void *parsed_result,
+                                   __attribute__((unused)) void *data)
+{
+       struct cmd_fork_result *res = parsed_result;
+       if (!strcmp_P(res->arg1, PSTR("deploy")))
+               fork_deploy();
+       else if (!strcmp_P(res->arg1, PSTR("pack")))
+               fork_pack();
+       else if (!strcmp_P(res->arg1, PSTR("left")))
+               fork_left();
+       else if (!strcmp_P(res->arg1, PSTR("right")))
+               fork_right();
+       else if (!strcmp_P(res->arg1, PSTR("middle")))
+               fork_middle();
+}
+
+prog_char str_fork_arg0[] = "fork";
+parse_pgm_token_string_t cmd_fork_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_fork_result, arg0, str_fork_arg0);
+prog_char str_fork_arg1[] = "deploy#pack#left#right#middle";
+parse_pgm_token_string_t cmd_fork_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_fork_result, arg1, str_fork_arg1);
+
+prog_char help_fork[] = "move fork";
+parse_pgm_inst_t cmd_fork = {
+       .f = cmd_fork_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_fork,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_fork_arg0, 
+               (prog_void *)&cmd_fork_arg1, 
+               NULL,
+       },
+};
+
+/**********************************************************/
+/* Roller */
+
+/* this structure is filled when cmd_roller is parsed successfully */
+struct cmd_roller_result {
+       fixed_string_t arg0;
+       fixed_string_t arg1;
+};
+
+/* function called when cmd_roller is parsed successfully */
+static void cmd_roller_parsed(void *parsed_result,
+                                   __attribute__((unused)) void *data)
+{
+       struct cmd_roller_result *res = parsed_result;
+       if (!strcmp_P(res->arg1, PSTR("on")))
+               roller_on();
+       else if (!strcmp_P(res->arg1, PSTR("off")))
+               roller_off();
+       else if (!strcmp_P(res->arg1, PSTR("reverse")))
+               roller_reverse();
+}
+
+prog_char str_roller_arg0[] = "roller";
+parse_pgm_token_string_t cmd_roller_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_roller_result, arg0, str_roller_arg0);
+prog_char str_roller_arg1[] = "on#off#reverse";
+parse_pgm_token_string_t cmd_roller_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_roller_result, arg1, str_roller_arg1);
+
+prog_char help_roller[] = "Servo door function";
+parse_pgm_inst_t cmd_roller = {
+       .f = cmd_roller_parsed,  /* function to call */
+       .data = NULL,      /* 2nd arg of func */
+       .help_str = help_roller,
+       .tokens = {        /* token list, NULL terminated */
+               (prog_void *)&cmd_roller_arg0, 
+               (prog_void *)&cmd_roller_arg1, 
+               NULL,
+       },
+};
+
+/**********************************************************/
 /* Test */
 
 /* this structure is filled when cmd_test is parsed successfully */
@@ -179,7 +463,6 @@ struct cmd_test_result {
 static void cmd_test_parsed(void *parsed_result, void *data)
 {
        //struct cmd_test_result *res = parsed_result;
-       
 }
 
 prog_char str_test_arg0[] = "test";
index 7e87fca..a82f3f4 100644 (file)
@@ -57,7 +57,7 @@ int32_t encoders_spi_update_roller_speed(void *number)
 }
 
 /* called every 5 ms */
-static void do_cs(void *dummy) 
+static void do_cs(void *dummy)
 {
        /* read encoders */
        if (ballboard.flags & DO_ENCODERS) {
@@ -177,7 +177,7 @@ void microb_cs_init(void)
        ballboard.forkrot.on = 1;
 
 
-       scheduler_add_periodical_event_priority(do_cs, NULL, 
+       scheduler_add_periodical_event_priority(do_cs, NULL,
                                                5000L / SCHEDULER_UNIT, 
                                                CS_PRIO);
 }
index 8995e55..f9e9b55 100644 (file)
@@ -46,6 +46,7 @@
 
 #include "../common/i2c_commands.h"
 #include "main.h"
+#include "state.h"
 #include "actuator.h"
 
 void i2c_protocol_init(void)
@@ -73,11 +74,18 @@ void i2c_send_status(void)
        i2c_flush();
        ans.hdr.cmd =  I2C_ANS_BALLBOARD_STATUS;
        ans.status = 0x55; /* XXX */
+       ans.ball_count = state_get_ball_count();
 
        i2c_send(I2C_ADD_MASTER, (uint8_t *) &ans,
                 sizeof(ans), I2C_CTRL_GENERIC);
 }
 
+static int8_t i2c_set_mode(struct i2c_cmd_ballboard_set_mode *cmd)
+{
+       state_set_mode(cmd->mode);
+       return 0;
+}
+
 void i2c_recvevent(uint8_t * buf, int8_t size)
 {
        void *void_cmd = buf;
@@ -91,11 +99,11 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
        if (size <= 0) {
                goto error;
        }
-       
+
        switch (buf[0]) {
 
        /* Commands (no answer needed) */
-       case I2C_CMD_GENERIC_LED_CONTROL: 
+       case I2C_CMD_GENERIC_LED_CONTROL:
                {
                        struct i2c_cmd_led_control *cmd = void_cmd;
                        if (size != sizeof (*cmd))
@@ -103,7 +111,7 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                        i2c_led_control(cmd->led_num, cmd->state);
                        break;
                }
-               
+
        case I2C_CMD_GENERIC_SET_COLOR:
                {
                        struct i2c_cmd_generic_color *cmd = void_cmd;
@@ -113,16 +121,25 @@ void i2c_recvevent(uint8_t * buf, int8_t size)
                        break;
                }
 
+       case I2C_CMD_BALLBOARD_SET_MODE:
+               {
+                       struct i2c_cmd_ballboard_set_mode *cmd = void_cmd;
+                       if (size != sizeof(struct i2c_cmd_ballboard_set_mode))
+                               goto error;
+                       i2c_set_mode(cmd);
+                       break;
+               }
+
 
        /* Add other commands here ...*/
 
 
        case I2C_REQ_BALLBOARD_STATUS:
                {
-                       struct i2c_req_ballboard_status *cmd = void_cmd;                        
+                       struct i2c_req_ballboard_status *cmd = void_cmd;
                        if (size != sizeof (*cmd))
                                goto error;
-                               
+
                        i2c_send_status();
                        break;
                }
index 46a3b52..9633368 100755 (executable)
@@ -1,7 +1,7 @@
-/*  
+/*
  *  Copyright Droids Corporation
  *  Olivier Matz <zer0@droids-corp.org>
- * 
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 2 of the License, or
 #include "actuator.h"
 #include "cs.h"
 #include "i2c_protocol.h"
-#include "beacon.h"
-#include "scanner.h"
 
 /* 0 means "programmed"
  * ---- with 16 Mhz quartz
  * CKSEL 3-0 : 0111
- * SUT 1-0 : 10 
+ * SUT 1-0 : 10
  * CKDIV8 : 1
  * ---- bootloader
  * BOOTZ 1-0 : 01 (4K bootloader)
@@ -108,7 +106,7 @@ void bootloader(void)
        __asm__ __volatile__ ("ldi r31,0xf8\n");
        __asm__ __volatile__ ("ldi r30,0x00\n");
        __asm__ __volatile__ ("eijmp\n");
-       
+
        /* never returns */
 }
 
@@ -121,7 +119,7 @@ void do_led_blink(__attribute__((unused)) void *dummy)
                LED1_ON();
        else
                LED1_OFF();
-       
+
        a = !a;
 #endif
 }
@@ -152,7 +150,7 @@ int main(void)
        memset(&gen, 0, sizeof(gen));
        memset(&ballboard, 0, sizeof(ballboard));
        ballboard.flags = DO_ENCODERS | DO_CS | DO_POWER; // DO_BD
-       
+
        /* UART */
        uart_init();
 #if CMDLINE_UART == 3
@@ -165,7 +163,7 @@ int main(void)
 #  error not supported
 #endif
 
-       //eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD);
+       eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD);
        /* check eeprom to avoid to run the bad program */
        if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) !=
            EEPROM_MAGIC_BALLBOARD) {
@@ -194,12 +192,12 @@ int main(void)
        timer0_register_OV_intr(main_timer_interrupt);
 
        /* PWM */
-       PWM_NG_TIMER_16BITS_INIT(1, TIMER_16_MODE_PWM_10, 
+       PWM_NG_TIMER_16BITS_INIT(1, TIMER_16_MODE_PWM_10,
                                 TIMER1_PRESCALER_DIV_1);
-       PWM_NG_TIMER_16BITS_INIT(4, TIMER_16_MODE_PWM_10, 
+       PWM_NG_TIMER_16BITS_INIT(4, TIMER_16_MODE_PWM_10,
                                 TIMER4_PRESCALER_DIV_1);
-       
-       PWM_NG_INIT16(&gen.pwm1_4A, 4, A, 10, PWM_NG_MODE_SIGNED | 
+
+       PWM_NG_INIT16(&gen.pwm1_4A, 4, A, 10, PWM_NG_MODE_SIGNED |
                      PWM_NG_MODE_SIGN_INVERTED,
                      &PORTD, 4);
        PWM_NG_INIT16(&gen.pwm2_4B, 4, B, 10, PWM_NG_MODE_SIGNED,
@@ -211,11 +209,11 @@ int main(void)
 
 
        /* servos */
-       PWM_NG_TIMER_16BITS_INIT(3, TIMER_16_MODE_PWM_10, 
+       PWM_NG_TIMER_16BITS_INIT(3, TIMER_16_MODE_PWM_10,
                                 TIMER1_PRESCALER_DIV_256);
        PWM_NG_INIT16(&gen.servo1, 3, C, 10, PWM_NG_MODE_NORMAL,
                      NULL, 0);
-       PWM_NG_TIMER_16BITS_INIT(5, TIMER_16_MODE_PWM_10, 
+       PWM_NG_TIMER_16BITS_INIT(5, TIMER_16_MODE_PWM_10,
                                 TIMER1_PRESCALER_DIV_256);
        PWM_NG_INIT16(&gen.servo2, 5, A, 10, PWM_NG_MODE_NORMAL,
                      NULL, 0);
@@ -223,12 +221,12 @@ int main(void)
                      NULL, 0);
        PWM_NG_INIT16(&gen.servo4, 5, C, 10, PWM_NG_MODE_NORMAL,
                      NULL, 0);
-       
+
        /* SCHEDULER */
        scheduler_init();
 
-       scheduler_add_periodical_event_priority(do_led_blink, NULL, 
-                                               100000L / SCHEDULER_UNIT, 
+       scheduler_add_periodical_event_priority(do_led_blink, NULL,
+                                               100000L / SCHEDULER_UNIT,
                                                LED_PRIO);
        /* all cs management */
        microb_cs_init();
index 36915bd..3ebb1e7 100755 (executable)
@@ -91,7 +91,7 @@ struct genboard {
        struct pwm_ng servo2;
        struct pwm_ng servo3;
        struct pwm_ng servo4;
-       
+
        /* ax12 interface */
        AX12 ax12;
 
index d08e580..87f98c7 100644 (file)
@@ -85,13 +85,14 @@ struct i2c_cmd_cobboard_set_mode {
 struct i2c_cmd_ballboard_set_mode {
        struct i2c_cmd_hdr hdr;
 
-#define I2C_BALLBOARD_MODE_OFF         0x00
-#define I2C_BALLBOARD_MODE_HARVEST     0x01
-#define I2C_BALLBOARD_MODE_EJECT       0x02
-#define I2C_BALLBOARD_MODE_PREP_L_FORK 0x03
-#define I2C_BALLBOARD_MODE_TAKE_L_FORK 0x04
-#define I2C_BALLBOARD_MODE_PREP_R_FORK 0x05
-#define I2C_BALLBOARD_MODE_TAKE_R_FORK 0x06
+#define I2C_BALLBOARD_MODE_INIT        0x00
+#define I2C_BALLBOARD_MODE_OFF         0x01
+#define I2C_BALLBOARD_MODE_HARVEST     0x02
+#define I2C_BALLBOARD_MODE_EJECT       0x03
+#define I2C_BALLBOARD_MODE_PREP_L_FORK 0x04
+#define I2C_BALLBOARD_MODE_TAKE_L_FORK 0x05
+#define I2C_BALLBOARD_MODE_PREP_R_FORK 0x06
+#define I2C_BALLBOARD_MODE_TAKE_R_FORK 0x07
        uint8_t mode;
 };
 
@@ -136,6 +137,7 @@ struct i2c_req_ballboard_status {
 struct i2c_ans_ballboard_status {
        struct i2c_cmd_hdr hdr;
 
+       uint8_t mode;
 
 #define I2C_BALLBOARD_STATUS_F_READY         0x00
 #define I2C_BALLBOARD_STATUS_F_BUSY          0x01