BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions | Variables
led.h File Reference

Support for platform-independent LED manipulation. More...

Go to the source code of this file.

Data Structures

struct  sBSP430halLED
 

Macros

#define configBSP430_LED   1
 
#define BSP430_LED   1
 
#define BSP430_LED_GREEN   include <bsp430/platform.h>
 
#define BSP430_LED_RED   include <bsp430/platform.h>
 
#define configBSP430_LED_USE_COMMON   1
 

Typedefs

typedef struct sBSP430halLED sBSP430halLED
 

Functions

void vBSP430ledInitialize_ni (void)
 
void vBSP430ledSet (int led_idx, int value)
 
int vBSP430ledGet (int led_idx)
 

Variables

const sBSP430halLED xBSP430halLED_ []
 
const unsigned char nBSP430led
 

Detailed Description

Support for platform-independent LED manipulation.

Homepage
http://github.com/pabigot/bsp430

Macro Definition Documentation

#define BSP430_LED   1

Indicate that the LED interface is available on the platform. This is normally set by <bsp430/platform.h> when configBSP430_LED is true. If it happens to be false, the LED interface functions are replaced by macros that do nothing.

This flag is defined only if configBSP430_LED is true.

Dependency:
configBSP430_LED
Platform-Based Value:
Undefined here; include <bsp430/platform.h> to obtain the correct value of this macro.
#define BSP430_LED_GREEN   include <bsp430/platform.h>

The platform-specific index for the first green LED.

This macro is defined in the platform-specific header on platforms that include a green LED. It is undefined if no green LED is available. If there are multiple green LEDs, subsequent ones would be numbered beginning with BSP430_LED_GREEN1 to indicate the second (sic) green LED.

Where possible, platforms should define both BSP430_LED_GREEN and BSP430_LED_RED. If one or the other is missing, but multiple LEDs are available, it is appropriate to use a different color for either or both, with the understanding that the inconsistency is specific to that board.

Additional colors may be available and are defined similarly. Availability of an LED color on a platform is determined by checking for the corresponding macro definition.

Platform-Based Value:
Undefined here; include <bsp430/platform.h> to obtain the correct value of this macro.
Examples:
bootstrap/clocks/main.c, bootstrap/console/main.c, and utility/u8glib/main.c.
#define BSP430_LED_RED   include <bsp430/platform.h>

As with BSP430_LED_GREEN, but for red LEDs.

Platform-Based Value:
Undefined here; include <bsp430/platform.h> to obtain the correct value of this macro.
Examples:
bootstrap/clocks/main.c, bootstrap/console/main.c, and utility/u8glib/main.c.
#define configBSP430_LED   1

Define to a true value to indicate intent to use the LED interface. Most platforms should support LEDs directly, bypassing any HAL/HPL interfaces.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Affects:
BSP430_LED
Defaulted:
The value here is superseded by previously encountered definitions.
#define configBSP430_LED_USE_COMMON   1

If the development board has LEDs that can be expressed using sBSP430halLED (i.e., controlled through 8-bit digital I/O ports with a single selection register) then the common implementation of the LED interface can be used. In that case, define this to a true value, and provide within a platform file or the application definitions of the xBSP430halLED_ and nBSP430led variables.

Since most platforms can benefit from the shared implementation, those that do not should override the default value.

C Preprocessor Only:
This macro may have a value that restricts its use to C preprocessor conditional directives.
Defaulted:
The value here is superseded by previously encountered definitions.

Typedef Documentation

typedef struct sBSP430halLED sBSP430halLED

Structure used to define the LED interface.

The assumption is that all MSP430 board LEDs are controlled through GPIO pins. The address of the PxOUT register is provided explicitly; the PxSEL and PxDIR registers are inferred by comparing that address with the known addresses of the PxOUT registers in the initialization loop.

Function Documentation

int vBSP430ledGet ( int  led_idx)

Return a true value iff the given LED is lit.

Parameters
led_idxthe index of the LED to test. Non-existent LEDs are considered to be off.
Returns
0 if the LED is absent or off; non-zero if it is on.
void vBSP430ledInitialize_ni ( void  )

Call to initialize the hardware for all LEDs.

The common implementation uses the LEDs defined in xBSP430halLED_.

Note
Unless configBSP430_LED_USE_COMMON is defined to a true value, the application or platform must define this function.
Examples:
bootstrap/lpm/main.c.
void vBSP430ledSet ( int  led_idx,
int  value 
)

Invoke to change the state of a given LED.

Parameters
led_idxthe index to the LED of interest. The call does should simply return if ucLED does not specify a valid LED.
valuehow to set the LED. If positive, the LED is turned on. If zero, the LED is turned off. If negative, the LED state is inverted.
Note
If configBSP430_LED_USE_COMMON is defined to a true value, the application or platform need not define this function, but must provide the data structures described for configBSP430_LED_USE_COMMON.
Examples:
bootstrap/blink/main.c, bootstrap/button/main.c, bootstrap/clocks/main.c, bootstrap/console/main.c, bootstrap/lpm/main.c, utility/cli/main.c, and utility/u8glib/main.c.

Variable Documentation

const unsigned char nBSP430led

The number of LEDs available on the platform.

If configBSP430_LED_USE_COMMON is true, this is the length of the xBSP430halLED_ configuration array. Otherwise it's just a constant. We'll assume there can't be more than 255 LEDs.

Examples:
bootstrap/blink/main.c.
const sBSP430halLED xBSP430halLED_[]

Platform should define the LED configuration available to it.

Dependency:
BSP430_LED