/**
* Update status LEDs with current value from shadow register.
*
* Additional info:
* This function ensures that the LED pins are not driven low to allow
* other circuitry to be connected to the I/O pads on the mainboard!
* As long as external circuits only connect the I/O pads to VCC and not to
* GND, everything should work fine, but always connect a >= 470 Ohm
* series resistor to limit maximum current!
*
*
* Example:
*
* statusLEDs.byte=0b101001;
* updateStatusLEDs();
* // this clears all LEDs and sets the LEDs STATUS1,
* // STATUS6 and STATUS4!
*
* // Other possibility:
* statusLEDs.LED2=true;
* updateStatusLEDs();
* // This sets LED2 and does not affect any other LED!
*/
void updateStatusLEDs(void)
{
DDRB &= ~0x83;
PORTB &= ~0x83;
if(statusLEDs.LED4){ DDRB |= SL4; PORTB |= SL4; }
if(statusLEDs.LED5){ DDRB |= SL5; PORTB |= SL5; }
if(statusLEDs.LED6){ DDRB |= SL6; PORTB |= SL6; }
DDRC &= ~0x70;
PORTC &= ~0x70;
DDRC |= ((statusLEDs.byte << 4) & 0x70);
PORTC |= ((statusLEDs.byte << 4) & 0x70);
#ifdef POWER_ON_WARNING
leds_on = (leds_on ? leds_on : (statusLEDs.byte && 1));
#endif
}
Lesezeichen