From 921332af2ab5ecdf7c21f431c9ee2da9ad14677f Mon Sep 17 00:00:00 2001 From: Jiri Kubias Date: Sat, 25 Apr 2009 01:16:21 +0200 Subject: [PATCH] eb_sberac: added back switch --- src/eb_sberac_09/main.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/eb_sberac_09/main.c b/src/eb_sberac_09/main.c index 81f4b85e..c39318bd 100644 --- a/src/eb_sberac_09/main.c +++ b/src/eb_sberac_09/main.c @@ -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<