Skip to content

Commit

Permalink
Fan and IR at 0 when in power savings mode (commaai#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbederks authored Oct 29, 2019
1 parent 0537328 commit 6cccf96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ void uno_init(void) {
// Turn on phone regulator
set_gpio_output(GPIOB, 4, 1);

// Initialize IR PWM and set to 50% for now
// Initialize IR PWM and set to 0%
set_gpio_alternate(GPIOB, 7, GPIO_AF2_TIM4);
pwm_init(TIM4, 2);
uno_set_ir_power(50U);
uno_set_ir_power(0U);

// Initialize fan and set to 20%
// Initialize fan and set to 0%
fan_init();
uno_set_fan_power(20U);
uno_set_fan_power(0U);

// Initialize harness
harness_init();
Expand Down
12 changes: 10 additions & 2 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,19 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired)
break;
// **** 0xb0: set IR power
case 0xb0:
current_board->set_ir_power(setup->b.wValue.w);
if(power_save_status == POWER_SAVE_STATUS_DISABLED){
current_board->set_ir_power(setup->b.wValue.w);
} else {
puts("Setting IR power not allowed in power saving mode\n");
}
break;
// **** 0xb1: set fan power
case 0xb1:
current_board->set_fan_power(setup->b.wValue.w);
if(power_save_status == POWER_SAVE_STATUS_DISABLED){
current_board->set_fan_power(setup->b.wValue.w);
} else {
puts("Setting fan power not allowed in power saving mode\n");
}
break;
// **** 0xb2: get fan rpm
case 0xb2:
Expand Down
9 changes: 5 additions & 4 deletions board/power_saving.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ void set_power_save_state(int state) {
set_gpio_output(GPIOA, 14, enable);
}

// Switch IR and fan
// TODO: Remove powering these back up. Should be done on device
current_board->set_ir_power(enable ? 50U : 0U);
current_board->set_fan_power(enable ? 20U : 0U);
// Switch off IR and fan when in power saving
if(!enable){
current_board->set_ir_power(0U);
current_board->set_fan_power(0U);
}

power_save_status = state;
}
Expand Down

0 comments on commit 6cccf96

Please sign in to comment.