SLAA476B February 2011 – July 2019 BQ2040 , BQ2040 , BQ2060A , BQ2060A , BQ2063 , BQ2063 , BQ2083-V1P3 , BQ2083-V1P3 , BQ2084-V143 , BQ2084-V143 , BQ2084-V150 , BQ2084-V150 , BQ2085-V1P3 , BQ2085-V1P3 , BQ20Z40-R1 , BQ20Z40-R1 , BQ20Z70-V160 , BQ20Z70-V160 , BQ20Z80A-V110 , BQ20Z80A-V110 , BQ28400 , BQ28400 , BQ78PL114 , BQ78PL114 , BQ78PL116 , BQ78PL116 , LM5145 , LM5145 , MSP430F5500 , MSP430F5500 , MSP430F5501 , MSP430F5501 , MSP430F5502 , MSP430F5502 , MSP430F5503 , MSP430F5503 , MSP430F5504 , MSP430F5504 , MSP430F5505 , MSP430F5505 , MSP430F5506 , MSP430F5506 , MSP430F5507 , MSP430F5507 , MSP430F5508 , MSP430F5508 , MSP430F5509 , MSP430F5509 , MSP430F5510 , MSP430F5510 , TPS40057 , TPS40057 , TPS40170 , TPS40170
This function configures all of the port bits connected to the LEDs to output direction and initializes all LEDs to off state.
Function Definition
void LED_Init(void) {...}
Inputs
None
Return
None
Example Function Call
LED_Init();
The function uses a structure to map the MSP430F5510 port pins to the LEDs. To allow multiple LEDs to blink at different intervals, virtual timer counters are used to keep track of the time-out duration. This structure declaration keeps track of the virtual count for each LED as well as the time-out duration.
Structure Definition Name
LEDDescription_t
Name | Type | Description | Example Value |
---|---|---|---|
PortOutAddr | unsigned int | Address of the Port Out Register of the LED control output. This register controls the on/off state of the output. | P2OUT_ADDR |
PortDirAddr | unsigned int | Address of the Port Direction Register. This register controls the input/output capability of the port. | P2DIR_ADDR |
PortBit | unsigned int | Bit of the Port (value can range from 0 to 15) | BIT0, BIT1, ..., BITF |
LEDVirtualTimer (1) | unsigned char | Virtual Timer keeps tracks of timer ticks before time-out expires and LED is toggled. | 0 |
LEDBlinkPeriod (1) | unsigned char | This parameter contains the time-out period that the virtual timer starts counting down from. This parameter is used to adjust the LED blink rate. | 0 |
Example Structure Declaration
For a case with two LEDs on P2.0 and P2.1:
// Constant defined in header file
#define LED_DEFAULT_STATE { { P2OUT_ADDR, P2DIR_ADDR, BIT0, 0, 0 }, { P2OUT_ADDR, P2DIR_ADDR, BIT1, 0, 0 } }
// Declaration in source code file
LEDDescription_t LEDs[2] = LED_DEFAULT_STATE;