| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2011, 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: bkpd.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/26 $ |
|---|
| 12 | * $brcm_Date: 11/21/11 6:20p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/kpd/7435/bkpd.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/26 11/21/11 6:20p mward |
|---|
| 21 | * SW7435-7: Add 7435. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/25 10/11/11 11:24a katrep |
|---|
| 24 | * SW7429-1:add 7429 support |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/24 2/1/11 7:12a agin |
|---|
| 27 | * SW7335-884: Need to enable irqen bit in the BCHP_LDK_CONTROL register |
|---|
| 28 | * regardless of using interrupt mode or polling mode. |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/23 1/14/11 8:04p brianlee |
|---|
| 31 | * SW7422-197: Make sure to zero out upper bits of LDK_CONTROL during |
|---|
| 32 | * initialization. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/22 12/27/10 2:48p xhuang |
|---|
| 35 | * SW7358-29: Add 7358/7552 support |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/21 12/8/10 5:58p katrep |
|---|
| 38 | * SW7231-4:add support for 7231 |
|---|
| 39 | * |
|---|
| 40 | * Hydra_Software_Devel/20 12/7/10 6:16p jrubio |
|---|
| 41 | * SW7344-9: add 7344/7346 support |
|---|
| 42 | * |
|---|
| 43 | * Hydra_Software_Devel/19 11/2/10 5:06p hongtaoz |
|---|
| 44 | * SW7425-9: added 7425 support; |
|---|
| 45 | * |
|---|
| 46 | * Hydra_Software_Devel/18 10/7/10 4:51p nickh |
|---|
| 47 | * SW7422-74: Add 7422 support |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/17 7/8/10 5:28p jkim |
|---|
| 50 | * SW7405-751: Bring KPD core out of reset and program DUTY CYCLE to make |
|---|
| 51 | * it work without opening LED PI. |
|---|
| 52 | * |
|---|
| 53 | * Hydra_Software_Devel/16 12/13/09 6:42p rpereira |
|---|
| 54 | * SW7550-41: Fixed compilation issues for 7550 |
|---|
| 55 | * |
|---|
| 56 | * Hydra_Software_Devel/15 4/9/08 10:55a farshidf |
|---|
| 57 | * PR39192: fix compile error |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/14 4/9/08 10:10a farshidf |
|---|
| 60 | * PR39192: add 3548 support |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/13 10/4/07 5:19p brianlee |
|---|
| 63 | * PR35042: Set returned pointer to NULL if error occurs during kpd open. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/12 10/4/07 4:28p brianlee |
|---|
| 66 | * PR35042: Fixed potential memory leak problem. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/11 2/2/07 11:21a jkim |
|---|
| 69 | * PR27238: Modify to use the correct IRQ definition |
|---|
| 70 | * |
|---|
| 71 | * Hydra_Software_Devel/10 1/12/07 4:20p jkim |
|---|
| 72 | * PR14344: Add 3563 support |
|---|
| 73 | * |
|---|
| 74 | * Hydra_Software_Devel/9 11/10/05 12:38p erickson |
|---|
| 75 | * PR17936: don't read the L2 interrupt status and enable registers here |
|---|
| 76 | * instead, trust that BINT will only call you if the interrupt actually |
|---|
| 77 | * fired. this allows the L2 to be masked in the usermodedrv and yet |
|---|
| 78 | * still processed by BINT. This is critical because the UPG_CPU_INTR is |
|---|
| 79 | * shared with the linux kernel and cannot be masked. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/8 9/15/04 11:50a brianlee |
|---|
| 82 | * PR12504: Added function to allow user to install interrupt callback. |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/7 5/27/04 5:15p brianlee |
|---|
| 85 | * PR11238: Fixed code to work with 7038 B0. |
|---|
| 86 | * |
|---|
| 87 | * Hydra_Software_Devel/6 2/3/04 4:02p brianlee |
|---|
| 88 | * PR9598: Make 7038 kpd compile for now, we don't have RDB file for B0 |
|---|
| 89 | * yet. |
|---|
| 90 | * |
|---|
| 91 | * Hydra_Software_Devel/5 1/30/04 11:03a brianlee |
|---|
| 92 | * PR9535: Fixed compile error in createcallback function call for now. |
|---|
| 93 | * Must put in int ID when RDB for 7038B0 becomes available. |
|---|
| 94 | * |
|---|
| 95 | * Hydra_Software_Devel/4 12/29/03 3:59p marcusk |
|---|
| 96 | * PR9117: Updated with changes required to support interrupt ids rather |
|---|
| 97 | * than strings. |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/3 11/4/03 6:59p brianlee |
|---|
| 100 | * Get rid of enter/leave macros. |
|---|
| 101 | * |
|---|
| 102 | * Hydra_Software_Devel/2 9/30/03 11:21a brianlee |
|---|
| 103 | * Fixed a warning. |
|---|
| 104 | * |
|---|
| 105 | * Hydra_Software_Devel/1 9/23/03 11:41a brianlee |
|---|
| 106 | * Initial version. This version contains stubs for now since 7038 A0 |
|---|
| 107 | * does not have keypad controller. |
|---|
| 108 | * |
|---|
| 109 | ***************************************************************************/ |
|---|
| 110 | #include "bstd.h" |
|---|
| 111 | #include "bkpd.h" |
|---|
| 112 | #include "bchp_ldk.h" |
|---|
| 113 | #include "bchp_irq0.h" |
|---|
| 114 | #include "bchp_int_id_irq0.h" |
|---|
| 115 | #if (BCHP_CHIP==7422) || (BCHP_CHIP==7425) || (BCHP_CHIP==7429) || (BCHP_CHIP==7344) || (BCHP_CHIP==7346) || (BCHP_CHIP==7231) || \ |
|---|
| 116 | (BCHP_CHIP==7358) || (BCHP_CHIP==7552) || (BCHP_CHIP==7435) |
|---|
| 117 | #include "bchp_int_id_irq0_aon.h" |
|---|
| 118 | #include "bchp_irq0_aon.h" |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | BDBG_MODULE(bkpd); |
|---|
| 122 | |
|---|
| 123 | #define DEV_MAGIC_ID ((BERR_KPD_ID<<16) | 0xFACE) |
|---|
| 124 | |
|---|
| 125 | #define BKPD_CHK_RETCODE( rc, func ) \ |
|---|
| 126 | do { \ |
|---|
| 127 | if( (rc = BERR_TRACE(func)) != BERR_SUCCESS ) \ |
|---|
| 128 | { \ |
|---|
| 129 | goto done; \ |
|---|
| 130 | } \ |
|---|
| 131 | } while(0) |
|---|
| 132 | |
|---|
| 133 | #define KPD_DEFAULT_PRESCALE 0x0055 |
|---|
| 134 | #define KPD_DEFAULT_DUTYCYCLE_OFF 0x01 |
|---|
| 135 | #define KPD_DEFAULT_DUTYCYCLE_ON 0xAA |
|---|
| 136 | #define KPD_DEFAULT_DEBOUNCE 0x40 |
|---|
| 137 | |
|---|
| 138 | #if (BCHP_CHIP==3563) || (BCHP_CHIP==3548) || (BCHP_CHIP==3556) || (BCHP_CHIP==7550) |
|---|
| 139 | #ifndef BCHP_INT_ID_ldk_irqen |
|---|
| 140 | #define BCHP_INT_ID_ldk_irqen BCHP_INT_ID_ldk |
|---|
| 141 | #endif |
|---|
| 142 | #endif |
|---|
| 143 | static void BKPD_P_HandleInterrupt_Isr |
|---|
| 144 | ( |
|---|
| 145 | void *pParam1, /* Device channel handle */ |
|---|
| 146 | int parm2 /* not used */ |
|---|
| 147 | ); |
|---|
| 148 | |
|---|
| 149 | /******************************************************************************* |
|---|
| 150 | * |
|---|
| 151 | * Private Module Handles |
|---|
| 152 | * |
|---|
| 153 | *******************************************************************************/ |
|---|
| 154 | |
|---|
| 155 | typedef struct BKPD_P_Handle |
|---|
| 156 | { |
|---|
| 157 | uint32_t magicId; /* Used to check if structure is corrupt */ |
|---|
| 158 | BCHP_Handle hChip; |
|---|
| 159 | BREG_Handle hRegister; |
|---|
| 160 | BINT_Handle hInterrupt; |
|---|
| 161 | BKNI_EventHandle hEvent; |
|---|
| 162 | BINT_CallbackHandle hCallback; |
|---|
| 163 | bool intMode; |
|---|
| 164 | BKPD_CallbackInfo stCallbackInfo; |
|---|
| 165 | } BKPD_P_Handle; |
|---|
| 166 | |
|---|
| 167 | /******************************************************************************* |
|---|
| 168 | * |
|---|
| 169 | * Default Module Settings |
|---|
| 170 | * |
|---|
| 171 | *******************************************************************************/ |
|---|
| 172 | static const BKPD_Settings defKpdSettings = |
|---|
| 173 | { |
|---|
| 174 | KPD_DEFAULT_PRESCALE, |
|---|
| 175 | KPD_DEFAULT_DEBOUNCE, |
|---|
| 176 | true |
|---|
| 177 | }; |
|---|
| 178 | |
|---|
| 179 | /******************************************************************************* |
|---|
| 180 | * |
|---|
| 181 | * Public Module Functions |
|---|
| 182 | * |
|---|
| 183 | *******************************************************************************/ |
|---|
| 184 | BERR_Code BKPD_Open( |
|---|
| 185 | BKPD_Handle *pKpd, /* [output] Returns handle */ |
|---|
| 186 | BCHP_Handle hChip, /* Chip handle */ |
|---|
| 187 | BREG_Handle hRegister, /* Register handle */ |
|---|
| 188 | BINT_Handle hInterrupt, /* Interrupt handle */ |
|---|
| 189 | const BKPD_Settings *pDefSettings /* Default settings */ |
|---|
| 190 | ) |
|---|
| 191 | { |
|---|
| 192 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 193 | BKPD_Handle hDev; |
|---|
| 194 | uint32_t lval; |
|---|
| 195 | uint16_t sval; |
|---|
| 196 | uint32_t prescale; |
|---|
| 197 | |
|---|
| 198 | /* Sanity check on the handles we've been given. */ |
|---|
| 199 | BDBG_ASSERT( hChip ); |
|---|
| 200 | BDBG_ASSERT( hRegister ); |
|---|
| 201 | BDBG_ASSERT( hInterrupt ); |
|---|
| 202 | |
|---|
| 203 | /* Alloc memory from the system heap */ |
|---|
| 204 | hDev = (BKPD_Handle) BKNI_Malloc( sizeof( BKPD_P_Handle ) ); |
|---|
| 205 | if( hDev == NULL ) |
|---|
| 206 | { |
|---|
| 207 | *pKpd = NULL; |
|---|
| 208 | retCode = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY); |
|---|
| 209 | BDBG_ERR(("BKPD_Open: BKNI_malloc() failed\n")); |
|---|
| 210 | goto done; |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | hDev->magicId = DEV_MAGIC_ID; |
|---|
| 214 | hDev->hChip = hChip; |
|---|
| 215 | hDev->hRegister = hRegister; |
|---|
| 216 | hDev->hInterrupt = hInterrupt; |
|---|
| 217 | hDev->intMode = pDefSettings->intMode; |
|---|
| 218 | |
|---|
| 219 | BKPD_CHK_RETCODE( retCode, BKNI_CreateEvent( &(hDev->hEvent) ) ); |
|---|
| 220 | |
|---|
| 221 | prescale = pDefSettings->prescale; |
|---|
| 222 | BREG_Write32 (hDev->hRegister, BCHP_LDK_PRESCHI, (uint8_t)(prescale >> 8)); |
|---|
| 223 | BREG_Write32 (hDev->hRegister, BCHP_LDK_PRESCLO, (uint8_t)(prescale & 0xff)); |
|---|
| 224 | |
|---|
| 225 | BREG_Write32 (hDev->hRegister, BCHP_LDK_DEBOUNCE, pDefSettings->debounce); |
|---|
| 226 | |
|---|
| 227 | /* Set up default duty cycle assuming 100% brightness. */ |
|---|
| 228 | BREG_Write32 (hDev->hRegister, BCHP_LDK_DUTYOFF, 0); |
|---|
| 229 | BREG_Write32 (hDev->hRegister, BCHP_LDK_DUTYON, KPD_DEFAULT_DUTYCYCLE_ON+KPD_DEFAULT_DUTYCYCLE_OFF); |
|---|
| 230 | |
|---|
| 231 | /* Read data to clear any pending interrupt */ |
|---|
| 232 | BKPD_Read (hDev, &sval); |
|---|
| 233 | |
|---|
| 234 | if (hDev->intMode) |
|---|
| 235 | { |
|---|
| 236 | BKPD_CHK_RETCODE( retCode, BINT_CreateCallback( |
|---|
| 237 | &(hDev->hCallback), hDev->hInterrupt, BCHP_INT_ID_ldk_irqen, |
|---|
| 238 | BKPD_P_HandleInterrupt_Isr, (void *) hDev, 0x00 ) ); |
|---|
| 239 | BKPD_CHK_RETCODE( retCode, BINT_EnableCallback( hDev->hCallback ) ); |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | BKNI_EnterCriticalSection(); |
|---|
| 243 | /* Enable keypad interrupt in led/keypad controller */ |
|---|
| 244 | lval = BREG_Read32 (hDev->hRegister, BCHP_LDK_CONTROL); |
|---|
| 245 | lval |= BCHP_LDK_CONTROL_irqen_MASK; |
|---|
| 246 | BREG_Write32 (hDev->hRegister, BCHP_LDK_CONTROL, lval); |
|---|
| 247 | |
|---|
| 248 | /* Clear user callback */ |
|---|
| 249 | hDev->stCallbackInfo.cbFunc = NULL; |
|---|
| 250 | |
|---|
| 251 | BKNI_LeaveCriticalSection(); |
|---|
| 252 | |
|---|
| 253 | /* Set the VER bit. Scan keypad only once at end of ON interval. */ |
|---|
| 254 | lval = BREG_Read32 (hDev->hRegister, BCHP_LDK_CONTROL); |
|---|
| 255 | lval &= ~BCHP_LDK_CONTROL_swr_MASK; |
|---|
| 256 | lval |= BCHP_LDK_CONTROL_ver_MASK; |
|---|
| 257 | lval &= 0x0f; /* make sure to zero out the upper bits */ |
|---|
| 258 | BREG_Write32 (hDev->hRegister, BCHP_LDK_CONTROL, lval); |
|---|
| 259 | |
|---|
| 260 | *pKpd = hDev; |
|---|
| 261 | |
|---|
| 262 | done: |
|---|
| 263 | if ((retCode != BERR_SUCCESS) && hDev) |
|---|
| 264 | { |
|---|
| 265 | BKNI_Free( (void *) hDev ); |
|---|
| 266 | *pKpd = NULL; |
|---|
| 267 | } |
|---|
| 268 | return( retCode ); |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | BERR_Code BKPD_Close( |
|---|
| 272 | BKPD_Handle hDev /* Device handle */ |
|---|
| 273 | ) |
|---|
| 274 | { |
|---|
| 275 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 276 | uint32_t lval; |
|---|
| 277 | |
|---|
| 278 | BDBG_ASSERT( hDev ); |
|---|
| 279 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 280 | |
|---|
| 281 | if ( hDev->hCallback ) |
|---|
| 282 | { |
|---|
| 283 | BKPD_CHK_RETCODE( retCode, BINT_DisableCallback( hDev->hCallback ) ); |
|---|
| 284 | BKPD_CHK_RETCODE( retCode, BINT_DestroyCallback( hDev->hCallback ) ); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | BKNI_EnterCriticalSection(); |
|---|
| 288 | /* Enable keypad interrupt in led/keypad controller */ |
|---|
| 289 | lval = BREG_Read32 (hDev->hRegister, BCHP_LDK_CONTROL); |
|---|
| 290 | lval &= ~BCHP_LDK_CONTROL_irqen_MASK; |
|---|
| 291 | BREG_Write32 (hDev->hRegister, BCHP_LDK_CONTROL, lval); |
|---|
| 292 | BKNI_LeaveCriticalSection(); |
|---|
| 293 | |
|---|
| 294 | BKNI_DestroyEvent( hDev->hEvent ); |
|---|
| 295 | BKNI_Free( (void *) hDev ); |
|---|
| 296 | |
|---|
| 297 | done: |
|---|
| 298 | return( retCode ); |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | BERR_Code BKPD_GetDefaultSettings( |
|---|
| 302 | BKPD_Settings *pDefSettings, /* [output] Returns default setting */ |
|---|
| 303 | BCHP_Handle hChip /* Chip handle */ |
|---|
| 304 | ) |
|---|
| 305 | { |
|---|
| 306 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 307 | BSTD_UNUSED(hChip); |
|---|
| 308 | |
|---|
| 309 | *pDefSettings = defKpdSettings; |
|---|
| 310 | |
|---|
| 311 | return( retCode ); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | BERR_Code BKPD_GetEventHandle( |
|---|
| 315 | BKPD_Handle hDev, /* Device handle */ |
|---|
| 316 | BKNI_EventHandle *phEvent /* [output] Returns event handle */ |
|---|
| 317 | ) |
|---|
| 318 | { |
|---|
| 319 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 320 | |
|---|
| 321 | BDBG_ASSERT( hDev ); |
|---|
| 322 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 323 | |
|---|
| 324 | *phEvent = hDev->hEvent; |
|---|
| 325 | |
|---|
| 326 | return( retCode ); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | BERR_Code BKPD_IsDataReady ( |
|---|
| 330 | BKPD_Handle hKpd, /* Device handle */ |
|---|
| 331 | bool *ready /* flag indicating key is pressed */ |
|---|
| 332 | ) |
|---|
| 333 | { |
|---|
| 334 | uint32_t lval; |
|---|
| 335 | |
|---|
| 336 | lval = BREG_Read32 (hKpd->hRegister, BCHP_IRQ0_IRQSTAT); |
|---|
| 337 | #if (BCHP_CHIP==3563) || (BCHP_CHIP==3548) || (BCHP_CHIP==3556) || (BCHP_CHIP==7550) |
|---|
| 338 | *ready = (lval & BCHP_IRQ0_IRQSTAT_ldk_MASK) ? true : false; |
|---|
| 339 | #elif (BCHP_CHIP==7422) || (BCHP_CHIP==7425) || (BCHP_CHIP==7429) || (BCHP_CHIP==7344) || (BCHP_CHIP==7346) || (BCHP_CHIP==7231) || \ |
|---|
| 340 | (BCHP_CHIP==7358) || (BCHP_CHIP==7552) || (BCHP_CHIP==7435) |
|---|
| 341 | *ready = (lval & BCHP_IRQ0_AON_IRQSTAT_ldkirq_MASK) ? true : false; |
|---|
| 342 | #else |
|---|
| 343 | *ready = (lval & BCHP_IRQ0_IRQSTAT_ldkirq_MASK) ? true : false; |
|---|
| 344 | #endif |
|---|
| 345 | |
|---|
| 346 | return BERR_SUCCESS; |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | BERR_Code BKPD_Read ( |
|---|
| 350 | BKPD_Handle hKpd, /* Device handle */ |
|---|
| 351 | uint16_t *pData /* pointer to data read from keypad */ |
|---|
| 352 | ) |
|---|
| 353 | { |
|---|
| 354 | uint32_t hi, lo; |
|---|
| 355 | |
|---|
| 356 | hi = BREG_Read32 (hKpd->hRegister, BCHP_LDK_KEYROW32); |
|---|
| 357 | lo = BREG_Read32 (hKpd->hRegister, BCHP_LDK_KEYROW10); |
|---|
| 358 | |
|---|
| 359 | *pData = (((uint16_t)hi) << 8) | ((uint16_t)lo); |
|---|
| 360 | |
|---|
| 361 | return BERR_SUCCESS; |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | BERR_Code BKPD_InstallInterruptCallback ( |
|---|
| 365 | BKPD_Handle hKpd, /* Device handle */ |
|---|
| 366 | BKPD_CallbackFunc callback, /* callback function */ |
|---|
| 367 | void *pParm1, /* application specified parameter */ |
|---|
| 368 | int parm2 /* application specified parameter */ |
|---|
| 369 | ) |
|---|
| 370 | { |
|---|
| 371 | BDBG_ASSERT( hKpd ); |
|---|
| 372 | |
|---|
| 373 | /* Put the interrupt callback into our array */ |
|---|
| 374 | hKpd->stCallbackInfo.cbFunc = callback; |
|---|
| 375 | hKpd->stCallbackInfo.pParm1 = pParm1 ; |
|---|
| 376 | hKpd->stCallbackInfo.parm2 = parm2 ; |
|---|
| 377 | |
|---|
| 378 | return BERR_SUCCESS; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | BERR_Code BKPD_UnInstallInterruptCallback ( |
|---|
| 382 | BKPD_Handle hKpd /* Device handle */ |
|---|
| 383 | ) |
|---|
| 384 | { |
|---|
| 385 | BDBG_ASSERT( hKpd ); |
|---|
| 386 | |
|---|
| 387 | /* Put the interrupt callback into our array */ |
|---|
| 388 | hKpd->stCallbackInfo.cbFunc = NULL; |
|---|
| 389 | hKpd->stCallbackInfo.pParm1 = NULL ; |
|---|
| 390 | hKpd->stCallbackInfo.parm2 = 0 ; |
|---|
| 391 | |
|---|
| 392 | return BERR_SUCCESS; |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | /******************************************************************************* |
|---|
| 396 | * |
|---|
| 397 | * Private Module Functions |
|---|
| 398 | * |
|---|
| 399 | *******************************************************************************/ |
|---|
| 400 | static void BKPD_P_HandleInterrupt_Isr |
|---|
| 401 | ( |
|---|
| 402 | void *pParam1, /* Device channel handle */ |
|---|
| 403 | int parm2 /* not used */ |
|---|
| 404 | ) |
|---|
| 405 | { |
|---|
| 406 | BKPD_Handle hDev; |
|---|
| 407 | uint16_t data; |
|---|
| 408 | |
|---|
| 409 | BSTD_UNUSED(parm2); |
|---|
| 410 | hDev = (BKPD_Handle) pParam1; |
|---|
| 411 | BDBG_ASSERT( hDev ); |
|---|
| 412 | |
|---|
| 413 | /* |
|---|
| 414 | * Check to see if user has installed a callback |
|---|
| 415 | */ |
|---|
| 416 | if(hDev->stCallbackInfo.cbFunc) |
|---|
| 417 | { |
|---|
| 418 | hDev->stCallbackInfo.cbFunc ( hDev->stCallbackInfo.pParm1, |
|---|
| 419 | hDev->stCallbackInfo.parm2, |
|---|
| 420 | NULL) ; |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | /* |
|---|
| 424 | * Clear keypad interrupt by reading the key registers |
|---|
| 425 | */ |
|---|
| 426 | BKPD_Read (hDev, &data); |
|---|
| 427 | |
|---|
| 428 | BKNI_SetEvent( hDev->hEvent ); |
|---|
| 429 | |
|---|
| 430 | return; |
|---|
| 431 | } |
|---|
| 432 | |
|---|