| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-2010 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_led.h $ |
|---|
| 39 | * $brcm_Revision: 7 $ |
|---|
| 40 | * $brcm_Date: 12/14/10 3:25p $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * LED output control |
|---|
| 44 | * |
|---|
| 45 | * Revision History: |
|---|
| 46 | * |
|---|
| 47 | * $brcm_Log: /nexus/modules/led/7400/include/nexus_led.h $ |
|---|
| 48 | * |
|---|
| 49 | * 7 12/14/10 3:25p erickson |
|---|
| 50 | * SW7420-1285: add null_allowed attribute |
|---|
| 51 | * |
|---|
| 52 | * 6 10/14/09 2:30p erickson |
|---|
| 53 | * SW7405-3181: add NEXUS_Led_WriteSegments |
|---|
| 54 | * |
|---|
| 55 | * 5 7/23/09 12:00p erickson |
|---|
| 56 | * PR57047: add NEXUS_Led_SetDot |
|---|
| 57 | * |
|---|
| 58 | * 4 2/4/08 4:28p vsilyaev |
|---|
| 59 | * PR 38682: Added more tags for the linux kernel/user proxy mode |
|---|
| 60 | * |
|---|
| 61 | * 3 1/23/08 8:36p vobadm |
|---|
| 62 | * PR35457: update docs |
|---|
| 63 | * |
|---|
| 64 | * 2 1/23/08 5:16p erickson |
|---|
| 65 | * PR35457: update docs |
|---|
| 66 | * |
|---|
| 67 | * 1 1/18/08 2:21p jgarrett |
|---|
| 68 | * PR 38808: Merging to main branch |
|---|
| 69 | * |
|---|
| 70 | * Nexus_Devel/2 11/21/07 11:12a erickson |
|---|
| 71 | * PR37423: update |
|---|
| 72 | * |
|---|
| 73 | * Nexus_Devel/1 11/20/07 4:53p erickson |
|---|
| 74 | * PR37423: adding ir_input and led |
|---|
| 75 | * |
|---|
| 76 | * Nexus_Devel/1 9/12/07 6:32p jgarrett |
|---|
| 77 | * PR 34702: Adding LED control |
|---|
| 78 | * |
|---|
| 79 | ***************************************************************************/ |
|---|
| 80 | |
|---|
| 81 | #ifndef NEXUS_LED_H__ |
|---|
| 82 | #define NEXUS_LED_H__ |
|---|
| 83 | |
|---|
| 84 | #ifdef __cplusplus |
|---|
| 85 | extern "C" { |
|---|
| 86 | #endif |
|---|
| 87 | |
|---|
| 88 | typedef struct NEXUS_Led *NEXUS_LedHandle; |
|---|
| 89 | |
|---|
| 90 | /*************************************************************************** |
|---|
| 91 | Summary: |
|---|
| 92 | Settings for an LED controller |
|---|
| 93 | ****************************************************************************/ |
|---|
| 94 | typedef struct NEXUS_LedSettings |
|---|
| 95 | { |
|---|
| 96 | unsigned brightness; /* Percent of brightness (0..100) */ |
|---|
| 97 | |
|---|
| 98 | bool scrollingEnabled; /* Is scrolling enabled? If false, data will be clipped to the size of the display */ |
|---|
| 99 | bool alwaysScroll; /* Scroll even if the number of characters will fit on the screen */ |
|---|
| 100 | unsigned scrollDelay; /* in milliseconds, delay between each character while scrolling */ |
|---|
| 101 | } NEXUS_LedSettings; |
|---|
| 102 | |
|---|
| 103 | /*************************************************************************** |
|---|
| 104 | Summary: |
|---|
| 105 | Digits on the LED display |
|---|
| 106 | ****************************************************************************/ |
|---|
| 107 | typedef enum NEXUS_LedDigit |
|---|
| 108 | { |
|---|
| 109 | NEXUS_LedDigit_e1 = 1, |
|---|
| 110 | NEXUS_LedDigit_e2, |
|---|
| 111 | NEXUS_LedDigit_e3, |
|---|
| 112 | NEXUS_LedDigit_e4, |
|---|
| 113 | NEXUS_LedDigit_eMax |
|---|
| 114 | } NEXUS_LedDigit; |
|---|
| 115 | |
|---|
| 116 | /*************************************************************************** |
|---|
| 117 | Summary: |
|---|
| 118 | Individual segments of a single LED digit |
|---|
| 119 | ****************************************************************************/ |
|---|
| 120 | typedef enum NEXUS_LedSegment |
|---|
| 121 | { |
|---|
| 122 | NEXUS_LedSegment_eTop = 0x01, |
|---|
| 123 | NEXUS_LedSegment_eUpperRight = 0x02, |
|---|
| 124 | NEXUS_LedSegment_eLowerRight = 0x04, |
|---|
| 125 | NEXUS_LedSegment_eBottom = 0x08, |
|---|
| 126 | NEXUS_LedSegment_eLowerLeft = 0x10, |
|---|
| 127 | NEXUS_LedSegment_eUpperLeft = 0x20, |
|---|
| 128 | NEXUS_LedSegment_eMiddle = 0x40, |
|---|
| 129 | NEXUS_LedSegment_eDot = 0x80, |
|---|
| 130 | NEXUS_LedSegment_eMax |
|---|
| 131 | } NEXUS_LedSegment; |
|---|
| 132 | |
|---|
| 133 | /*************************************************************************** |
|---|
| 134 | Summary: |
|---|
| 135 | This function returns the default settings for an LED controller |
|---|
| 136 | ****************************************************************************/ |
|---|
| 137 | void NEXUS_Led_GetDefaultSettings( |
|---|
| 138 | NEXUS_LedSettings *pSettings /* [out] */ |
|---|
| 139 | ); |
|---|
| 140 | |
|---|
| 141 | /*************************************************************************** |
|---|
| 142 | Summary: |
|---|
| 143 | This function opens an LED controller |
|---|
| 144 | ****************************************************************************/ |
|---|
| 145 | NEXUS_LedHandle NEXUS_Led_Open( /* attr{destructor=NEXUS_Led_Close} */ |
|---|
| 146 | unsigned index, |
|---|
| 147 | const NEXUS_LedSettings *pSettings /* attr{null_allowed=y} */ |
|---|
| 148 | ); |
|---|
| 149 | |
|---|
| 150 | /*************************************************************************** |
|---|
| 151 | Summary: |
|---|
| 152 | This function closes an LED controller |
|---|
| 153 | ****************************************************************************/ |
|---|
| 154 | void NEXUS_Led_Close( |
|---|
| 155 | NEXUS_LedHandle handle |
|---|
| 156 | ); |
|---|
| 157 | |
|---|
| 158 | /*************************************************************************** |
|---|
| 159 | Summary: |
|---|
| 160 | This function retrieves the current settings for an LED controller |
|---|
| 161 | ****************************************************************************/ |
|---|
| 162 | void NEXUS_Led_GetSettings( |
|---|
| 163 | NEXUS_LedHandle handle, |
|---|
| 164 | NEXUS_LedSettings *pSettings /* [out] */ |
|---|
| 165 | ); |
|---|
| 166 | |
|---|
| 167 | /*************************************************************************** |
|---|
| 168 | Summary: |
|---|
| 169 | This function sets the current settings for an LED controller |
|---|
| 170 | ****************************************************************************/ |
|---|
| 171 | NEXUS_Error NEXUS_Led_SetSettings( |
|---|
| 172 | NEXUS_LedHandle handle, |
|---|
| 173 | const NEXUS_LedSettings *pSettings |
|---|
| 174 | ); |
|---|
| 175 | |
|---|
| 176 | /*************************************************************************** |
|---|
| 177 | Summary: |
|---|
| 178 | Write a string to the seven-segment LED display. |
|---|
| 179 | |
|---|
| 180 | Description: |
|---|
| 181 | If the length of pString is greater than the number of available LED characters, |
|---|
| 182 | the scrolling option specified in NEXUS_LedSettings will be used. |
|---|
| 183 | |
|---|
| 184 | ****************************************************************************/ |
|---|
| 185 | NEXUS_Error NEXUS_Led_WriteString( |
|---|
| 186 | NEXUS_LedHandle handle, |
|---|
| 187 | const char *pString, /* attr{fixed_length=128} ASCII string which is either NULL-terminated or terminated by the length parameter. */ |
|---|
| 188 | unsigned length /* This limits the number of characters used in pString. If 0 or greater than the length of pString, pString will be terminated by a NULL-terminator. */ |
|---|
| 189 | ); |
|---|
| 190 | |
|---|
| 191 | /*************************************************************************** |
|---|
| 192 | Summary: |
|---|
| 193 | Write a custom value to a single LED digit. |
|---|
| 194 | |
|---|
| 195 | Description: |
|---|
| 196 | Use bitwise OR of NEXUS_LedSegment elements to construct the value to be written. |
|---|
| 197 | ****************************************************************************/ |
|---|
| 198 | NEXUS_Error NEXUS_Led_WriteSegments( |
|---|
| 199 | NEXUS_LedHandle handle, |
|---|
| 200 | NEXUS_LedDigit digit, |
|---|
| 201 | uint8_t value /* Value to be written to the digit. Writing 0 clears the digit */ |
|---|
| 202 | ); |
|---|
| 203 | |
|---|
| 204 | /*************************************************************************** |
|---|
| 205 | Summary: |
|---|
| 206 | Set the dots on a seven-segment LED display. |
|---|
| 207 | |
|---|
| 208 | Description: |
|---|
| 209 | The seven bars of the LED seven-segment display are controlled with NEXUS_Led_WriteString. |
|---|
| 210 | In addition, these digits also have dots, either in the lower right corner or upper left corner. |
|---|
| 211 | This API sets those bits. |
|---|
| 212 | By default they are off. |
|---|
| 213 | ****************************************************************************/ |
|---|
| 214 | NEXUS_Error NEXUS_Led_SetDot( |
|---|
| 215 | NEXUS_LedHandle handle, |
|---|
| 216 | unsigned dotIndex, /* corresponds to the index of characters in NEXUS_Led_WriteString's pString[] */ |
|---|
| 217 | bool enabled /* true = on, false = off */ |
|---|
| 218 | ); |
|---|
| 219 | |
|---|
| 220 | /*************************************************************************** |
|---|
| 221 | Summary: |
|---|
| 222 | This function sets the state of a discrete LED on the LED controller. |
|---|
| 223 | ****************************************************************************/ |
|---|
| 224 | NEXUS_Error NEXUS_Led_SetLedState( |
|---|
| 225 | NEXUS_LedHandle handle, |
|---|
| 226 | unsigned ledNumber, |
|---|
| 227 | bool active |
|---|
| 228 | ); |
|---|
| 229 | |
|---|
| 230 | #ifdef __cplusplus |
|---|
| 231 | } |
|---|
| 232 | #endif |
|---|
| 233 | |
|---|
| 234 | #endif /* #ifndef NEXUS_LED_H__ */ |
|---|
| 235 | |
|---|