From a51c55e4a9dc25c25b7be6dd35e952d3a93d1953 Mon Sep 17 00:00:00 2001 From: Ondra Vrzal Date: Thu, 1 May 2008 01:26:21 +0200 Subject: [PATCH] include receive of CAN message that force board to turn off all motors etc and halt. Ondra --- app/eb_carousel/carousel.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/eb_carousel/carousel.c b/app/eb_carousel/carousel.c index bd202d0..c643ea4 100644 --- a/app/eb_carousel/carousel.c +++ b/app/eb_carousel/carousel.c @@ -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 -- 2.39.2