C H A P T E R  4

Programming the User LED

This chapter describes how to use the Alarm/User LED. The Alarm/User LED is located on the front panel of the Netra CP2100 series boards. The bi-colored LED is red and green in color (see FIGURE 4-1 for the location of the Alarm/User LED on the board front panel).



Note - Programming the User LED is supported on the Netra CP2140 and the Netra CP2160 boards when they are used with the CP2000 Supplemental CD 4.0 for Solaris 8 only.



In order to use the LED function, support with a sparc v9 64 bit C library and the led.h file are required. The Application Programming Interface (API) for the user is documented in the led.h file. The library and the file are available on the CP2000 Supplemental CD 4.0 for Solaris 8.


FIGURE 4-1 Illustration of a Typical Netra CP2140 Board Front Panel Showing the Alarm/User LED

This is a diagram of a typical CP2140 board front panel showing specifically the location of the Alarm/User LED.



Files and Packages Required to Support the Alarm/User LED

To use the Alarm/User LED feature, the user should update the firmware with the appropriate firmware version that supports this feature on the Netra board.



Note - To check the current firmware version and for instructions on how to update the firmware, refer to the technical reference manual of the Netra board that you are using.



The list of packages that are required are as follows:

/usr/platform/${PLATFORM}/lib

/usr/include/sys/

Ensure that the following drivers are also there, as needed:

/platform/${PLATFORM}/kernel/drv/sparcv9/sc

/platform/${PLATFORM}/kernel/strmod/sparcv9/s_led

A typical example of ${PLATFORM} is UltraSPARCengine_CP-60 for the Netra CP2160 board. An example for the library directory is:

/usr/platform/UltraSPARCengine_CP-60/lib


Applications

This section provides the application programming interface (API) to control the command combination of the Alarm/User LED, and instructions on how to compile and link the information.



Note - Since the LED interface installs and then removes the led_s streams module, an error can occur when multiple applications attempt to use this interface at the same time. If the user desires more than one application to use this interface, application software should incorporate a synchronization method such that only one access to the interface exists at any time.



Application Programming Interface (API)

 


CODE EXAMPLE 4-1 Application Programming Interface for the Netra CP2140 Board
extern	int	led(int led, int cmd);
 
/*	leds */
#define	USER_LED_RED	0x2
#define		USER_LED_GREEN	0x4
 
/*	commands	*/
#define	LED_OFF	0x0
#define	LED_ON	0x1
#define	LED_SQUAREWAVE	0x2
#define	LED_HEARTBEAT	0x3

CODE EXAMPLE 4-2 Application Programming Interface for the Netra CP2160 Board
extern	int	led(int led, int cmd);
 
/*	leds */
#define	USER_LED_RED	0x2
#define		USER_LED_GREEN	0x4
 
/*	commands	*/
#define	LED_OFF	0x0
#define	LED_ON	0x1

 

The supported LED and command combinations are shown in TABLE 4-1 and TABLE 4-2.


TABLE 4-1 Supported LED and Command Combinations for the Netra CP2140 Board

Color of LED[1]

LED_OFF

LED_ON

LED_SQUAREWAVE

LED_HEARTBEAT

USER_LED_RED

Yes

Yes

No

No

USER_LED_GREEN

Yes

Yes

Yes

Yes


TABLE 4-2 Supported LED and Command Combinations for the Netra CP2160 Board

Color of LED[2]

LED_OFF

LED_ON

LED_SQUAREWAVE

LED_HEARTBEAT

USER_LED_RED[3]

Yes

Yes

No

No

USER_LED_GREEN

Yes

Yes

No

No


 

Compile

As you compile your application, you need to use the compiler command (cc) flag
-I, to include the sys/led.h file named in Files and Packages Required to Support the Alarm/User LED. Specify 64-bit binaries by setting the -xarch=v9 and -D__sparcv9 compiler flags.

For example:


-xCC -xarch=v9 -D__sparcv9 -I/usr/platform/sun4u/include/



Note - Type the above command all on one line.



Link

To create a link to the library named (libcp2000.so) listed in Files and Packages Required to Support the Alarm/User LED, use the linker flag -L command.

For example:


-L /usr/platform/UltraSPARCengine_CP-60/lib

 


1 (TableFootnote) When the user turns on the red and green LED at the same time, the light shows as amber. There is no support for a red LED blinking light.
2 (TableFootnote) When the user turns on the red LED, the green LED goes out and when the user turns out the green LED, the red LED goes out. When the user turns off the red LED, only the red LED turns off, and when the user turns off the green LED, only the green LED turns off..
3 (TableFootnote) The Netra CP2160 board has a green and amber light, rather than a green and red light. In the software code, however, the amber light is represented by USER_LED_RED.