From: Xavier L. <Ba...@us...> - 2011-04-12 12:48:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 81ad433ad4992f4c336e5bcf236cb4c3edf49ac5 (commit) from 95c331e1f020fae9b686285a13fa515fd647e229 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 81ad433ad4992f4c336e5bcf236cb4c3edf49ac5 Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 12 14:47:38 2011 +0200 [Controller_Motor_STM32] Refactored blinkyness in motor_controller The HIL mode has been tested and works perfectly. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c index 0625ce5..2c0e6da 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/can_monitor.c @@ -17,7 +17,7 @@ PROC_DEFINE_STACK(stack_can_send, KERN_MINSTACKSIZE * 8); PROC_DEFINE_STACK(stack_can_receive, KERN_MINSTACKSIZE * 8); // globals -uint8_t mode; +volatile uint8_t mode; // Structures to represent data into CAN messages typedef struct { diff --git a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c index 56fef1a..3bc54e0 100644 --- a/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c +++ b/elec/boards/Controller_Motor_STM32/Firmware/controller_motor_stm32/motor_controller.c @@ -52,6 +52,40 @@ static inline uint8_t get_motor_index(uint8_t motor_id) { return motor_ind; } +static inline void motor_led_on(uint8_t motor_id) { + switch (motor_id) { + case MOTOR1: + LED1_ON(); + break; + case MOTOR2: + LED2_ON(); + break; + case MOTOR3: + LED3_ON(); + break; + case MOTOR4: + LED4_ON(); + break; + } +} + +static inline void motor_led_off(uint8_t motor_id) { + switch (motor_id) { + case MOTOR1: + LED1_OFF(); + break; + case MOTOR2: + LED2_OFF(); + break; + case MOTOR3: + LED3_OFF(); + break; + case MOTOR4: + LED4_OFF(); + break; + } +} + // Process functions for control and simulation static void NORETURN motorController_process(void); static void NORETURN motorController_HIL_process(void); @@ -131,6 +165,9 @@ static void NORETURN motorController_process(void) { timer_setDelay(&timer, ms_to_ticks((mtime_t)(params->T*1000))); timer_setEvent(&timer); + // Switch off motor LED + motor_led_off(params->motor); + while (1) { if (params->enable == 0) { params->running = 0; @@ -202,38 +239,11 @@ static void NORETURN motorController_HIL_process(void) { timer_add(&timer); if (last_t >= 0.2) { - if (led_state == 0) { - led_state = 1; - switch (params->motor) { - case MOTOR1: - LED1_ON(); - break; - case MOTOR2: - LED2_ON(); - break; - case MOTOR3: - LED3_ON(); - break; - case MOTOR4: - LED4_ON(); - break; - } + led_state = !led_state; + if (led_state) { + motor_led_on(params->motor); } else { - led_state = 0; - switch (params->motor) { - case MOTOR1: - LED1_OFF(); - break; - case MOTOR2: - LED2_OFF(); - break; - case MOTOR3: - LED3_OFF(); - break; - case MOTOR4: - LED4_OFF(); - break; - } + motor_led_off(params->motor); } last_t -= 0.2; } hooks/post-receive -- krobot |