Adding dynamic USB power support

- Each scan module now has a current change callback which passes the available current as a parameter
- No longer attempts to use the max 500 mA immediately, starts with 100 mA then goes to 500 mA after enumeration
- If enumeration fails due to bMaxPower of 500 mA, then attempt again at 100 mA (might also be possible to go even lower to 20 mA in certain cases)
- Now working with the Apple Ipad (no over-power messages)
- Fixed Wake-up behaviour on Apple Ipad (and likely other iOS devices)
- More effecient set_feature/clear_feature handling (device handler)
- Initial power handling via Interconnect (still needs work to get it more dynamic)
This commit is contained in:
Jacob Alexander 2016-02-21 19:56:52 -08:00
parent e761960aca
commit 46765e85c5
25 changed files with 463 additions and 41 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2014-2015 by Jacob Alexander
/* Copyright (C) 2014-2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -406,8 +406,14 @@ inline void LED_setup()
// Set default brightness
LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 );
// Disable Software shutdown of ISSI chip
LED_writeReg( 0x0A, 0x01, 0x0B );
// Do not disable software shutdown of ISSI chip unless current is high enough
// Require at least 150 mA
// May be enabled/disabled at a later time
if ( Output_current_available() >= 150 )
{
// Disable Software shutdown of ISSI chip
LED_writeReg( 0x0A, 0x01, 0x0B );
}
}
@ -644,6 +650,24 @@ inline uint8_t LED_scan()
}
// Called by parent Scan Module whenver the available current has changed
// current - mA
void LED_currentChange( unsigned int current )
{
// TODO dim LEDs in low power mode instead of shutting off
if ( current < 150 )
{
// Enabled Software shutdown of ISSI chip
LED_writeReg( 0x0A, 0x00, 0x0B );
}
else
{
// Disable Software shutdown of ISSI chip
LED_writeReg( 0x0A, 0x01, 0x0B );
}
}
// ----- Capabilities -----

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2014-2015 by Jacob Alexander
/* Copyright (C) 2014-2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,3 +28,5 @@
void LED_setup();
uint8_t LED_scan();
void LED_currentChange( unsigned int current );