| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bled.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/6 $ |
|---|
| 12 | * $brcm_Date: 11/11/03 11:59a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/led/7038/bled.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/6 11/11/03 11:59a brianlee |
|---|
| 21 | * Added LED character definitions. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/5 11/6/03 4:12p lseverin |
|---|
| 24 | * updated module overview for DocJet format |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/4 10/1/03 11:41a brianlee |
|---|
| 27 | * Fixed sample code. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/3 9/25/03 12:08p brianlee |
|---|
| 30 | * Fixed tags for Midas service generator. |
|---|
| 31 | * |
|---|
| 32 | * Hydra_Software_Devel/2 9/23/03 10:13a brianlee |
|---|
| 33 | * LED does not need interrupt. |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/1 7/25/03 4:47p brianlee |
|---|
| 36 | * Initial version. |
|---|
| 37 | * |
|---|
| 38 | ***************************************************************************/ |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | /*= Module Overview ********************************************************* |
|---|
| 42 | <verbatim> |
|---|
| 43 | |
|---|
| 44 | Overview |
|---|
| 45 | The LED PI module controls the LED display controller within the BCM7038-B0. The |
|---|
| 46 | LED controller (along with the keypad controller) is not available in the |
|---|
| 47 | BCM7038-A0 version. |
|---|
| 48 | |
|---|
| 49 | Design |
|---|
| 50 | The design for BLED PI API is broken into two parts. |
|---|
| 51 | |
|---|
| 52 | o Part 1 (open/close/configuration): |
|---|
| 53 | |
|---|
| 54 | These APIs are used for opening and closing BLED device. |
|---|
| 55 | |
|---|
| 56 | o Part 2 (write to LED display) |
|---|
| 57 | |
|---|
| 58 | These APIs are used to write to an LED digit or discrete LED. |
|---|
| 59 | |
|---|
| 60 | Usage |
|---|
| 61 | The usage of BLED involves the following: |
|---|
| 62 | |
|---|
| 63 | * Configure/Open of BLED |
|---|
| 64 | |
|---|
| 65 | * Configure BLED device for the target system |
|---|
| 66 | * Open BLED device |
|---|
| 67 | |
|---|
| 68 | * Write value to LED digit or discrete LED. |
|---|
| 69 | |
|---|
| 70 | Sample Code |
|---|
| 71 | void main( void ) |
|---|
| 72 | { |
|---|
| 73 | BLED_Handle hLED; |
|---|
| 74 | BLED_Settings defSettings; |
|---|
| 75 | BREG_Handle hReg; |
|---|
| 76 | BCHP_Handle hChip; |
|---|
| 77 | |
|---|
| 78 | // Do other initialization, i.e. for BREG, BCHP, etc |
|---|
| 79 | |
|---|
| 80 | // Now, ready to setup the BLED |
|---|
| 81 | BLED_GetDefaultSettings( &defSettings, hChip ); |
|---|
| 82 | |
|---|
| 83 | // Make any changes required from the default values |
|---|
| 84 | defSettings.percentBrightness = 100; |
|---|
| 85 | |
|---|
| 86 | BLED_Open (&hLED, hChip, hReg, &defSettings); |
|---|
| 87 | |
|---|
| 88 | // Display "7038" on the front panel |
|---|
| 89 | BLED_Write (hLED, 1, LED_NUM7); |
|---|
| 90 | BLED_Write (hLED, 2, LED_NUM0); |
|---|
| 91 | BLED_Write (hLED, 3, LED_NUM3); |
|---|
| 92 | BLED_Write (hLED, 4, LED_NUM8); |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | </verbatim> |
|---|
| 96 | ***************************************************************************/ |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | #ifndef BLED_H__ |
|---|
| 100 | #define BLED_H__ |
|---|
| 101 | |
|---|
| 102 | #include "bchp.h" |
|---|
| 103 | #include "breg_mem.h" |
|---|
| 104 | #include "bint.h" |
|---|
| 105 | #include "bkni.h" |
|---|
| 106 | #include "berr_ids.h" |
|---|
| 107 | |
|---|
| 108 | #ifdef __cplusplus |
|---|
| 109 | extern "C" { |
|---|
| 110 | #endif |
|---|
| 111 | |
|---|
| 112 | /*************************************************************************** |
|---|
| 113 | Summary: |
|---|
| 114 | LED segments and characters |
|---|
| 115 | |
|---|
| 116 | Description: |
|---|
| 117 | |
|---|
| 118 | See Also: |
|---|
| 119 | |
|---|
| 120 | ****************************************************************************/ |
|---|
| 121 | #define LED_ON 0x80 |
|---|
| 122 | #define LED_TOP_OFF 0x01 |
|---|
| 123 | #define LED_RU_OFF 0x02 |
|---|
| 124 | #define LED_RL_OFF 0x04 |
|---|
| 125 | #define LED_BOT_OFF 0x08 |
|---|
| 126 | #define LED_LL_OFF 0x10 |
|---|
| 127 | #define LED_LU_OFF 0x20 |
|---|
| 128 | #define LED_MID_OFF 0x40 |
|---|
| 129 | |
|---|
| 130 | #define LED_A (0x88) |
|---|
| 131 | #define LED_B (0x80) |
|---|
| 132 | #define LED_C (0xc6) |
|---|
| 133 | #define LED_D (0xc0) |
|---|
| 134 | #define LED_E (0x86) |
|---|
| 135 | #define LED_F (0x8e) |
|---|
| 136 | #define LED_G (0x82) |
|---|
| 137 | #define LED_H (0x89) |
|---|
| 138 | #define LED_I (0xf9) |
|---|
| 139 | #define LED_J (0xf1) |
|---|
| 140 | #define LED_K (0x89) |
|---|
| 141 | #define LED_L (0xc7) |
|---|
| 142 | #define LED_M (0x88) |
|---|
| 143 | #define LED_N (0xc8) |
|---|
| 144 | #define LED_O (0xc0) |
|---|
| 145 | #define LED_P (0x8c) |
|---|
| 146 | #define LED_Q (0xc0) |
|---|
| 147 | #define LED_R (0x88) |
|---|
| 148 | #define LED_S (0x92) |
|---|
| 149 | #define LED_T (0xf8) |
|---|
| 150 | #define LED_U (0xC1) |
|---|
| 151 | #define LED_V (0xC1) |
|---|
| 152 | #define LED_W (0x81) |
|---|
| 153 | #define LED_X (0x89) |
|---|
| 154 | #define LED_Y (0x91) |
|---|
| 155 | #define LED_Z (0xa4) |
|---|
| 156 | |
|---|
| 157 | #define LED_DASH (0xbf) |
|---|
| 158 | |
|---|
| 159 | #define LED_NUM0 (0xc0) |
|---|
| 160 | #define LED_NUM1 (0xf9) |
|---|
| 161 | #define LED_NUM2 (0xa4) |
|---|
| 162 | #define LED_NUM3 (0xb0) |
|---|
| 163 | #define LED_NUM4 (0x99) |
|---|
| 164 | #define LED_NUM5 (0x92) |
|---|
| 165 | #define LED_NUM6 (0x82) |
|---|
| 166 | #define LED_NUM7 (0xf8) |
|---|
| 167 | #define LED_NUM8 (0x80) |
|---|
| 168 | #define LED_NUM9 (0x98) |
|---|
| 169 | |
|---|
| 170 | /*************************************************************************** |
|---|
| 171 | Summary: |
|---|
| 172 | Error Codes specific to BLED |
|---|
| 173 | |
|---|
| 174 | Description: |
|---|
| 175 | |
|---|
| 176 | See Also: |
|---|
| 177 | |
|---|
| 178 | ****************************************************************************/ |
|---|
| 179 | |
|---|
| 180 | /*************************************************************************** |
|---|
| 181 | Summary: |
|---|
| 182 | The handle for led module. |
|---|
| 183 | |
|---|
| 184 | Description: |
|---|
| 185 | |
|---|
| 186 | See Also: |
|---|
| 187 | BLED_Open() |
|---|
| 188 | |
|---|
| 189 | ****************************************************************************/ |
|---|
| 190 | typedef struct BLED_P_Handle *BLED_Handle; |
|---|
| 191 | |
|---|
| 192 | /*************************************************************************** |
|---|
| 193 | Summary: |
|---|
| 194 | Required default settings structure for LED module. |
|---|
| 195 | |
|---|
| 196 | Description: |
|---|
| 197 | The default setting structure defines the default configure of |
|---|
| 198 | LED when the device is opened. |
|---|
| 199 | |
|---|
| 200 | See Also: |
|---|
| 201 | BLED_Open() |
|---|
| 202 | |
|---|
| 203 | ****************************************************************************/ |
|---|
| 204 | typedef struct BLED_Settings |
|---|
| 205 | { |
|---|
| 206 | uint8_t percentBrightness; /* percent brightness */ |
|---|
| 207 | } BLED_Settings; |
|---|
| 208 | |
|---|
| 209 | /*************************************************************************** |
|---|
| 210 | Summary: |
|---|
| 211 | This function opens LED module. |
|---|
| 212 | |
|---|
| 213 | Description: |
|---|
| 214 | This function is responsible for opening BLED module. When BLED is |
|---|
| 215 | opened, it will create a module handle and configure the module based |
|---|
| 216 | on the default settings. Once the device is opened, it must be closed |
|---|
| 217 | before it can be opened again. |
|---|
| 218 | |
|---|
| 219 | Returns: |
|---|
| 220 | TODO: |
|---|
| 221 | |
|---|
| 222 | See Also: |
|---|
| 223 | BLED_Close() |
|---|
| 224 | BLED_GetDefaultSettings() |
|---|
| 225 | |
|---|
| 226 | ****************************************************************************/ |
|---|
| 227 | BERR_Code BLED_Open( |
|---|
| 228 | BLED_Handle *pLED, /* [out] Returns handle */ |
|---|
| 229 | BCHP_Handle hChip, /* [in] Chip handle */ |
|---|
| 230 | BREG_Handle hRegister, /* [in] Register handle */ |
|---|
| 231 | const BLED_Settings *pDefSettings /* [in] Default settings */ |
|---|
| 232 | ); |
|---|
| 233 | |
|---|
| 234 | /*************************************************************************** |
|---|
| 235 | Summary: |
|---|
| 236 | This function closes LED module. |
|---|
| 237 | |
|---|
| 238 | Description: |
|---|
| 239 | This function is responsible for closing BLED module. Closing BLED |
|---|
| 240 | will free main BLED handle. |
|---|
| 241 | |
|---|
| 242 | Returns: |
|---|
| 243 | TODO: |
|---|
| 244 | |
|---|
| 245 | See Also: |
|---|
| 246 | BLED_Open() |
|---|
| 247 | |
|---|
| 248 | ****************************************************************************/ |
|---|
| 249 | BERR_Code BLED_Close( |
|---|
| 250 | BLED_Handle hDev /* [in] Device handle */ |
|---|
| 251 | ); |
|---|
| 252 | |
|---|
| 253 | /*************************************************************************** |
|---|
| 254 | Summary: |
|---|
| 255 | This function returns the default settings for LED module. |
|---|
| 256 | |
|---|
| 257 | Description: |
|---|
| 258 | This function is responsible for returns the default setting for |
|---|
| 259 | BLED module. The returning default setting should be when |
|---|
| 260 | opening the device. |
|---|
| 261 | |
|---|
| 262 | Returns: |
|---|
| 263 | TODO: |
|---|
| 264 | |
|---|
| 265 | See Also: |
|---|
| 266 | BLED_Open() |
|---|
| 267 | |
|---|
| 268 | ****************************************************************************/ |
|---|
| 269 | BERR_Code BLED_GetDefaultSettings( |
|---|
| 270 | BLED_Settings *pDefSettings, /* [out] Returns default setting */ |
|---|
| 271 | BCHP_Handle hChip /* [in] Chip handle */ |
|---|
| 272 | ); |
|---|
| 273 | |
|---|
| 274 | /*************************************************************************** |
|---|
| 275 | Summary: |
|---|
| 276 | This function writes an LED digit |
|---|
| 277 | |
|---|
| 278 | Description: |
|---|
| 279 | This function is used to write a character to an LED digit. |
|---|
| 280 | |
|---|
| 281 | Returns: |
|---|
| 282 | TODO: |
|---|
| 283 | |
|---|
| 284 | See Also: |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | ****************************************************************************/ |
|---|
| 288 | BERR_Code BLED_Write ( |
|---|
| 289 | BLED_Handle hLed, /* [in] Device handle */ |
|---|
| 290 | uint8_t digit, /* [in] digit to write to */ |
|---|
| 291 | uint8_t value /* [in] value to write */ |
|---|
| 292 | ); |
|---|
| 293 | |
|---|
| 294 | /*************************************************************************** |
|---|
| 295 | Summary: |
|---|
| 296 | This function adjusts the brightness of LED. |
|---|
| 297 | |
|---|
| 298 | Description: |
|---|
| 299 | This function is used to adjust LED brightness. The caller specifies |
|---|
| 300 | the percentage of brightness from (0-100). |
|---|
| 301 | |
|---|
| 302 | Returns: |
|---|
| 303 | TODO: |
|---|
| 304 | |
|---|
| 305 | See Also: |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | ****************************************************************************/ |
|---|
| 309 | BERR_Code BLED_AdjustBrightness ( |
|---|
| 310 | BLED_Handle hLed, /* [in] Device handle */ |
|---|
| 311 | uint8_t percentBrightness /* [in] percent of brightness */ |
|---|
| 312 | ); |
|---|
| 313 | |
|---|
| 314 | /*************************************************************************** |
|---|
| 315 | Summary: |
|---|
| 316 | This function writes to a discrete LED |
|---|
| 317 | |
|---|
| 318 | Description: |
|---|
| 319 | This function is used to turn on or off a discrete LED |
|---|
| 320 | |
|---|
| 321 | Returns: |
|---|
| 322 | TODO: |
|---|
| 323 | |
|---|
| 324 | See Also: |
|---|
| 325 | |
|---|
| 326 | |
|---|
| 327 | ****************************************************************************/ |
|---|
| 328 | BERR_Code BLED_SetDiscreteLED ( |
|---|
| 329 | BLED_Handle hLed, /* [in] Device handle */ |
|---|
| 330 | bool on, /* [in] turn on or off */ |
|---|
| 331 | uint8_t ledStatusBit /* [in] bit to turn on or off */ |
|---|
| 332 | ); |
|---|
| 333 | |
|---|
| 334 | #ifdef __cplusplus |
|---|
| 335 | } |
|---|
| 336 | #endif |
|---|
| 337 | |
|---|
| 338 | #endif |
|---|
| 339 | |
|---|
| 340 | |
|---|
| 341 | |
|---|