Mercurial > louis > kiibohd-controller
comparison Scan/ISSILed/led_scan.c @ 420:23a1868b4ac2
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)
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Sun, 21 Feb 2016 19:56:52 -0800 |
parents | a3825c7fc651 |
children | cbcdb7a16b7c |
comparison
equal
deleted
inserted
replaced
419:910be0f02758 | 420:23a1868b4ac2 |
---|---|
1 /* Copyright (C) 2014-2015 by Jacob Alexander | 1 /* Copyright (C) 2014-2016 by Jacob Alexander |
2 * | 2 * |
3 * This file is free software: you can redistribute it and/or modify | 3 * This file is free software: you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License as published by | 4 * it under the terms of the GNU General Public License as published by |
5 * the Free Software Foundation, either version 3 of the License, or | 5 * the Free Software Foundation, either version 3 of the License, or |
6 * (at your option) any later version. | 6 * (at your option) any later version. |
404 LED_sendPage( (uint8_t*)LED_ledEnableMask1, sizeof( LED_ledEnableMask1 ), 0 ); | 404 LED_sendPage( (uint8_t*)LED_ledEnableMask1, sizeof( LED_ledEnableMask1 ), 0 ); |
405 | 405 |
406 // Set default brightness | 406 // Set default brightness |
407 LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 ); | 407 LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 ); |
408 | 408 |
409 // Disable Software shutdown of ISSI chip | 409 // Do not disable software shutdown of ISSI chip unless current is high enough |
410 LED_writeReg( 0x0A, 0x01, 0x0B ); | 410 // Require at least 150 mA |
411 // May be enabled/disabled at a later time | |
412 if ( Output_current_available() >= 150 ) | |
413 { | |
414 // Disable Software shutdown of ISSI chip | |
415 LED_writeReg( 0x0A, 0x01, 0x0B ); | |
416 } | |
411 } | 417 } |
412 | 418 |
413 | 419 |
414 inline uint8_t I2C_BufferCopy( uint8_t *data, uint8_t sendLen, uint8_t recvLen, I2C_Buffer *buffer ) | 420 inline uint8_t I2C_BufferCopy( uint8_t *data, uint8_t sendLen, uint8_t recvLen, I2C_Buffer *buffer ) |
415 { | 421 { |
642 | 648 |
643 return 0; | 649 return 0; |
644 } | 650 } |
645 | 651 |
646 | 652 |
653 // Called by parent Scan Module whenver the available current has changed | |
654 // current - mA | |
655 void LED_currentChange( unsigned int current ) | |
656 { | |
657 // TODO dim LEDs in low power mode instead of shutting off | |
658 if ( current < 150 ) | |
659 { | |
660 // Enabled Software shutdown of ISSI chip | |
661 LED_writeReg( 0x0A, 0x00, 0x0B ); | |
662 } | |
663 else | |
664 { | |
665 // Disable Software shutdown of ISSI chip | |
666 LED_writeReg( 0x0A, 0x01, 0x0B ); | |
667 } | |
668 } | |
669 | |
670 | |
647 | 671 |
648 // ----- Capabilities ----- | 672 // ----- Capabilities ----- |
649 | 673 |
650 // Basic LED Control Capability | 674 // Basic LED Control Capability |
651 typedef enum LedControlMode { | 675 typedef enum LedControlMode { |