save
[aversive.git] / projects / microb2010 / cobboard / main.c
index 62103c8..1f4065b 100755 (executable)
@@ -115,16 +115,21 @@ void bootloader(void)
 
 void do_led_blink(__attribute__((unused)) void *dummy)
 {
-#if 1 /* simple blink */
-       static uint8_t a=0;
+       static uint8_t a = 0;
 
-       if(a)
-               LED1_ON();
-       else
-               LED1_OFF();
-
-       a = !a;
-#endif
+       if (cobboard.flags & DO_ERRBLOCKING) {
+               if (a & 1)
+                       LED1_ON();
+               else
+                       LED1_OFF();
+       }
+       else {
+               if (a & 4)
+                       LED1_ON();
+               else
+                       LED1_OFF();
+       }
+       a++;
 }
 
 static void main_timer_interrupt(void)
@@ -153,7 +158,8 @@ int main(void)
        memset(&gen, 0, sizeof(gen));
        memset(&cobboard, 0, sizeof(cobboard));
        /* cs is enabled after arm_calibrate() */
-       cobboard.flags = DO_ENCODERS | DO_POWER; // DO_BD
+       cobboard.flags = DO_ENCODERS | DO_POWER | DO_BD |
+               DO_ERRBLOCKING;
 
        /* UART */
        uart_init();
@@ -183,8 +189,6 @@ int main(void)
        error_register_notice(mylog);
        error_register_debug(mylog);
 
-       wait_ms(3000);
-
        /* SPI + ENCODERS */
        encoders_spi_init(); /* this will also init spi hardware */
 
@@ -205,8 +209,8 @@ int main(void)
 
        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,
-                     &PORTD, 5);
+       PWM_NG_INIT16(&gen.pwm2_4B, 4, B, 10, PWM_NG_MODE_SIGNED |
+                     PWM_NG_MODE_SIGN_INVERTED, &PORTD, 5);
        PWM_NG_INIT16(&gen.pwm3_1A, 1, A, 10, PWM_NG_MODE_SIGNED,
                      &PORTD, 6);
        PWM_NG_INIT16(&gen.pwm4_1B, 1, B, 10, PWM_NG_MODE_SIGNED |
@@ -248,13 +252,15 @@ int main(void)
 
        sei();
 
-       /* actuators */
-       actuator_init();
+       printf_P(PSTR("cobboard start\r\n"));
 
        /* spickle, shovel */
        spickle_init();
        shovel_init();
 
+       /* actuators */
+       actuator_init();
+
        state_init();
 
        printf_P(PSTR("\r\n"));