Mercurial > louis > kiibohd-controller
comparison Scan/ISSILed/led_scan.c @ 422:cbcdb7a16b7c
Fixing potential WF LED issue
- Added fix for USB Current Change
* If called during interrupt, could hang the I2C bus
* Delaying I2C writes till scan loop
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Tue, 01 Mar 2016 19:35:21 -0800 |
parents | 23a1868b4ac2 |
children |
comparison
equal
deleted
inserted
replaced
421:ad693d70c292 | 422:cbcdb7a16b7c |
---|---|
637 } | 637 } |
638 | 638 |
639 | 639 |
640 | 640 |
641 // LED State processing loop | 641 // LED State processing loop |
642 unsigned int LED_currentEvent = 0; | |
642 inline uint8_t LED_scan() | 643 inline uint8_t LED_scan() |
643 { | 644 { |
644 | 645 // Check for current change event |
645 // I2C Busy | 646 if ( LED_currentEvent ) |
646 // S & I2C_S_BUSY | 647 { |
647 //I2C_S_BUSY | 648 // TODO dim LEDs in low power mode instead of shutting off |
649 if ( LED_currentEvent < 150 ) | |
650 { | |
651 // Enable Software shutdown of ISSI chip | |
652 LED_writeReg( 0x0A, 0x00, 0x0B ); | |
653 } | |
654 else | |
655 { | |
656 // Disable Software shutdown of ISSI chip | |
657 LED_writeReg( 0x0A, 0x01, 0x0B ); | |
658 } | |
659 | |
660 LED_currentEvent = 0; | |
661 } | |
648 | 662 |
649 return 0; | 663 return 0; |
650 } | 664 } |
651 | 665 |
652 | 666 |
653 // Called by parent Scan Module whenver the available current has changed | 667 // Called by parent Scan Module whenver the available current has changed |
654 // current - mA | 668 // current - mA |
655 void LED_currentChange( unsigned int current ) | 669 void LED_currentChange( unsigned int current ) |
656 { | 670 { |
657 // TODO dim LEDs in low power mode instead of shutting off | 671 // Delay action till next LED scan loop (as this callback sometimes occurs during interrupt requests) |
658 if ( current < 150 ) | 672 LED_currentEvent = current; |
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 } | 673 } |
669 | 674 |
670 | 675 |
671 | 676 |
672 // ----- Capabilities ----- | 677 // ----- Capabilities ----- |