Fixed USB power mode on black (#291)

* Fixed USB power mode on black

* bump version
master
robbederks 2019-10-05 20:34:20 -07:00 committed by rbiasini
parent 4b3358c921
commit 0894b28f1e
5 changed files with 15 additions and 13 deletions

View File

@ -1 +1 @@
v1.5.1
v1.5.2

View File

@ -162,6 +162,9 @@ void black_init(void) {
// Turn on USB load switch.
black_set_usb_load_switch(true);
// Set right power mode
black_set_usb_power_mode(USB_POWER_CDP);
// Initialize harness
harness_init();

View File

@ -288,6 +288,16 @@ void white_init(void) {
EXTI->RTSR |= (1U << 1);
EXTI->FTSR |= (1U << 1);
NVIC_EnableIRQ(EXTI1_IRQn);
// Init usb power mode
uint32_t voltage = adc_get_voltage();
// Init in CDP mode only if panda is powered by 12V.
// Otherwise a PC would not be able to flash a standalone panda with EON build
if (voltage > 8000U) { // 8V threshold
white_set_usb_power_mode(USB_POWER_CDP);
} else {
white_set_usb_power_mode(USB_POWER_CLIENT);
}
}
const harness_configuration white_harness_config = {

View File

@ -32,6 +32,7 @@ const board *current_board;
#include "drivers/clock.h"
#include "drivers/llgpio.h"
#include "drivers/adc.h"
#include "board.h"
@ -68,8 +69,6 @@ int main(void) {
detect_configuration();
detect_board_type();
current_board->set_usb_power_mode(USB_POWER_CLIENT);
if (enter_bootloader_mode == ENTER_SOFTLOADER_MAGIC) {
enter_bootloader_mode = 0;
soft_flasher_start();

View File

@ -652,16 +652,6 @@ int main(void) {
// init board
current_board->init();
// init usb power mode
uint32_t voltage = adc_get_voltage();
// init in CDP mode only if panda is powered by 12V.
// Otherwise a PC would not be able to flash a standalone panda with EON build
if (voltage > 8000U) { // 8V threshold
current_board->set_usb_power_mode(USB_POWER_CDP);
} else {
current_board->set_usb_power_mode(USB_POWER_CLIENT);
}
// panda has an FPU, let's use it!
enable_fpu();