]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
eb_sberac: added back switch
authorJiri Kubias <jiri.kubias@gmail.com>
Fri, 24 Apr 2009 23:16:21 +0000 (01:16 +0200)
committerJiri Kubias <jiri.kubias@gmail.com>
Fri, 24 Apr 2009 23:16:21 +0000 (01:16 +0200)
src/eb_sberac_09/main.c

index 81f4b85e6df35b27c038ea676f5676d0a754ae18..c39318bd248d3c2e42793941ad84ed858c8bf8e8 100644 (file)
@@ -287,7 +287,7 @@ void timeout(void)
 #define PUCK_PIN       18      // MISO1
 uint32_t time_puck = 0;
 #define  PUCK_TIME     50
-
+#define BACK_PIN       19              // start pin
 void puck_switch(void)
 {
     if (time_puck == 0) time_puck= time_ms + PUCK_TIME;        
@@ -300,18 +300,31 @@ void puck_switch(void)
        msg_puck.id = CAN_PUCK;
        msg_puck.dlc = 1;
        
+      msg_puck.data[0] = 0;
       if(IO0PIN & (1<< PUCK_PIN))
       {
-       msg_puck.data[0] = 0;
+       msg_puck.data[0] |= 1;
        deb_led_off(LEDR);
       }
       else
       {
-       msg_puck.data[0] 1;
+       msg_puck.data[0] &= ~1;
        deb_led_on(LEDR);
       }
       
+      if(IO0PIN & (1<< BACK_PIN))
+      {
+       msg_puck.data[0] |= 2;
+       deb_led_off(LEDB);
+      }
+      else
+      {
+       msg_puck.data[0] &= ~2;
+       deb_led_on(LEDB);
+      }
+      
       while (can_tx_msg(&msg_puck));
+      
        
     }
 }
@@ -322,6 +335,7 @@ uint32_t time_start = 0;
 uint8_t start_cnt = 0;
 #define START_PIN      15              // start pin
 
+
 void start_button(void)
 {
        if (start_bt > 10) 
@@ -368,6 +382,14 @@ void start_button(void)
 
 int main (void)  {
 
+  
+  
+  
+       SET_PIN(PINSEL0, START_PIN, PINSEL_0);
+       SET_PIN(PINSEL1, 2, PINSEL_0);                  // PUCK_PIN
+       SET_PIN(PINSEL1, 3, PINSEL_0);                  // BACK_PIN
+       
+       
        init_perip();                   // sys init MCU
        
        set_servo(CHELAE_L , CHELAE_L_MIN) ;
@@ -394,9 +416,10 @@ int main (void)  {
        time_timeout = time_ms + TIMEOUT_DELAY;
 
        
-       SET_PIN(PINSEL0, START_PIN, PINSEL_0);
-       SET_PIN(PINSEL1, (PUCK_PIN - 15), PINSEL_0);
 
+       IO0DIR &= ~((1<<START_PIN) | (1<<PUCK_PIN) | (1<<BACK_PIN));
+       
+       
        while(1)
        {
 
@@ -405,6 +428,7 @@ int main (void)  {
                        timeout();
                        //deb_led_on(LEDY);
                }
+               
                start_button();
                led_blik(LEDG);
                send_adc();