add usb power gating
This commit is contained in:
parent
472e43056d
commit
d8477e3d2d
1 changed files with 8 additions and 4 deletions
|
|
@ -261,8 +261,15 @@ fn app_main(mut p: hal::Peripherals, app_settings: Settings) -> Settings {
|
|||
let mut adc = hal::adc::Adc::new(p.ADC1, Default::default());
|
||||
let mut batt_monitor_pin = p.PD4;
|
||||
let mut adc_core = AdcCore::new(adc, batt_monitor_pin);
|
||||
|
||||
let mut usb_detect_pin = p.PD5;
|
||||
let usb_detect_input = Input::new(usb_detect_pin, Pull::Up);
|
||||
let usb = Usb::new(usb_detect_input);
|
||||
|
||||
let bv = adc_core.get_battery_voltage();
|
||||
if bv < 421 {
|
||||
|
||||
// if we don't have USB power, and the batt ADC reads under 421, don't wake
|
||||
if !usb.powered() && bv < 421 {
|
||||
adc_core.shutdown();
|
||||
return app_settings;
|
||||
}
|
||||
|
|
@ -313,9 +320,6 @@ fn app_main(mut p: hal::Peripherals, app_settings: Settings) -> Settings {
|
|||
|
||||
// adc2
|
||||
// let mut usb_detect_dc = hal::adc::Adc::new(p.ADC1, Default::default());
|
||||
let mut usb_detect_pin = p.PD5;
|
||||
let usb_detect_input = Input::new(usb_detect_pin, Pull::Up);
|
||||
let usb = Usb::new(usb_detect_input);
|
||||
|
||||
// println!("ADC_PIN CHANNEL: {}", adc_pin.channel().channel());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue