void nfc_timer_expiry_hdlr (int sig, siginfo_t *si, void *uc) { int timer_slot; timer_t *tidp; ppCallBck_t cb_func; void *param; #ifdef DEBUG_LOG ALOGD("[TIMER]Caugh signal %d\n", sig); #endif tidp = si->si_value.sival_ptr; /* Look up timer_slot of this timeout, range = 0 ~ (MTK_NFC_TIMER_MAX_NUM-1) */ for(timer_slot = 0; timer_slot < MTK_NFC_TIMER_MAX_NUM; timer_slot++) { if(nfc_timer_table[timer_slot].handle == *tidp) { break; } } if(timer_slot == MTK_NFC_TIMER_MAX_NUM) //timer not found in table { #ifdef DEBUG_LOG //ALOGD("[TIMER]timer no found in the table : (handle: 0x%x)\r\n", nfc_timer_table[timer_slot].handle); ALOGD("[TIMER]timer no found in the table \r\n"); #endif return; } //get the cb and param from gps timer pool cb_func = nfc_timer_table[timer_slot].timer_expiry_callback; param = nfc_timer_table[timer_slot].timer_expiry_context; //stop time (windows timer is periodic timer) mtk_nfc_sys_timer_stop(timer_slot); //execute cb (*cb_func)(timer_slot, param); }
MTK_NFC_CHIP_TYPE_E mtk_nfc_get_chip_type (void) { MTK_NFC_CHIP_TYPE_E eChipType = MTK_NFC_CHIP_TYPE_UNKNOW; int result; char data[32];// ="0x55"; int len =0; unsigned int TimerID; //Init Timer // Initialize timer handler result = mtk_nfc_sys_timer_init(); if (result < 0) { #ifdef DEBUG_LOG ALOGD("mtk_nfc_sys_timer_init fail, error code %d\n", result); #endif return (result); } //{ //int i; //for (i=0;i<100;i++){ usleep(1000);} //} //ALOGD("MT6605_LC_TEST_ADD_DELAY"); /* TRY MT6605*/ ////////////////////////////////////////////////////////////////// // (1) open device node handle = open(DevNode_mt6605, O_RDWR | O_NOCTTY); if (handle < 0) { #ifdef DEBUG_LOG ALOGD("OpenDeviceFail,eChipType,%d",eChipType); #endif return eChipType; } // (3) mask IRQ by IOCTL ioctl(handle,0xFE00,0); // (4) re-registration IRQ handle by IOCTL ioctl(handle,0xFE01,0); // ioctl(handle,0x01, ((0x00 << 8) | (0x01))); ioctl(handle,0x01, ((0x01 << 8) | (0x00))); { int i; for (i=0;i<10;i++){ usleep(1000);} } // ioctl(handle,0x01, ((0x00 << 8) | (0x00))); ioctl(handle,0x01, ((0x01 << 8) | (0x00))); { int i; for (i=0;i<10;i++){ usleep(1000);} } ioctl(handle,0x01, ((0x01 << 8) | (0x01))); // { int i; for (i=0;i<100;i++){ usleep(1000);} } //ALOGD("MT6605_LC_TEST_O"); // (5) Write 0x55 data[0] = 0x55; len = 1; if (write(handle, &data[0], len) < 0) { #ifdef DEBUG_LOG ALOGD("MT6605_Write_Err"); #endif return eChipType; } // (6) Read 0x55 // Set Timeout mtkNfcQueryChipIdTimeout = 1; TimerID = mtk_nfc_sys_timer_create(); // Seart Timer and set time-out is 3 sec mtk_nfc_sys_timer_start(TimerID, 3000, &mtkNfcQueryChipIdTimeoutCb, NULL); len = 32; if (read(handle, &data[0], len) < 0) { #ifdef DEBUG_LOG ALOGD("MT6605_Write_Err"); #endif return eChipType; } if (mtkNfcQueryChipIdTimeout == 1) { mtk_nfc_sys_timer_stop(TimerID); if ((data[0] == 0xA5) /*&& (data[1] == 0x05) && (data[2] == 0x00) && (data[3] == 0x01)*/) { eChipType = MTK_NFC_CHIP_TYPE_MT6605; } close(handle); } mtk_nfc_sys_timer_delete(TimerID); ////////////////////////////////////////////////////////////////// /* TRY MT6605 END*/ #ifdef DEBUG_LOG ALOGD("eChipType,%d",eChipType); #endif return eChipType; }