rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * Copyright Statement: |
| 3 | * -------------------- |
| 4 | * This software is protected by Copyright and the information contained |
| 5 | * herein is confidential. The software may not be copied and the information |
| 6 | * contained herein may not be used or disclosed except with the written |
| 7 | * permission of MediaTek Inc. (C) 2005 |
| 8 | * |
| 9 | * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 10 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 11 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 12 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 13 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 14 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 15 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 16 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 17 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 18 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 19 | * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 20 | * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 21 | * |
| 22 | * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 23 | * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 24 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 25 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 26 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 27 | * |
| 28 | * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 29 | * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 30 | * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 31 | * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 32 | * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 33 | * |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | #include "kal_general_types.h" |
| 37 | #include "kal_public_api.h" |
| 38 | #include "hisr_config.h" |
| 39 | #include "reg_base.h" |
| 40 | #include "intrCtrl.h" |
| 41 | #include "eint.h" |
| 42 | #include "dcl.h" |
| 43 | |
| 44 | #include "Eint_internal.h" |
| 45 | #include "kal_internal_api.h" |
| 46 | #include "eint_sw.h" |
| 47 | #include "eint_hw.h" |
| 48 | #include "cpu.h" |
| 49 | #include "drvpdn.h" |
| 50 | #include "sync_data.h" |
| 51 | |
| 52 | #include "kal_public_api.h" |
| 53 | |
| 54 | kal_spinlockid eint_set_lock = 0; |
| 55 | |
| 56 | |
| 57 | eint_func EINT_FUNC; |
| 58 | //dedicated_eint_func DEINT_FUNC; |
| 59 | #if defined(__MD93__) |
| 60 | static EINT_SW_DEBOUNCE_STRUCT eint_sw_debounce[EINT_MAX_CHANNEL]; |
| 61 | //static EINT_SW_DEBOUNCE_STRUCT deint_sw_debounce[DEDICATED_EINT_TOTAL_CHANNEL]; |
| 62 | #ifndef ATEST_DRV_ENABLE |
| 63 | static kal_uint8 *eint_sw_debounce_time_delay = NULL; |
| 64 | #else |
| 65 | kal_uint8 *eint_sw_debounce_time_delay = NULL; |
| 66 | #endif |
| 67 | //static kal_uint8 deint_sw_debounce_time_delay[DEDICATED_EINT_TOTAL_CHANNEL] = {0}; |
| 68 | #elif defined(__MD95__) |
| 69 | #elif defined(__MD97__) |
| 70 | #elif defined(__MD97P__) |
| 71 | // |
| 72 | #else |
| 73 | #error "no chip match" |
| 74 | #endif |
| 75 | /* Variables to sources that triggers EINT interrupt */ |
| 76 | kal_uint8 eint_trigger_src_log[EINT_TRIGGER_SRC_LOG_MAX] = {0x0}; |
| 77 | kal_uint8 eint_trigger_src_ptr = 0; |
| 78 | |
| 79 | //static kal_hisrid eint_hisrid; |
| 80 | //static kal_hisrid deint_hisrid; |
| 81 | |
| 82 | extern kal_uint32 eint_is_dedicated; |
| 83 | extern kal_uint32 eint_is_dedicated_map[EINT_MAX_CHANNEL]; |
| 84 | |
| 85 | //extern kal_uint32 LockIRQ(void); |
| 86 | //extern void RestoreIRQ(kal_uint32 irq); |
| 87 | |
| 88 | extern kal_uint32 SaveAndSetIRQMask(void); |
| 89 | extern void RESTOREIRQMASK(kal_uint32 irq); |
| 90 | extern void BTMT_EINT_HANDLER(kal_uint32* status); |
| 91 | //extern kal_uint32 DisableIRQ(void); |
| 92 | //kal_uint32 DEINT_Get_IRQ_ID(kal_uint8 deintno); |
| 93 | //void DEINT_Registration(kal_uint8 deintno,void (reg_hisr)(void)); |
| 94 | extern kal_spinlockid md1_eint_lock; |
| 95 | |
| 96 | void DEINT0_LISR(kal_uint32 irq_id); |
| 97 | void DEINT1_LISR(kal_uint32 irq_id); |
| 98 | void DEINT2_LISR(kal_uint32 irq_id); |
| 99 | void DEINT3_LISR(kal_uint32 irq_id); |
| 100 | |
| 101 | //eint creat spinlock |
| 102 | void eint_create_spinlock(void){ |
| 103 | if (eint_set_lock == 0){ |
| 104 | eint_set_lock = kal_create_spinlock("mdeint_"); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /************************************************************************* |
| 109 | * FUNCTION |
| 110 | * EINT_Mask |
| 111 | * |
| 112 | * DESCRIPTION |
| 113 | * This function implements mask of dedicated external interrupt source |
| 114 | * |
| 115 | * CALLS |
| 116 | * |
| 117 | * PARAMETERS |
| 118 | * eintno - external interrupt vector number |
| 119 | * |
| 120 | * RETURNS |
| 121 | * No return |
| 122 | * |
| 123 | * GLOBALS AFFECTED |
| 124 | * |
| 125 | *************************************************************************/ |
| 126 | void EINT_Mask(kal_uint8 eintno) |
| 127 | { |
| 128 | if (eint_is_dedicated & (1 << eintno)) |
| 129 | { |
| 130 | eint_set_l1_eint_enable(eint_is_dedicated_map[eintno], EINT_DISABLE); |
| 131 | switch(eint_is_dedicated_map[eintno]) |
| 132 | { |
| 133 | case DEDICATED_EINT0: |
| 134 | IRQMask(DEDICATED_EINT_IRQ0); |
| 135 | break; |
| 136 | case DEDICATED_EINT1: |
| 137 | IRQMask(DEDICATED_EINT_IRQ1); |
| 138 | break; |
| 139 | case DEDICATED_EINT2: |
| 140 | IRQMask(DEDICATED_EINT_IRQ2); |
| 141 | break; |
| 142 | case DEDICATED_EINT3: |
| 143 | IRQMask(DEDICATED_EINT_IRQ3); |
| 144 | break; |
| 145 | default: |
| 146 | return; |
| 147 | } |
| 148 | } |
| 149 | else |
| 150 | { |
| 151 | eint_set_irqen(eintno,EINT_DISABLE); |
| 152 | } |
| 153 | } |
| 154 | /* |
| 155 | static void eint_udelay(kal_uint32 usdelay) |
| 156 | { |
| 157 | kal_uint32 clock_count,event_count1,event_count2,delay_count; |
| 158 | |
| 159 | event_count1 = event_count2 = 0; |
| 160 | |
| 161 | clock_count = usdelay*(CPU_FREQUENCY_MHZ); |
| 162 | cpu_event_counter_get_cycle(event_count1); |
| 163 | |
| 164 | |
| 165 | while(1) |
| 166 | { |
| 167 | cpu_event_counter_get_cycle(event_count2); |
| 168 | delay_count = cpu_event_get_duration(event_count1,event_count2); |
| 169 | if(delay_count >= clock_count) |
| 170 | { |
| 171 | break; |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | */ |
| 176 | kal_uint32 EINT_Get_Mask_Bits(void) |
| 177 | { |
| 178 | kal_uint32 mask_bit_value; |
| 179 | kal_uint32 index, deint_en; |
| 180 | |
| 181 | mask_bit_value = eint_get_irqen(); |
| 182 | |
| 183 | //add deint mask |
| 184 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 185 | { |
| 186 | if (eint_is_dedicated & (1 << index)) |
| 187 | { |
| 188 | deint_en = eint_get_l1_irqen(eint_is_dedicated_map[index]); |
| 189 | mask_bit_value |= (deint_en << index); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | return ~mask_bit_value; |
| 194 | } |
| 195 | |
| 196 | void EINT_Set_Mask_all(kal_uint32 mask_bits) |
| 197 | { |
| 198 | kal_uint32 index; |
| 199 | |
| 200 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 201 | { |
| 202 | if ((eint_is_dedicated & (1 << index)) && (mask_bits & (1<< index))) |
| 203 | { |
| 204 | eint_set_l1_eint_enable(eint_is_dedicated_map[index], EINT_DISABLE); |
| 205 | mask_bits &= (~(1<< index)); |
| 206 | } |
| 207 | } |
| 208 | eint_set_mask_all(mask_bits); |
| 209 | } |
| 210 | |
| 211 | void EINT_Set_UnMask_all(kal_uint32 unmask_bits) |
| 212 | { |
| 213 | kal_uint32 index; |
| 214 | |
| 215 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 216 | { |
| 217 | if ((eint_is_dedicated & (1 << index)) && (unmask_bits & (1<< index))) |
| 218 | { |
| 219 | eint_set_l1_eint_enable(eint_is_dedicated_map[index], EINT_ENABLE); |
| 220 | unmask_bits &= (~(1<< index)); |
| 221 | } |
| 222 | } |
| 223 | eint_set_unmask_all(unmask_bits); |
| 224 | } |
| 225 | |
| 226 | /************************************************************************* |
| 227 | * FUNCTION |
| 228 | * EINT_UnMask |
| 229 | * |
| 230 | * DESCRIPTION |
| 231 | * This function implements Unmask of dedicated external interrupt source |
| 232 | * |
| 233 | * CALLS |
| 234 | * |
| 235 | * PARAMETERS |
| 236 | * eintno - external interrupt vector number |
| 237 | * |
| 238 | * RETURNS |
| 239 | * No return |
| 240 | * |
| 241 | * GLOBALS AFFECTED |
| 242 | * |
| 243 | *************************************************************************/ |
| 244 | void EINT_UnMask(kal_uint8 eintno) |
| 245 | { |
| 246 | if (eint_is_dedicated & (1 << eintno)) |
| 247 | { |
| 248 | switch(eint_is_dedicated_map[eintno]) |
| 249 | { |
| 250 | case DEDICATED_EINT0: |
| 251 | { |
| 252 | eint_set_l1_eint_enable(DEDICATED_EINT0, EINT_ENABLE); |
| 253 | IRQUnmask(DEDICATED_EINT_IRQ0); |
| 254 | break; |
| 255 | } |
| 256 | case DEDICATED_EINT1: |
| 257 | { |
| 258 | eint_set_l1_eint_enable(DEDICATED_EINT1, EINT_ENABLE); |
| 259 | IRQUnmask(DEDICATED_EINT_IRQ1); |
| 260 | break; |
| 261 | } |
| 262 | case DEDICATED_EINT2: |
| 263 | { |
| 264 | eint_set_l1_eint_enable(DEDICATED_EINT2, EINT_ENABLE); |
| 265 | IRQUnmask(DEDICATED_EINT_IRQ2); |
| 266 | break; |
| 267 | } |
| 268 | case DEDICATED_EINT3: |
| 269 | { |
| 270 | eint_set_l1_eint_enable(DEDICATED_EINT3, EINT_ENABLE); |
| 271 | IRQUnmask(DEDICATED_EINT_IRQ3); |
| 272 | break; |
| 273 | } |
| 274 | default: |
| 275 | return; |
| 276 | } |
| 277 | |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | eint_set_irqen(eintno,EINT_ENABLE); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /************************************************************************* |
| 286 | * FUNCTION |
| 287 | * DEINT_Mask |
| 288 | * |
| 289 | * DESCRIPTION |
| 290 | * This function implements mask of dedicated external interrupt source |
| 291 | * |
| 292 | * CALLS |
| 293 | * |
| 294 | * PARAMETERS |
| 295 | * deintno - external interrupt vector number |
| 296 | * |
| 297 | * RETURNS |
| 298 | * No return |
| 299 | * |
| 300 | * GLOBALS AFFECTED |
| 301 | * |
| 302 | *************************************************************************/ |
| 303 | #if 0 |
| 304 | /* under construction !*/ |
| 305 | /* under construction !*/ |
| 306 | /* under construction !*/ |
| 307 | /* under construction !*/ |
| 308 | /* under construction !*/ |
| 309 | /* under construction !*/ |
| 310 | /* under construction !*/ |
| 311 | /* under construction !*/ |
| 312 | /* under construction !*/ |
| 313 | /* under construction !*/ |
| 314 | /* under construction !*/ |
| 315 | /* under construction !*/ |
| 316 | /* under construction !*/ |
| 317 | /* under construction !*/ |
| 318 | /* under construction !*/ |
| 319 | /* under construction !*/ |
| 320 | /* under construction !*/ |
| 321 | /* under construction !*/ |
| 322 | /* under construction !*/ |
| 323 | /* under construction !*/ |
| 324 | /* under construction !*/ |
| 325 | /* under construction !*/ |
| 326 | /* under construction !*/ |
| 327 | /* under construction !*/ |
| 328 | /* under construction !*/ |
| 329 | /* under construction !*/ |
| 330 | /* under construction !*/ |
| 331 | /* under construction !*/ |
| 332 | /* under construction !*/ |
| 333 | /* under construction !*/ |
| 334 | /* under construction !*/ |
| 335 | /* under construction !*/ |
| 336 | /* under construction !*/ |
| 337 | /* under construction !*/ |
| 338 | /* under construction !*/ |
| 339 | /* under construction !*/ |
| 340 | /* under construction !*/ |
| 341 | /* under construction !*/ |
| 342 | /* under construction !*/ |
| 343 | /* under construction !*/ |
| 344 | /* under construction !*/ |
| 345 | /* under construction !*/ |
| 346 | /* under construction !*/ |
| 347 | /* under construction !*/ |
| 348 | /* under construction !*/ |
| 349 | /* under construction !*/ |
| 350 | /* under construction !*/ |
| 351 | /* under construction !*/ |
| 352 | /* under construction !*/ |
| 353 | /* under construction !*/ |
| 354 | /* under construction !*/ |
| 355 | /* under construction !*/ |
| 356 | /* under construction !*/ |
| 357 | /* under construction !*/ |
| 358 | /* under construction !*/ |
| 359 | /* under construction !*/ |
| 360 | /* under construction !*/ |
| 361 | /* under construction !*/ |
| 362 | /* under construction !*/ |
| 363 | /* under construction !*/ |
| 364 | /* under construction !*/ |
| 365 | /* under construction !*/ |
| 366 | /* under construction !*/ |
| 367 | /* under construction !*/ |
| 368 | /* under construction !*/ |
| 369 | /* under construction !*/ |
| 370 | /* under construction !*/ |
| 371 | /* under construction !*/ |
| 372 | /* under construction !*/ |
| 373 | /* under construction !*/ |
| 374 | #endif |
| 375 | |
| 376 | /************************************************************************* |
| 377 | * FUNCTION |
| 378 | * EINT_HISR_Entry |
| 379 | * |
| 380 | * DESCRIPTION |
| 381 | * This function implements main external interrupt HISR registered in |
| 382 | * global ISR jump table, eint_hisr_func. |
| 383 | * |
| 384 | * CALLS |
| 385 | * |
| 386 | * PARAMETERS |
| 387 | * |
| 388 | * RETURNS |
| 389 | * No return |
| 390 | * |
| 391 | * GLOBALS AFFECTED |
| 392 | * |
| 393 | *************************************************************************/ |
| 394 | void EINT_HISR_Entry(void) |
| 395 | { |
| 396 | kal_uint8 index; |
| 397 | |
| 398 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 399 | { |
| 400 | if ( !(eint_is_dedicated & (1 << index)) && (EINT_FUNC.eint_active[index] == KAL_TRUE) |
| 401 | && (EINT_FUNC.eint_func[index]) ) |
| 402 | { |
| 403 | |
| 404 | EINT_FUNC.eint_active[index] = KAL_FALSE; |
| 405 | |
| 406 | eint_trigger_src_log[eint_trigger_src_ptr] = index; |
| 407 | eint_trigger_src_ptr = (eint_trigger_src_ptr + 1) % EINT_TRIGGER_SRC_LOG_MAX; |
| 408 | |
| 409 | EINT_FUNC.eint_func[index](); |
| 410 | |
| 411 | if (EINT_FUNC.eint_auto_umask[index] == KAL_TRUE) |
| 412 | { |
| 413 | |
| 414 | EINT_UnMask(index); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | /************************************************************************* |
| 421 | * FUNCTION |
| 422 | * DEINT_HISR_Entry |
| 423 | * |
| 424 | * DESCRIPTION |
| 425 | * This function implements main dedicated external interrupt HISR registered in |
| 426 | * global ISR jump table, eint_hisr_func. |
| 427 | * |
| 428 | * CALLS |
| 429 | * |
| 430 | * PARAMETERS |
| 431 | * |
| 432 | * RETURNS |
| 433 | * No return |
| 434 | * |
| 435 | * GLOBALS AFFECTED |
| 436 | * |
| 437 | *************************************************************************/ |
| 438 | void DEINT_HISR_Entry(void) |
| 439 | { |
| 440 | kal_uint8 index; |
| 441 | |
| 442 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 443 | { |
| 444 | if (eint_is_dedicated & (1 << index)) |
| 445 | { |
| 446 | if ( (EINT_FUNC.eint_active[index] == KAL_TRUE) && (EINT_FUNC.eint_func[index]) ) |
| 447 | { |
| 448 | |
| 449 | EINT_FUNC.eint_active[index] = KAL_FALSE; |
| 450 | |
| 451 | EINT_FUNC.eint_func[index](); |
| 452 | |
| 453 | if (EINT_FUNC.eint_auto_umask[index] == KAL_TRUE) |
| 454 | { |
| 455 | EINT_UnMask(index); |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | |
| 463 | /************************************************************************* |
| 464 | * FUNCTION |
| 465 | * EINT_Internal_LISR_Handler |
| 466 | * |
| 467 | * DESCRIPTION |
| 468 | * Internal function of External Interrupt Service Routine |
| 469 | * |
| 470 | * CALLS |
| 471 | * |
| 472 | * PARAMETERS |
| 473 | * The value of EINT_STA |
| 474 | * |
| 475 | * RETURNS |
| 476 | * If the original LISR flow should be bypassed |
| 477 | * |
| 478 | *************************************************************************/ |
| 479 | kal_bool EINT_Internal_LISR_Handler(kal_uint32* status) |
| 480 | { |
| 481 | kal_bool retval = KAL_FALSE; |
| 482 | |
| 483 | #if defined(__AST_EINT__) && defined(__AST_TL1_TDD__) |
| 484 | AST_EINT_HANDLER(status); |
| 485 | #endif |
| 486 | |
| 487 | #if defined(IC_BURNIN_TEST) || defined(IC_MODULE_TEST) |
| 488 | BTMT_EINT_HANDLER(status); |
| 489 | #endif |
| 490 | |
| 491 | return retval; |
| 492 | } |
| 493 | extern kal_uint32 eint_src_map[EINT_MAX_CHANNEL]; |
| 494 | /************************************************************************* |
| 495 | * FUNCTION |
| 496 | * Register_EINT |
| 497 | * |
| 498 | * DESCRIPTION |
| 499 | * This function implements registration of external interrupts |
| 500 | * |
| 501 | * CALLS |
| 502 | * |
| 503 | * PARAMETERS |
| 504 | * eintno - External interrupt vector number |
| 505 | * Dbounce_En - Debounce control enable |
| 506 | * ACT_Polarity - Interrupt polarity |
| 507 | * reg_hisr - Registered hisr |
| 508 | * auto_umask - A flag instruct the systerm to do unmask after |
| 509 | * invoking the registered HISR |
| 510 | * |
| 511 | * RETURNS |
| 512 | * No return |
| 513 | * |
| 514 | * GLOBALS AFFECTED |
| 515 | * |
| 516 | *************************************************************************/ |
| 517 | void EINT_Registration(kal_uint8 eintno, kal_bool Dbounce_En, kal_bool ACT_Polarity, void (reg_hisr)(void), kal_bool auto_umask) |
| 518 | { |
| 519 | // PDN_CLR(PDN_GPIO); |
| 520 | //kal_uint32 savedMask; |
| 521 | |
| 522 | /* If EINT Number is out of range, get return address and send it to exception handler */ |
| 523 | if(eintno >= EINT_TOTAL_CHANNEL) |
| 524 | { |
| 525 | kal_uint32 retaddr; |
| 526 | |
| 527 | GET_RETURN_ADDRESS(retaddr); |
| 528 | kal_fatal_error_handler(KAL_ERROR_DRV_EINT_INVALID_INDEX, retaddr); |
| 529 | } |
| 530 | |
| 531 | /*disable eint interrupt*/ |
| 532 | eint_set_irqen(eintno, EINT_DISABLE); |
| 533 | eint_set_debounce_enable(eintno, EINT_DISABLE); |
| 534 | |
| 535 | /*register LISR*/ |
| 536 | /*dispatch for dedicated eint*/ |
| 537 | if (eint_is_dedicated & (1<<eintno)) |
| 538 | { |
| 539 | switch(eint_is_dedicated_map[eintno]) |
| 540 | { |
| 541 | case DEDICATED_EINT0: |
| 542 | { |
| 543 | eint_set_l1_eint_enable(DEDICATED_EINT0, EINT_DISABLE); |
| 544 | //IRQ_Register_LISR(DEDICATED_EINT_IRQ0, DEINT0_LISR, "DEINT0 handler"); |
| 545 | } |
| 546 | break; |
| 547 | case DEDICATED_EINT1: |
| 548 | { |
| 549 | eint_set_l1_eint_enable(DEDICATED_EINT1, EINT_DISABLE); |
| 550 | //IRQ_Register_LISR(DEDICATED_EINT_IRQ1, DEINT1_LISR, "DEINT1 handler"); |
| 551 | } |
| 552 | break; |
| 553 | case DEDICATED_EINT2: |
| 554 | { |
| 555 | eint_set_l1_eint_enable(DEDICATED_EINT2, EINT_DISABLE); |
| 556 | //IRQ_Register_LISR(DEDICATED_EINT_IRQ2, DEINT2_LISR, "DEINT2 handler"); |
| 557 | } |
| 558 | break; |
| 559 | case DEDICATED_EINT3: |
| 560 | { |
| 561 | eint_set_l1_eint_enable(DEDICATED_EINT3, EINT_DISABLE); |
| 562 | //IRQ_Register_LISR(DEDICATED_EINT_IRQ3, DEINT3_LISR, "DEINT3 handler"); |
| 563 | } |
| 564 | break; |
| 565 | default: |
| 566 | break; |
| 567 | } |
| 568 | } |
| 569 | else |
| 570 | { |
| 571 | //IRQ_Register_LISR(IRQ_EIT_CODE, EINT_LISR, "EINT handler"); |
| 572 | } |
| 573 | |
| 574 | /* Save and set MCU's I,F bits to disable interrupts */ |
| 575 | // savedMask = LockIRQ(); |
| 576 | |
| 577 | /* Set external interrupt polarity */ |
| 578 | eint_set_pol(eintno,ACT_Polarity); |
| 579 | /*only for smartphone chip,follow moly*/ |
| 580 | gpio_set_eint_src(eintno,eint_src_map[eintno]); |
| 581 | |
| 582 | if (Dbounce_En) |
| 583 | { |
| 584 | //eint_set_debounce_duration(eintno,EINT_DB_DUR_DEFAULT); |
| 585 | eint_set_debounce_enable(eintno,EINT_ENABLE); |
| 586 | } |
| 587 | else |
| 588 | { |
| 589 | /*disable debounce */ |
| 590 | eint_set_debounce_enable(eintno,EINT_DISABLE); |
| 591 | } |
| 592 | |
| 593 | /* Save and set MCU's I,F bits to disable interrupts */ |
| 594 | //savedMask = SaveAndSetIRQMask(); |
| 595 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 596 | /* Register external interrupt's HISR */ |
| 597 | EINT_FUNC.eint_func[eintno] = reg_hisr; |
| 598 | EINT_FUNC.eint_active[eintno] = KAL_FALSE; |
| 599 | EINT_FUNC.eint_auto_umask[eintno] = auto_umask; |
| 600 | |
| 601 | if (eint_is_dedicated & (1<<eintno)) |
| 602 | { |
| 603 | /* register HISR */ |
| 604 | EINT_L2_ACK(eintno); |
| 605 | EINT_UnMask(eintno); |
| 606 | kal_give_spinlock(md1_eint_lock); |
| 607 | //deint_hisrid = kal_init_hisr(DEINT_HISR); |
| 608 | } |
| 609 | else |
| 610 | { |
| 611 | /* register HISR */ |
| 612 | EINT_L2_ACK(eintno); |
| 613 | EINT_UnMask(eintno); |
| 614 | IRQSensitivity( IRQ_EIT_CODE, LEVEL_SENSITIVE ); |
| 615 | /* Enable external interrupt */ |
| 616 | IRQUnmask( IRQ_EIT_CODE ); |
| 617 | //RestoreIRQMask(savedMask); |
| 618 | kal_give_spinlock(md1_eint_lock); |
| 619 | //eint_hisrid = kal_init_hisr(EINT_HISR); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | /************************************************************************* |
| 624 | * FUNCTION |
| 625 | * EXTRA_EINT_Registration |
| 626 | * |
| 627 | * DESCRIPTION |
| 628 | * This function implements registration of external interrupts |
| 629 | * |
| 630 | * CALLS |
| 631 | * |
| 632 | * PARAMETERS |
| 633 | * eintno - External interrupt vector number |
| 634 | * ACT_Polarity - Interrupt polarity |
| 635 | * reg_hisr - Registered hisr |
| 636 | * auto_umask - A flag instruct the systerm to do unmask after |
| 637 | * invoking the registered HISR |
| 638 | * |
| 639 | * RETURNS |
| 640 | * No return |
| 641 | * |
| 642 | * GLOBALS AFFECTED |
| 643 | * |
| 644 | *************************************************************************/ |
| 645 | void EXTRA_EINT_Registration(kal_uint8 eintno, kal_bool ACT_Polarity, void (reg_hisr)(void), \ |
| 646 | kal_bool auto_umask) |
| 647 | { |
| 648 | ASSERT((eintno < EINT_TOTAL_CHANNEL) && EINT_CheckHWDebounce(eintno) ); |
| 649 | |
| 650 | EINT_Registration(eintno, KAL_FALSE, ACT_Polarity, reg_hisr, auto_umask); |
| 651 | } |
| 652 | |
| 653 | /************************************************************************* |
| 654 | * FUNCTION |
| 655 | * EINT_Query_HW_Debounce |
| 656 | * |
| 657 | * DESCRIPTION |
| 658 | * This function dedicates to query the hardware debounce status |
| 659 | * interrupts. |
| 660 | * |
| 661 | * CALLS |
| 662 | * |
| 663 | * PARAMETERS |
| 664 | * |
| 665 | * RETURNS |
| 666 | * The hardware debounce disabled indicator bitmask |
| 667 | * |
| 668 | * GLOBALS AFFECTED |
| 669 | * |
| 670 | *************************************************************************/ |
| 671 | kal_uint32 EINT_Query_HW_Debounce(void) |
| 672 | { |
| 673 | kal_uint8 index; |
| 674 | kal_uint32 status = 0x0; |
| 675 | |
| 676 | for (index = 0; index < EINT_TOTAL_CHANNEL; index++) |
| 677 | { |
| 678 | if ( (EINT_FUNC.eint_func[index]) && |
| 679 | ((EINT_CheckNotHWDebounce(index)) || !eint_get_debounce_enable(index)) ) |
| 680 | { |
| 681 | status |= (0x1 << index);; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | return status; |
| 686 | } |
| 687 | |
| 688 | /************************************************************************* |
| 689 | * FUNCTION |
| 690 | * EINT_Set_HW_Debounce |
| 691 | * |
| 692 | * DESCRIPTION |
| 693 | * This function dedicates to set the hardware debounce time of external |
| 694 | * interrupts. |
| 695 | * |
| 696 | * CALLS |
| 697 | * |
| 698 | * PARAMETERS |
| 699 | * eintno - External interrupt vector number |
| 700 | * ms - hardware debounce time (in milli second) |
| 701 | * |
| 702 | * RETURNS |
| 703 | * No return |
| 704 | * |
| 705 | * GLOBALS AFFECTED |
| 706 | * |
| 707 | *************************************************************************/ |
| 708 | void EINT_Set_HW_Debounce(kal_uint8 eintno, kal_uint32 ms) |
| 709 | { |
| 710 | kal_uint32 cnt; |
| 711 | kal_uint32 debounce_en; |
| 712 | |
| 713 | debounce_en = eint_get_debounce_enable(eintno); |
| 714 | eint_set_debounce_enable(eintno,EINT_DISABLE); |
| 715 | |
| 716 | if(ms == 0) |
| 717 | { |
| 718 | /* set to one 32KHz clock cycle */ |
| 719 | cnt = 1; |
| 720 | } |
| 721 | else if(ms <= EINT_HW_DB_TIME_MAX) |
| 722 | { |
| 723 | /* calculate cnt value based on 32KHz clock cycles */ |
| 724 | #ifdef __FPGA__ |
| 725 | cnt = (ms*1000)/31; |
| 726 | #else |
| 727 | cnt = ms << 5; |
| 728 | #endif |
| 729 | } |
| 730 | else |
| 731 | { |
| 732 | /* set to maximum count */ |
| 733 | cnt = EINT_DB_DUR_MAX; |
| 734 | } |
| 735 | |
| 736 | eint_set_debounce_duration(eintno,cnt); |
| 737 | eint_set_debounce_enable(eintno, debounce_en); |
| 738 | EINT_L2_ACK(eintno); |
| 739 | } |
| 740 | |
| 741 | /************************************************************************* |
| 742 | * FUNCTION |
| 743 | * EINT_Set_HW_Debounce_32KCycle |
| 744 | * |
| 745 | * DESCRIPTION |
| 746 | * This function dedicates to set the hardware debounce time of external |
| 747 | * interrupts. |
| 748 | * |
| 749 | * CALLS |
| 750 | * |
| 751 | * PARAMETERS |
| 752 | * eintno - External interrupt vector number |
| 753 | * count_of_32kcycle - hardware debounce time (unit is 32k cycle) |
| 754 | * |
| 755 | * RETURNS |
| 756 | * No return |
| 757 | * |
| 758 | * GLOBALS AFFECTED |
| 759 | * |
| 760 | *************************************************************************/ |
| 761 | |
| 762 | void EINT_Set_HW_Debounce_32KCycle(kal_uint8 eintno, kal_uint32 count_of_32kcycle) |
| 763 | { |
| 764 | kal_uint32 debounce_en; |
| 765 | debounce_en = eint_get_debounce_enable(eintno); |
| 766 | eint_set_debounce_enable(eintno,EINT_DISABLE); |
| 767 | |
| 768 | eint_set_debounce_duration(eintno,count_of_32kcycle); |
| 769 | |
| 770 | eint_set_debounce_enable(eintno, debounce_en); |
| 771 | EINT_L2_ACK(eintno); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | /************************************************************************* |
| 776 | * @brief set the debounce enable parameter of the eint |
| 777 | * @param eintno : the eint index to be set |
| 778 | * @param debounce_en : the debounce enable value to set, it should be 0~1 |
| 779 | * 0: enable debounce function |
| 780 | * 1: disable debounce function |
| 781 | * @return No return |
| 782 | *************************************************************************/ |
| 783 | void EINT_Set_HW_Debounce_Enable(kal_uint8 eintno, kal_uint32 debounce_en) |
| 784 | { |
| 785 | eint_set_debounce_enable(eintno,debounce_en); |
| 786 | // eint_udelay(60); |
| 787 | } |
| 788 | |
| 789 | /************************************************************************* |
| 790 | * FUNCTION |
| 791 | * EINT_Set_Polarity |
| 792 | * |
| 793 | * DESCRIPTION |
| 794 | * This function sets the polarity of external interrupts |
| 795 | * |
| 796 | * CALLS |
| 797 | * |
| 798 | * PARAMETERS |
| 799 | * eintno - External interrupt vector number |
| 800 | * ACT_Polarity - Interrupt polarity |
| 801 | * |
| 802 | * RETURNS |
| 803 | * No return |
| 804 | * |
| 805 | * GLOBALS AFFECTED |
| 806 | * |
| 807 | *************************************************************************/ |
| 808 | void EINT_Set_Polarity(kal_uint8 eintno, kal_bool ACT_Polarity) |
| 809 | { |
| 810 | // kal_uint32 savedMask; |
| 811 | kal_uint32 debounce_en; |
| 812 | |
| 813 | /*disable EINT interrupt*/ |
| 814 | //EINT_Mask(eintno); |
| 815 | kal_take_spinlock(eint_set_lock, KAL_INFINITE_WAIT); |
| 816 | |
| 817 | /* Set external interrupt polarity */ |
| 818 | debounce_en = eint_get_debounce_enable(eintno); |
| 819 | eint_set_debounce_enable(eintno, EINT_DISABLE); |
| 820 | |
| 821 | // savedMask = SaveAndSetIRQMask(); |
| 822 | eint_set_pol(eintno,ACT_Polarity); |
| 823 | |
| 824 | eint_set_debounce_enable(eintno, debounce_en); |
| 825 | |
| 826 | EINT_L2_ACK(eintno); |
| 827 | |
| 828 | kal_give_spinlock(eint_set_lock); |
| 829 | /*enable EINT interrupt*/ |
| 830 | //EINT_UnMask(eintno); |
| 831 | } |
| 832 | |
| 833 | |
| 834 | /************************************************************************* |
| 835 | * FUNCTION |
| 836 | * EINT_Set_Sensitivity |
| 837 | * |
| 838 | * DESCRIPTION |
| 839 | * This function dedicates to set the sensitivity of external |
| 840 | * interrupts. |
| 841 | * |
| 842 | * CALLS |
| 843 | * |
| 844 | * PARAMETERS |
| 845 | * eintno - External interrupt vector number |
| 846 | * sens - EDGE_SENSITIVE or LEVEL_SENSITIVE |
| 847 | * |
| 848 | * RETURNS |
| 849 | * 0 for success; 1 for failure |
| 850 | * |
| 851 | * GLOBALS AFFECTED |
| 852 | * |
| 853 | *************************************************************************/ |
| 854 | kal_uint32 EINT_Set_Sensitivity(kal_uint8 eintno, kal_bool sens) |
| 855 | { |
| 856 | //kal_uint32 savedMask; |
| 857 | |
| 858 | /* Save and set MCU's I,F bits to disable interrupts */ |
| 859 | //savedMask = SaveAndSetIRQMask(); |
| 860 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 861 | if (eint_is_dedicated & (1<<eintno)) |
| 862 | { |
| 863 | switch(eint_is_dedicated_map[eintno]) |
| 864 | { |
| 865 | case DEDICATED_EINT0: |
| 866 | { |
| 867 | IRQSensitivity( DEDICATED_EINT_IRQ0, sens); |
| 868 | } |
| 869 | break; |
| 870 | |
| 871 | case DEDICATED_EINT1: |
| 872 | { |
| 873 | IRQSensitivity( DEDICATED_EINT_IRQ1, sens ); |
| 874 | } |
| 875 | break; |
| 876 | |
| 877 | case DEDICATED_EINT2: |
| 878 | { |
| 879 | IRQSensitivity( DEDICATED_EINT_IRQ2, sens ); |
| 880 | } |
| 881 | break; |
| 882 | |
| 883 | case DEDICATED_EINT3: |
| 884 | { |
| 885 | IRQSensitivity( DEDICATED_EINT_IRQ3, sens ); |
| 886 | } |
| 887 | break; |
| 888 | |
| 889 | default: |
| 890 | break; |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | if(sens == EDGE_SENSITIVE) |
| 895 | { |
| 896 | sens = EINT_EDGE_SENSITIVITY; |
| 897 | } |
| 898 | else if(sens == LEVEL_SENSITIVE) |
| 899 | { |
| 900 | sens = EINT_LEVEL_SENSITIVITY; |
| 901 | } |
| 902 | |
| 903 | eint_set_type(eintno, sens); |
| 904 | |
| 905 | /* Restore previous MCU's I,F bits setting */ |
| 906 | //RestoreIRQMask(savedMask); |
| 907 | kal_give_spinlock(md1_eint_lock); |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | #if defined(__MD93__) |
| 912 | /************************************************************************* |
| 913 | * FUNCTION |
| 914 | * EINT_TIMER_CALLBACK |
| 915 | * |
| 916 | * DESCRIPTION |
| 917 | * This function implements main external interrupt LISR registered in |
| 918 | * global ISR jump table. |
| 919 | * |
| 920 | * CALLS |
| 921 | * |
| 922 | * PARAMETERS |
| 923 | * |
| 924 | * RETURNS |
| 925 | * No return |
| 926 | * |
| 927 | * GLOBALS AFFECTED |
| 928 | * |
| 929 | *************************************************************************/ |
| 930 | void EINT_TIMER_CALLBACK(void *data) |
| 931 | { |
| 932 | EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data; |
| 933 | |
| 934 | IRQMask(IRQ_EIT_CODE); |
| 935 | |
| 936 | if(sw_debounce->eint_sw_debounce_handle != 0x7f) |
| 937 | { |
| 938 | DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_STOP,0); |
| 939 | DclSGPT_Close(&(sw_debounce->eint_sw_debounce_handle)); |
| 940 | } |
| 941 | EINT_PRINT("\tEINT_TIMER_CALLBACK, sw_debounce->eint_no = %d",sw_debounce->eint_no); |
| 942 | sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE; |
| 943 | |
| 944 | /* |
| 945 | * This timer is to avoid if interrupt status is changed but |
| 946 | * sw_debounce->eint_intr_allow is still in KAL_TRUE state |
| 947 | * because of no interrupt |
| 948 | */ |
| 949 | if (sw_debounce->eint_intr_allow) |
| 950 | { |
| 951 | SGPT_CTRL_START_T start; |
| 952 | |
| 953 | start.u2Tick= eint_sw_debounce_time_delay[sw_debounce->eint_no]; |
| 954 | |
| 955 | start.pfCallback=EINT_TIMER_CALLBACK; |
| 956 | start.vPara=data; |
| 957 | sw_debounce->eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0); |
| 958 | DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); |
| 959 | } |
| 960 | IRQUnmask(IRQ_EIT_CODE); |
| 961 | EINT_UnMask(sw_debounce->eint_no); |
| 962 | } |
| 963 | |
| 964 | /************************************************************************* |
| 965 | * FUNCTION |
| 966 | * EINT_TIMER_CALLBACK |
| 967 | * |
| 968 | * DESCRIPTION |
| 969 | * This function implements main external interrupt LISR registered in |
| 970 | * global ISR jump table. |
| 971 | * |
| 972 | * CALLS |
| 973 | * |
| 974 | * PARAMETERS |
| 975 | * |
| 976 | * RETURNS |
| 977 | * No return |
| 978 | * |
| 979 | * GLOBALS AFFECTED |
| 980 | * |
| 981 | *************************************************************************/ |
| 982 | void DEINT_TIMER_CALLBACK(void *data) |
| 983 | { |
| 984 | EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data; |
| 985 | |
| 986 | EINT_Mask(sw_debounce->eint_no); |
| 987 | |
| 988 | if(sw_debounce->eint_sw_debounce_handle != 0x7f) |
| 989 | { |
| 990 | DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_STOP,0); |
| 991 | DclSGPT_Close(&(sw_debounce->eint_sw_debounce_handle)); |
| 992 | } |
| 993 | |
| 994 | sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE; |
| 995 | |
| 996 | /* |
| 997 | * This timer is to avoid if interrupt status is changed but |
| 998 | * sw_debounce->eint_intr_allow is still in KAL_TRUE state |
| 999 | * because of no interrupt |
| 1000 | */ |
| 1001 | if (sw_debounce->eint_intr_allow) |
| 1002 | { |
| 1003 | SGPT_CTRL_START_T start; |
| 1004 | |
| 1005 | start.u2Tick= eint_sw_debounce_time_delay[sw_debounce->eint_no]; |
| 1006 | |
| 1007 | start.pfCallback=DEINT_TIMER_CALLBACK; |
| 1008 | start.vPara=data; |
| 1009 | sw_debounce->eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0); |
| 1010 | DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); |
| 1011 | } |
| 1012 | EINT_UnMask(sw_debounce->eint_no); |
| 1013 | } |
| 1014 | |
| 1015 | /************************************************************************* |
| 1016 | * FUNCTION |
| 1017 | * EINT_LISR |
| 1018 | * |
| 1019 | * DESCRIPTION |
| 1020 | * Entry function of External Interrupt Service Routine |
| 1021 | * |
| 1022 | * CALLS |
| 1023 | * |
| 1024 | * PARAMETERS |
| 1025 | * |
| 1026 | * RETURNS |
| 1027 | * No return |
| 1028 | * |
| 1029 | * GLOBALS AFFECTE |
| 1030 | * |
| 1031 | *************************************************************************/ |
| 1032 | void EINT_LISR(kal_uint32 irq_id) |
| 1033 | { |
| 1034 | kal_uint8 index; |
| 1035 | kal_uint32 status,mask_bits; |
| 1036 | |
| 1037 | status = EINT_L2_STA(); |
| 1038 | |
| 1039 | if (EINT_Internal_LISR_Handler(&status)) |
| 1040 | { |
| 1041 | return; |
| 1042 | } |
| 1043 | |
| 1044 | // for conventional external interrupt! |
| 1045 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 1046 | { |
| 1047 | //EINT_PRINT("\tEINT triggered!"); |
| 1048 | if ( EINT_CheckHWDebounce(index) ) |
| 1049 | { |
| 1050 | mask_bits = EINT_Get_Mask_Bits(); |
| 1051 | if (status & EINT_STATUS_EINT(index) && !BU_G_BIT(mask_bits, index)) |
| 1052 | { |
| 1053 | if(eint_sw_debounce[index].eint_sw_debounce_handle != 0x7f) |
| 1054 | { |
| 1055 | DclSGPT_Control(eint_sw_debounce[index].eint_sw_debounce_handle,SGPT_CMD_STOP,0); |
| 1056 | DclSGPT_Close(&(eint_sw_debounce[index].eint_sw_debounce_handle)); |
| 1057 | } |
| 1058 | if ( (eint_sw_debounce[index].eint_intr_allow == KAL_FALSE) && |
| 1059 | (eint_sw_debounce_time_delay[index] > 0) |
| 1060 | ) |
| 1061 | { |
| 1062 | SGPT_CTRL_START_T start; |
| 1063 | //EINT_PRINT("\tstart timer, eint_sw_debounce_time_delay[%d] = %d",index,eint_sw_debounce_time_delay[index]); |
| 1064 | eint_sw_debounce[index].eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0); |
| 1065 | |
| 1066 | start.u2Tick=eint_sw_debounce_time_delay[index]; |
| 1067 | start.pfCallback=EINT_TIMER_CALLBACK; |
| 1068 | start.vPara=&eint_sw_debounce[index]; |
| 1069 | DclSGPT_Control(eint_sw_debounce[index].eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); |
| 1070 | |
| 1071 | EINT_Mask(index); |
| 1072 | Data_Sync_Barrier(); |
| 1073 | } |
| 1074 | else |
| 1075 | { |
| 1076 | eint_sw_debounce[index].eint_intr_allow = KAL_FALSE; |
| 1077 | // disable interrupt |
| 1078 | EINT_Mask(index); |
| 1079 | Data_Sync_Barrier(); |
| 1080 | //EINT_PRINT("\tEINT trigger HISR"); |
| 1081 | ASSERT(EINT_FUNC.eint_func[index]!=NULL); |
| 1082 | if ( EINT_FUNC.eint_func[index] ) |
| 1083 | { |
| 1084 | EINT_FUNC.eint_active[index] = KAL_TRUE; |
| 1085 | |
| 1086 | kal_activate_hisr_index(EINT_HISR); |
| 1087 | } |
| 1088 | } |
| 1089 | EINT_L2_ACK(index); |
| 1090 | } |
| 1091 | } |
| 1092 | else |
| 1093 | { |
| 1094 | if (status & EINT_STATUS_EINT(index)) |
| 1095 | { |
| 1096 | EINT_Mask(index); |
| 1097 | Data_Sync_Barrier(); |
| 1098 | ASSERT(EINT_FUNC.eint_func[index]!=NULL); |
| 1099 | if ( EINT_FUNC.eint_func[index] ) |
| 1100 | { |
| 1101 | EINT_FUNC.eint_active[index] = KAL_TRUE; |
| 1102 | |
| 1103 | kal_activate_hisr_index(EINT_HISR); |
| 1104 | } |
| 1105 | EINT_L2_ACK(index); |
| 1106 | } |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | void DEINT_Process(kal_uint8 deintno) |
| 1112 | { |
| 1113 | kal_uint8 eintno; |
| 1114 | char eintno_temp; |
| 1115 | eintno_temp = gpio_get_l1_eint_src(deintno); |
| 1116 | |
| 1117 | if(eintno_temp==EINT_FAIL) |
| 1118 | { |
| 1119 | ASSERT(0); |
| 1120 | return; |
| 1121 | } |
| 1122 | eintno = (kal_uint8)eintno_temp; |
| 1123 | if ( EINT_CheckHWDebounce(eintno) ) |
| 1124 | { |
| 1125 | if(eint_sw_debounce[eintno].eint_sw_debounce_handle != 0x7f) |
| 1126 | { |
| 1127 | DclSGPT_Control(eint_sw_debounce[eintno].eint_sw_debounce_handle,SGPT_CMD_STOP,0); |
| 1128 | DclSGPT_Close(&(eint_sw_debounce[eintno].eint_sw_debounce_handle)); |
| 1129 | } |
| 1130 | if ( (eint_sw_debounce[eintno].eint_intr_allow == KAL_FALSE) && |
| 1131 | (eint_sw_debounce_time_delay[eintno] > 0) |
| 1132 | ) |
| 1133 | { |
| 1134 | SGPT_CTRL_START_T start; |
| 1135 | //EINT_PRINT("\tDEINT start timer, eint_sw_debounce_time_delay[index] = %d",eint_sw_debounce_time_delay[deintno]); |
| 1136 | eint_sw_debounce[eintno].eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0); |
| 1137 | |
| 1138 | start.u2Tick=eint_sw_debounce_time_delay[eintno]; |
| 1139 | start.pfCallback=DEINT_TIMER_CALLBACK; |
| 1140 | start.vPara=&eint_sw_debounce[eintno]; |
| 1141 | DclSGPT_Control(eint_sw_debounce[eintno].eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); |
| 1142 | |
| 1143 | EINT_Mask(eintno); |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | eint_sw_debounce[eintno].eint_intr_allow = KAL_FALSE; |
| 1148 | // disable interrupt |
| 1149 | //EINT_PRINT("\tDEINT trigger HISR"); |
| 1150 | EINT_Mask(eintno); |
| 1151 | ASSERT(EINT_FUNC.eint_func[eintno]!=NULL); |
| 1152 | if ( EINT_FUNC.eint_func[eintno] ) |
| 1153 | { |
| 1154 | EINT_FUNC.eint_active[eintno] = KAL_TRUE; |
| 1155 | |
| 1156 | kal_activate_hisr_index(DEINT_HISR); |
| 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | else |
| 1161 | { |
| 1162 | EINT_Mask(eintno); |
| 1163 | ASSERT(EINT_FUNC.eint_func[eintno]!=NULL); |
| 1164 | if ( EINT_FUNC.eint_func[eintno] ) |
| 1165 | { |
| 1166 | EINT_FUNC.eint_active[eintno] = KAL_TRUE; |
| 1167 | |
| 1168 | kal_activate_hisr_index(DEINT_HISR); |
| 1169 | } |
| 1170 | } |
| 1171 | } |
| 1172 | #elif defined(__MD95__) || defined(__MD97__)|| defined(__MD97P__) |
| 1173 | |
| 1174 | /************************************************************************* |
| 1175 | * FUNCTION |
| 1176 | * EINT_LISR |
| 1177 | * |
| 1178 | * DESCRIPTION |
| 1179 | * Entry function of External Interrupt Service Routine |
| 1180 | * |
| 1181 | * CALLS |
| 1182 | * |
| 1183 | * PARAMETERS |
| 1184 | * |
| 1185 | * RETURNS |
| 1186 | * No return |
| 1187 | * |
| 1188 | * GLOBALS AFFECTE |
| 1189 | * |
| 1190 | *************************************************************************/ |
| 1191 | void EINT_LISR(kal_uint32 irq_id) |
| 1192 | { |
| 1193 | kal_uint8 index; |
| 1194 | kal_uint32 status,mask_bits; |
| 1195 | |
| 1196 | status = EINT_L2_STA(); |
| 1197 | |
| 1198 | if (EINT_Internal_LISR_Handler(&status)) |
| 1199 | { |
| 1200 | return; |
| 1201 | } |
| 1202 | |
| 1203 | // for conventional external interrupt! |
| 1204 | for(index=0;index<EINT_TOTAL_CHANNEL;index++) |
| 1205 | { |
| 1206 | //EINT_PRINT("\tEINT triggered!"); |
| 1207 | if ( EINT_CheckHWDebounce(index) ) |
| 1208 | { |
| 1209 | mask_bits = EINT_Get_Mask_Bits(); |
| 1210 | if (status & EINT_STATUS_EINT(index) && !BU_G_BIT(mask_bits, index)) |
| 1211 | { |
| 1212 | // disable interrupt |
| 1213 | EINT_Mask(index); |
| 1214 | Data_Sync_Barrier(); |
| 1215 | //EINT_PRINT("\tEINT trigger HISR"); |
| 1216 | ASSERT(EINT_FUNC.eint_func[index]!=NULL); |
| 1217 | if ( EINT_FUNC.eint_func[index] ) |
| 1218 | { |
| 1219 | EINT_FUNC.eint_active[index] = KAL_TRUE; |
| 1220 | |
| 1221 | kal_activate_hisr_index(EINT_HISR); |
| 1222 | } |
| 1223 | EINT_L2_ACK(index); |
| 1224 | } |
| 1225 | } |
| 1226 | else |
| 1227 | { |
| 1228 | if (status & EINT_STATUS_EINT(index)) |
| 1229 | { |
| 1230 | EINT_Mask(index); |
| 1231 | Data_Sync_Barrier(); |
| 1232 | ASSERT(EINT_FUNC.eint_func[index]!=NULL); |
| 1233 | if ( EINT_FUNC.eint_func[index] ) |
| 1234 | { |
| 1235 | EINT_FUNC.eint_active[index] = KAL_TRUE; |
| 1236 | |
| 1237 | kal_activate_hisr_index(EINT_HISR); |
| 1238 | } |
| 1239 | EINT_L2_ACK(index); |
| 1240 | } |
| 1241 | } |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | void DEINT_Process(kal_uint8 deintno) |
| 1246 | { |
| 1247 | kal_uint8 eintno; |
| 1248 | char eintno_temp; |
| 1249 | eintno_temp = gpio_get_l1_eint_src(deintno); |
| 1250 | |
| 1251 | if(eintno_temp==EINT_FAIL) |
| 1252 | { |
| 1253 | ASSERT(0); |
| 1254 | return; |
| 1255 | } |
| 1256 | eintno = (kal_uint8)eintno_temp; |
| 1257 | if ( EINT_CheckHWDebounce(eintno) ) |
| 1258 | { |
| 1259 | // disable interrupt |
| 1260 | //EINT_PRINT("\tDEINT trigger HISR"); |
| 1261 | EINT_Mask(eintno); |
| 1262 | ASSERT(EINT_FUNC.eint_func[eintno]!=NULL); |
| 1263 | if ( EINT_FUNC.eint_func[eintno] ) |
| 1264 | { |
| 1265 | EINT_FUNC.eint_active[eintno] = KAL_TRUE; |
| 1266 | |
| 1267 | kal_activate_hisr_index(DEINT_HISR); |
| 1268 | } |
| 1269 | } |
| 1270 | else |
| 1271 | { |
| 1272 | EINT_Mask(eintno); |
| 1273 | ASSERT(EINT_FUNC.eint_func[eintno]!=NULL); |
| 1274 | if ( EINT_FUNC.eint_func[eintno] ) |
| 1275 | { |
| 1276 | EINT_FUNC.eint_active[eintno] = KAL_TRUE; |
| 1277 | |
| 1278 | kal_activate_hisr_index(DEINT_HISR); |
| 1279 | } |
| 1280 | } |
| 1281 | } |
| 1282 | #else |
| 1283 | #error "no chip match" |
| 1284 | #endif |
| 1285 | |
| 1286 | /************************************************************************* |
| 1287 | * FUNCTION |
| 1288 | * DEINT0_LISR |
| 1289 | * |
| 1290 | * DESCRIPTION |
| 1291 | * Entry function of Dedicated External Interrupt 0 Service Routine |
| 1292 | * |
| 1293 | * CALLS |
| 1294 | * |
| 1295 | * PARAMETERS |
| 1296 | * |
| 1297 | * RETURNS |
| 1298 | * No return |
| 1299 | * |
| 1300 | * GLOBALS AFFECTE |
| 1301 | * |
| 1302 | *************************************************************************/ |
| 1303 | //void DEINT_LISR(void) |
| 1304 | void DEINT0_LISR(kal_uint32 irq_id) |
| 1305 | { |
| 1306 | DEINT_Process(DEDICATED_EINT0); |
| 1307 | } |
| 1308 | |
| 1309 | /************************************************************************* |
| 1310 | * FUNCTION |
| 1311 | * DEINT1_LISR |
| 1312 | * |
| 1313 | * DESCRIPTION |
| 1314 | * Entry function of Dedicated External Interrupt 1 Service Routine |
| 1315 | * |
| 1316 | * CALLS |
| 1317 | * |
| 1318 | * PARAMETERS |
| 1319 | * |
| 1320 | * RETURNS |
| 1321 | * No return |
| 1322 | * |
| 1323 | * GLOBALS AFFECTE |
| 1324 | * |
| 1325 | *************************************************************************/ |
| 1326 | //void DEINT_LISR(void) |
| 1327 | void DEINT1_LISR(kal_uint32 irq_id) |
| 1328 | { |
| 1329 | DEINT_Process(DEDICATED_EINT1); |
| 1330 | } |
| 1331 | |
| 1332 | /************************************************************************* |
| 1333 | * FUNCTION |
| 1334 | * DEINT2_LISR |
| 1335 | * |
| 1336 | * DESCRIPTION |
| 1337 | * Entry function of Dedicated External Interrupt 2 Service Routine |
| 1338 | * |
| 1339 | * CALLS |
| 1340 | * |
| 1341 | * PARAMETERS |
| 1342 | * |
| 1343 | * RETURNS |
| 1344 | * No return |
| 1345 | * |
| 1346 | * GLOBALS AFFECTE |
| 1347 | * |
| 1348 | *************************************************************************/ |
| 1349 | //void DEINT_LISR(void) |
| 1350 | void DEINT2_LISR(kal_uint32 irq_id) |
| 1351 | { |
| 1352 | DEINT_Process(DEDICATED_EINT2); |
| 1353 | } |
| 1354 | |
| 1355 | /************************************************************************* |
| 1356 | * FUNCTION |
| 1357 | * DEINT3_LISR |
| 1358 | * |
| 1359 | * DESCRIPTION |
| 1360 | * Entry function of Dedicated External Interrupt 3 Service Routine |
| 1361 | * |
| 1362 | * CALLS |
| 1363 | * |
| 1364 | * PARAMETERS |
| 1365 | * |
| 1366 | * RETURNS |
| 1367 | * No return |
| 1368 | * |
| 1369 | * GLOBALS AFFECTE |
| 1370 | * |
| 1371 | *************************************************************************/ |
| 1372 | //void DEINT_LISR(void) |
| 1373 | void DEINT3_LISR(kal_uint32 irq_id) |
| 1374 | { |
| 1375 | DEINT_Process(DEDICATED_EINT3); |
| 1376 | } |
| 1377 | |
| 1378 | |
| 1379 | |
| 1380 | /************************************************************************* |
| 1381 | * FUNCTION |
| 1382 | * EINT_SaveAndMask |
| 1383 | * |
| 1384 | * DESCRIPTION |
| 1385 | * This function saves and masks the specified external interrupt |
| 1386 | * |
| 1387 | * PARAMETERS |
| 1388 | * eintno - external interrupt vector number |
| 1389 | * |
| 1390 | * RETURNS |
| 1391 | * original mask |
| 1392 | * |
| 1393 | *************************************************************************/ |
| 1394 | kal_uint32 EINT_SaveAndMask(kal_uint8 eintno) |
| 1395 | { |
| 1396 | kal_uint32 eint_mask;//savedMask |
| 1397 | |
| 1398 | |
| 1399 | /* lockout interrupt */ |
| 1400 | //savedMask = SaveAndSetIRQMask(); |
| 1401 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 1402 | /* save EINT mask */ |
| 1403 | eint_mask = EINT_Get_Mask_Bits(); |
| 1404 | |
| 1405 | /* mask EINT */ |
| 1406 | EINT_Mask(eintno); |
| 1407 | |
| 1408 | /* clear unnecessary bits */ |
| 1409 | eint_mask = eint_mask & (0x0001 << eintno); |
| 1410 | |
| 1411 | /* un-lockout interrupt */ |
| 1412 | //RestoreIRQMask(savedMask); |
| 1413 | kal_give_spinlock(md1_eint_lock); |
| 1414 | return eint_mask; |
| 1415 | } |
| 1416 | |
| 1417 | |
| 1418 | /************************************************************************* |
| 1419 | * FUNCTION |
| 1420 | * EINT_RestoreMask |
| 1421 | * |
| 1422 | * DESCRIPTION |
| 1423 | * This function restores the MASK of the specified external interrupt |
| 1424 | * |
| 1425 | * PARAMETERS |
| 1426 | * val - value to restore |
| 1427 | * |
| 1428 | * RETURNS |
| 1429 | * No return |
| 1430 | * |
| 1431 | *************************************************************************/ |
| 1432 | void EINT_RestoreMask(kal_uint8 eintno, kal_uint32 val) |
| 1433 | { |
| 1434 | //kal_uint32 savedMask; |
| 1435 | |
| 1436 | |
| 1437 | /* lockout interrupt */ |
| 1438 | //savedMask = SaveAndSetIRQMask(); |
| 1439 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 1440 | /* |
| 1441 | * NoteXXX: The external interrup should already be masked here (via the |
| 1442 | * EINT_SaveAndMask() call). Only need to change the EINT_MASK |
| 1443 | * when the external interrupt is originally un-masked. |
| 1444 | */ |
| 1445 | if (val == 0) |
| 1446 | { |
| 1447 | EINT_UnMask(eintno); |
| 1448 | } |
| 1449 | |
| 1450 | /* un-lockout interrupt */ |
| 1451 | //RestoreIRQMask(savedMask); |
| 1452 | kal_give_spinlock(md1_eint_lock); |
| 1453 | } |
| 1454 | #if defined(__MD93__) |
| 1455 | /************************************************************************* |
| 1456 | * FUNCTION |
| 1457 | * EINT_SW_Debounce_Init |
| 1458 | * |
| 1459 | * DESCRIPTION |
| 1460 | * Initialize debounce time |
| 1461 | * |
| 1462 | * CALLS |
| 1463 | * |
| 1464 | * PARAMETERS |
| 1465 | * |
| 1466 | * RETURNS |
| 1467 | * No return |
| 1468 | * |
| 1469 | * GLOBALS AFFECTE |
| 1470 | * |
| 1471 | *************************************************************************/ |
| 1472 | void EINT_SW_Debounce_Init(void) |
| 1473 | { |
| 1474 | kal_uint8 index; |
| 1475 | |
| 1476 | for (index = 0; index < EINT_TOTAL_CHANNEL; index++) |
| 1477 | { |
| 1478 | eint_sw_debounce[index].eint_sw_debounce_handle = 0x7f; |
| 1479 | if( EINT_CheckHWDebounce(index) ) |
| 1480 | { |
| 1481 | eint_sw_debounce[index].eint_intr_allow = KAL_FALSE; |
| 1482 | eint_sw_debounce[index].eint_no = index; |
| 1483 | } |
| 1484 | } |
| 1485 | |
| 1486 | #ifndef ATEST_DRV_ENABLE |
| 1487 | eint_sw_debounce_time_delay = custom_config_eint_sw_debounce_time_delay(); |
| 1488 | #endif |
| 1489 | } |
| 1490 | |
| 1491 | /************************************************************************* |
| 1492 | * FUNCTION |
| 1493 | * EINT_SW_Debounce_Modify |
| 1494 | * |
| 1495 | * DESCRIPTION |
| 1496 | * Setting debounce time |
| 1497 | * |
| 1498 | * CALLS |
| 1499 | * |
| 1500 | * PARAMETERS |
| 1501 | * |
| 1502 | * RETURNS |
| 1503 | * No return |
| 1504 | * |
| 1505 | * GLOBALS AFFECTE |
| 1506 | * |
| 1507 | *************************************************************************/ |
| 1508 | kal_int32 EINT_SW_Debounce_Modify(kal_uint8 eintno, kal_uint8 debounce_time) |
| 1509 | { |
| 1510 | //kal_uint32 savedMask; |
| 1511 | |
| 1512 | if ( EINT_CheckNotHWDebounce(eintno)) |
| 1513 | return -1; |
| 1514 | |
| 1515 | if(NULL == eint_sw_debounce_time_delay) |
| 1516 | { |
| 1517 | eint_sw_debounce_time_delay = custom_config_eint_sw_debounce_time_delay(); |
| 1518 | } |
| 1519 | |
| 1520 | //savedMask = SaveAndSetIRQMask(); |
| 1521 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 1522 | eint_sw_debounce_time_delay[eintno] = debounce_time; |
| 1523 | //RestoreIRQMask(savedMask); |
| 1524 | kal_give_spinlock(md1_eint_lock); |
| 1525 | return 1; |
| 1526 | } |
| 1527 | #elif defined(__MD95__) |
| 1528 | #elif defined(__MD97__) |
| 1529 | #elif defined(__MD97P__) |
| 1530 | #else |
| 1531 | #error "no chip match" |
| 1532 | #endif |
| 1533 | /************************************************************************* |
| 1534 | * FUNCTION |
| 1535 | * EINT_SaveAndMaskAll |
| 1536 | * |
| 1537 | * DESCRIPTION |
| 1538 | * This function saves and masks the specified external interrupt |
| 1539 | * |
| 1540 | * PARAMETERS |
| 1541 | * eintno - external interrupt vector number |
| 1542 | * |
| 1543 | * RETURNS |
| 1544 | * original mask |
| 1545 | * |
| 1546 | *************************************************************************/ |
| 1547 | kal_uint32 EINT_SaveAndMaskAll(void) |
| 1548 | { |
| 1549 | kal_uint32 eint_mask, eint_new_mask;//savedMask |
| 1550 | |
| 1551 | #if (EINT_TOTAL_CHANNEL < 32) |
| 1552 | eint_new_mask = (1<<EINT_TOTAL_CHANNEL)-1; |
| 1553 | #else |
| 1554 | eint_new_mask = 0xffffffff; |
| 1555 | #endif |
| 1556 | |
| 1557 | /* lockout interrupt */ |
| 1558 | //savedMask = SaveAndSetIRQMask(); |
| 1559 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 1560 | /* save EINT mask */ |
| 1561 | eint_mask = EINT_Get_Mask_Bits(); |
| 1562 | |
| 1563 | /* mask EINT */ |
| 1564 | EINT_Set_Mask_all(eint_new_mask); |
| 1565 | |
| 1566 | /* un-lockout interrupt */ |
| 1567 | //RestoreIRQMask(savedMask); |
| 1568 | kal_give_spinlock(md1_eint_lock); |
| 1569 | return eint_mask; |
| 1570 | } |
| 1571 | |
| 1572 | |
| 1573 | |
| 1574 | /************************************************************************* |
| 1575 | * FUNCTION |
| 1576 | * EINT_RestoreMaskAll |
| 1577 | * |
| 1578 | * DESCRIPTION |
| 1579 | * This function restores the MASK of the specified external interrupt |
| 1580 | * |
| 1581 | * PARAMETERS |
| 1582 | * val - value to restore |
| 1583 | * |
| 1584 | * RETURNS |
| 1585 | * No return |
| 1586 | * |
| 1587 | *************************************************************************/ |
| 1588 | void EINT_RestoreMaskAll(kal_uint32 val) |
| 1589 | { |
| 1590 | //kal_uint32 savedMask; |
| 1591 | #if 0 |
| 1592 | /* under construction !*/ |
| 1593 | /* under construction !*/ |
| 1594 | #if !defined(__HW_US_TIMER_SUPPORT__) |
| 1595 | /* under construction !*/ |
| 1596 | /* under construction !*/ |
| 1597 | /* under construction !*/ |
| 1598 | /* under construction !*/ |
| 1599 | #endif |
| 1600 | #endif |
| 1601 | |
| 1602 | /* lockout interrupt */ |
| 1603 | //savedMask = SaveAndSetIRQMask(); |
| 1604 | kal_take_spinlock(md1_eint_lock, KAL_INFINITE_WAIT); |
| 1605 | /* |
| 1606 | * NoteXXX: The external interrupt should already be masked here (via the |
| 1607 | * EINT_SaveAndMask() call). Only need to change the EINT_MASK |
| 1608 | * when the external interrupt is originally un-masked. |
| 1609 | */ |
| 1610 | EINT_Set_Mask_all(0xffffffff); |
| 1611 | EINT_Set_UnMask_all(~val); |
| 1612 | |
| 1613 | /* un-lockout interrupt */ |
| 1614 | //RestoreIRQMask(savedMask); |
| 1615 | kal_give_spinlock(md1_eint_lock); |
| 1616 | } |
| 1617 | |
| 1618 | |
| 1619 | |
| 1620 | /************************************************************************* |
| 1621 | * FUNCTION |
| 1622 | * EINT_SetSWRegister |
| 1623 | * |
| 1624 | * DESCRIPTION |
| 1625 | * This function set EINT SW interrupt register |
| 1626 | * |
| 1627 | * PARAMETERS |
| 1628 | * |
| 1629 | * RETURNS |
| 1630 | * none |
| 1631 | * |
| 1632 | *************************************************************************/ |
| 1633 | void EINT_SetSWRegister(kal_uint8 eintno) |
| 1634 | { |
| 1635 | //MT6290 not support this register |
| 1636 | } |
| 1637 | |
| 1638 | /************************************************************************* |
| 1639 | * FUNCTION |
| 1640 | * EINT_ResetSWRegister |
| 1641 | * |
| 1642 | * DESCRIPTION |
| 1643 | * This function set EINT SW interrupt register |
| 1644 | * |
| 1645 | * PARAMETERS |
| 1646 | * |
| 1647 | * RETURNS |
| 1648 | * none |
| 1649 | * |
| 1650 | *************************************************************************/ |
| 1651 | void EINT_ResetSWRegister(kal_uint8 eintno) |
| 1652 | { |
| 1653 | //MT6290 not support this register |
| 1654 | } |
| 1655 | |
| 1656 | /************************************************************************* |
| 1657 | * FUNCTION |
| 1658 | * EINT_Set_OwnerShip |
| 1659 | * |
| 1660 | * DESCRIPTION |
| 1661 | * This function sets the ownership of external interrupts |
| 1662 | * |
| 1663 | * CALLS |
| 1664 | * |
| 1665 | * PARAMETERS |
| 1666 | * eintno - External interrupt vector number |
| 1667 | * ownership - 0: MD ownership, 1: AP ownerhship |
| 1668 | * |
| 1669 | * RETURNS |
| 1670 | * 0 for success; -1 for failure |
| 1671 | * |
| 1672 | * GLOBALS AFFECTED |
| 1673 | * |
| 1674 | *************************************************************************/ |
| 1675 | kal_int32 EINT_Set_OwnerShip(kal_uint8 eintno, kal_uint8 ownership) |
| 1676 | { |
| 1677 | eint_set_ownership(eintno,ownership); |
| 1678 | return EINT_OK; |
| 1679 | } |
| 1680 | |
| 1681 | /************************************************************************* |
| 1682 | * FUNCTION |
| 1683 | * EINT_Set_Source_GPIO |
| 1684 | * |
| 1685 | * DESCRIPTION |
| 1686 | * This function set the signal of source GPIO as input signal of the specified external interrupt |
| 1687 | * |
| 1688 | * PARAMETERS |
| 1689 | * eintno - External interrupt vector number |
| 1690 | * gpiono - the GPIO number to be set as source of the specified external interrupt. |
| 1691 | |
| 1692 | * |
| 1693 | * RETURNS |
| 1694 | * No return |
| 1695 | * |
| 1696 | *************************************************************************/ |
| 1697 | |
| 1698 | kal_int32 EINT_Set_Source_GPIO(kal_uint8 eintno, kal_uint8 gpiono) |
| 1699 | { |
| 1700 | if(gpio_set_eint_src(eintno,gpiono) != EINT_OK) |
| 1701 | { |
| 1702 | return EINT_FAIL; |
| 1703 | } |
| 1704 | |
| 1705 | return EINT_OK; |
| 1706 | } |
| 1707 | |
| 1708 | /************************************************************************* |
| 1709 | * FUNCTION |
| 1710 | * EINT_Set_Dedicated_Eint |
| 1711 | * |
| 1712 | * DESCRIPTION |
| 1713 | * This function set the specified external interrupt as L1 IRQ, not shared irq. |
| 1714 | * |
| 1715 | * PARAMETERS |
| 1716 | * Deintno - L1 external interrupt ID 0~3 |
| 1717 | * eintno - External interrupt vector number |
| 1718 | |
| 1719 | * |
| 1720 | * RETURNS |
| 1721 | * No return |
| 1722 | * |
| 1723 | *************************************************************************/ |
| 1724 | kal_int32 EINT_Set_Dedicated_Eint(kal_uint8 Deintno, kal_uint8 eintno) |
| 1725 | { |
| 1726 | if(gpio_set_l1_eint(Deintno,eintno,EINT_ENABLE) != EINT_OK) |
| 1727 | { |
| 1728 | return EINT_FAIL; |
| 1729 | } |
| 1730 | |
| 1731 | return EINT_OK; |
| 1732 | } |
| 1733 | |
| 1734 | /************************************************************************* |
| 1735 | * FUNCTION |
| 1736 | * DEINT_UnMask |
| 1737 | * |
| 1738 | * DESCRIPTION |
| 1739 | * This function implements Unmask of dedicated external interrupt source |
| 1740 | * |
| 1741 | * CALLS |
| 1742 | * |
| 1743 | * PARAMETERS |
| 1744 | * deintno - external interrupt vector number |
| 1745 | * |
| 1746 | * RETURNS |
| 1747 | * No return |
| 1748 | * |
| 1749 | * GLOBALS AFFECTED |
| 1750 | * |
| 1751 | *************************************************************************/ |
| 1752 | void DEINT_Registration(kal_uint8 deintno,void (reg_hisr)(void)) |
| 1753 | { |
| 1754 | #if 0 |
| 1755 | /* under construction !*/ |
| 1756 | /* under construction !*/ |
| 1757 | /* under construction !*/ |
| 1758 | /* under construction !*/ |
| 1759 | /* under construction !*/ |
| 1760 | /* under construction !*/ |
| 1761 | /* under construction !*/ |
| 1762 | /* under construction !*/ |
| 1763 | /* under construction !*/ |
| 1764 | /* under construction !*/ |
| 1765 | /* under construction !*/ |
| 1766 | /* under construction !*/ |
| 1767 | /* under construction !*/ |
| 1768 | /* under construction !*/ |
| 1769 | /* under construction !*/ |
| 1770 | /* under construction !*/ |
| 1771 | /* under construction !*/ |
| 1772 | /* under construction !*/ |
| 1773 | /* under construction !*/ |
| 1774 | /* under construction !*/ |
| 1775 | /* under construction !*/ |
| 1776 | /* under construction !*/ |
| 1777 | /* under construction !*/ |
| 1778 | /* under construction !*/ |
| 1779 | /* under construction !*/ |
| 1780 | /* under construction !*/ |
| 1781 | /* under construction !*/ |
| 1782 | /* under construction !*/ |
| 1783 | /* under construction !*/ |
| 1784 | /* under construction !*/ |
| 1785 | /* under construction !*/ |
| 1786 | /* under construction !*/ |
| 1787 | #endif |
| 1788 | } |
| 1789 | #if 0 |
| 1790 | /* under construction !*/ |
| 1791 | /* under construction !*/ |
| 1792 | /* under construction !*/ |
| 1793 | /* under construction !*/ |
| 1794 | /* under construction !*/ |
| 1795 | /* under construction !*/ |
| 1796 | /* under construction !*/ |
| 1797 | /* under construction !*/ |
| 1798 | /* under construction !*/ |
| 1799 | /* under construction !*/ |
| 1800 | /* under construction !*/ |
| 1801 | /* under construction !*/ |
| 1802 | /* under construction !*/ |
| 1803 | /* under construction !*/ |
| 1804 | /* under construction !*/ |
| 1805 | /* under construction !*/ |
| 1806 | /* under construction !*/ |
| 1807 | /* under construction !*/ |
| 1808 | /* under construction !*/ |
| 1809 | /* under construction !*/ |
| 1810 | /* under construction !*/ |
| 1811 | /* under construction !*/ |
| 1812 | /* under construction !*/ |
| 1813 | /* under construction !*/ |
| 1814 | /* under construction !*/ |
| 1815 | /* under construction !*/ |
| 1816 | /* under construction !*/ |
| 1817 | /* under construction !*/ |
| 1818 | /* under construction !*/ |
| 1819 | /* under construction !*/ |
| 1820 | /* under construction !*/ |
| 1821 | /* under construction !*/ |
| 1822 | /* under construction !*/ |
| 1823 | /* under construction !*/ |
| 1824 | /* under construction !*/ |
| 1825 | /* under construction !*/ |
| 1826 | /* under construction !*/ |
| 1827 | /* under construction !*/ |
| 1828 | /* under construction !*/ |
| 1829 | /* under construction !*/ |
| 1830 | /* under construction !*/ |
| 1831 | /* under construction !*/ |
| 1832 | /* under construction !*/ |
| 1833 | /* under construction !*/ |
| 1834 | /* under construction !*/ |
| 1835 | /* under construction !*/ |
| 1836 | /* under construction !*/ |
| 1837 | /* under construction !*/ |
| 1838 | /* under construction !*/ |
| 1839 | /* under construction !*/ |
| 1840 | /* under construction !*/ |
| 1841 | /* under construction !*/ |
| 1842 | /* under construction !*/ |
| 1843 | /* under construction !*/ |
| 1844 | /* under construction !*/ |
| 1845 | #endif |