]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
include receive of CAN message that force board to turn off all motors etc and halt.
authorOndra Vrzal <ondra.vrzal@gmail.com>
Wed, 30 Apr 2008 23:26:21 +0000 (01:26 +0200)
committerOndra Vrzal <ondra.vrzal@gmail.com>
Wed, 30 Apr 2008 23:26:21 +0000 (01:26 +0200)
Ondra

app/eb_carousel/carousel.c

index bd202d0d809f066d57d1f95d3ab871fa962e2d3a..c643ea453297eabc02afd2c5167b21b1f0d3df9f 100644 (file)
@@ -71,6 +71,7 @@ void init_carousel(void);
 unsigned int getCurrentPosition(void);
 void gotoPos(unsigned int position); // !!! depricated
 void generatePositions(void);
+void go_to_sleep();
 
 unsigned int getTime(void);
 void can_rx(can_msg_t *msg);
@@ -946,12 +947,33 @@ void can_rx(can_msg_t *msg) {
                        recieveCANmessage= 1; //flag to sent CAN data
                        recieveCANdata= rx_msg.data[3]; // data to send                 
                        break;
+               
+               case CAN_PWR_ALERT:
+                       if ( rx_msg.data[0] == 2 ) go_to_sleep();
+                       break;
                        
                default:
                        break;
        }
 }
 
+void go_to_sleep()
+{
+       engine_A_en(ENGINE_EN_OFF);  // engines off
+       engine_A_pwm(0);
+       engine_B_en(ENGINE_EN_OFF);
+       engine_B_pwm(0);
+
+       can_off();
+       
+       deb_led_off(LEDY);
+       deb_led_off(LEDB);
+       deb_led_off(LEDG);
+       deb_led_on(LEDR);
+       PCON = 2;                               // bye bye 
+}
+
+
 
 /**
  *     returns the number in T0TC