void noke_drv_horse_race_keyenter_round_light_on_timer_handler(void * index) { kal_uint8 horse_race_tmr_handle = HORSE_RASE_TMR_HANDLE; kal_bool ret = KAL_FALSE; int lights = enter_key_style_array[*((int *)index)]; kal_uint16 horse_race_tmr_repeat = 10; /*30ms : 1s = 100ticks, 0.1s = 10ticks */ GPTI_StopItem(horse_race_tmr_handle); noke_drv_horse_race_keyenter_backlight( lights ); f_lights_index++; if( f_lights_index >= sizeof(enter_key_style_array)/sizeof(int) ) { f_lights_index = 0; return; } do{ ret = GPTI_StartItem(horse_race_tmr_handle, horse_race_tmr_repeat, noke_drv_horse_race_keyenter_round_light_on_timer_handler, (void *)(&f_lights_index)); }while( ret== KAL_FALSE ); }
void pmic6326_ccci_ut_timer_cb(void *parameter) { if (pmic6236_ccci_ut_count == 0) { // Lock pmic6326_ccci_lock(KAL_TRUE); } else if (pmic6236_ccci_ut_count == 1) { // Turn off VSIM pmic6326_ccci_vsim_enable(KAL_FALSE); } else if (pmic6236_ccci_ut_count == 2) { // Set VSIM to 3.3V and turn on VSIM pmic6326_ccci_vsim_sel_and_enable(VSIM_3_3V); } else if (pmic6236_ccci_ut_count == 3) { // Unlock pmic6326_ccci_lock(KAL_FALSE); } pmic6236_ccci_ut_count++; if (pmic6236_ccci_ut_count == 4) { pmic6236_ccci_ut_count = 0; } GPTI_StartItem(pmic6236_ccci_ut_gpt_handle, 100, pmic6326_ccci_ut_timer_cb, NULL); }
static void e_compass_enable_driver(kal_bool enable) { if (KAL_TRUE == enable) { e_compass_sensor_custom_fp->ec_take_measurement(); /* we have different GPT timer for different state */ if (E_COMPASS_SENSOR_START_CALI != e_compass_sensor_data.cali_state) GPTI_StartItem(e_compass_sensor_data.sample_handle,e_compass_sensor_custom_dp->normal_sample_dura,e_compass_sample_cb,NULL); else GPTI_StartItem(e_compass_sensor_data.sample_handle,e_compass_sensor_custom_dp->calibration_sample_dura,e_compass_sample_cb,NULL); } else { GPTI_StopItem(e_compass_sensor_data.sample_handle); } }
/************************************************************************* * FUNCTION * EINT_LISR * * DESCRIPTION * Entry function of External Interrupt Service Routine * * CALLS * * PARAMETERS * * RETURNS * No return * * GLOBALS AFFECTE * *************************************************************************/ void EINT_LISR(void) { kal_uint8 index; kal_uint16 status; status = *EINT_STATUS; // for conventional external interrupt! for(index=0;index<EINT_MAX_CHANNEL;index++) { if (status & EINT_STATUS_EINT(index)) { GPTI_StopItem(eint_sw_debounce[index].eint_sw_debounce_handle); if ( (eint_sw_debounce[index].eint_intr_allow == KAL_FALSE) && (eint_sw_debounce_time_delay[index] > 0) ) { GPTI_StartItem(eint_sw_debounce[index].eint_sw_debounce_handle, eint_sw_debounce_time_delay[index], EINT_TIMER_CALLBACK, &eint_sw_debounce[index]); EINT_Mask(index); } else { eint_sw_debounce[index].eint_intr_allow = KAL_FALSE; // disable interrupt EINT_Mask(index); ASSERT(EINT_FUNC.eint_func[index]!=NULL); if ( EINT_FUNC.eint_func[index] ) { EINT_FUNC.eint_active[index] = KAL_TRUE; drv_active_hisr(DRV_EINT_HISR_ID); } } *EINT_INTACK = EINT_INTACK_EINT(index); } } // for external interrupt without hardware debounce and always edge sensitive for (index=EINT_MAX_CHANNEL; index<EINT_TOTAL_CHANNEL; index++) { if (status & EINT_STATUS_EINT(index)) { EINT_Mask(index); ASSERT(EINT_FUNC.eint_func[index]!=NULL); if ( EINT_FUNC.eint_func[index] ) { EINT_FUNC.eint_active[index] = KAL_TRUE; drv_active_hisr(DRV_EINT_HISR_ID); } *EINT_INTACK = EINT_INTACK_EINT(index); } } }
void pmic6326_ccci_ut_main(void) { GPTI_GetHandle(&pmic6236_ccci_ut_gpt_handle); GPTI_StartItem(pmic6236_ccci_ut_gpt_handle, 1000, pmic6326_ccci_ut_timer_cb, NULL); }
void pw_charger_usb_det_eint_ADC(void) { USB_Phy_Enable(USB_PHY_OWNER_BMT);//USB_PowerControl(KAL_TRUE); if (bmt_event_sche_active == 1){ if (usb_charger_eint_reg_handle == 0xFF){ GPTI_GetHandle(&usb_charger_eint_reg_handle); } GPTI_StartItem(usb_charger_eint_reg_handle, 1, usb_charger_eint_reg_adc_measurement_cb, NULL); }else{ // bmt task is NOT setting event scheduler, we can set directly //adc_sche_set_timer_page_align(KAL_FALSE); adc_sche_add_item(chr_usb_detect.chr_usb_adc_logical_id,check_charger_or_usb,adc_sche_measure); } }
void Direction_Sensor_state_Filter() { kal_uint8 direction_sensor_tmr_handle = DIRECTION_SENSOR_TMR_HANDLE; kal_uint16 direction_sensor_tmr_repeat = 50; /* 1s = 100ticks, 0.1s = 10ticks */ kal_bool ret = KAL_FALSE; //noke_dbg_printf("\rHongzhe.Liu : Direction_Sensor_state_Filter ... \n"); GPTI_StopItem(direction_sensor_tmr_handle); kal_sleep_task(100); do{ ret = GPTI_StartItem(direction_sensor_tmr_handle, direction_sensor_tmr_repeat, Direct_Sensor_Set_Sensor_State, NULL); //noke_dbg_printf("\rHongzhe.Liu : Direction_Sensor_state_Filter : start ret=%d... \n", ret); }while( ret== KAL_FALSE ); }
/* config escape charater and guard time */ static void USB2UART_ConfigEscape(UART_PORT port, kal_uint8 EscChar, kal_uint16 ESCGuardtime, module_type ownerid) { #ifndef __PRODUCTION_RELEASE__ if(ownerid != USB2UARTPort.ownerid) { EXT_ASSERT( 0, (kal_uint32) ownerid, USB2UARTPort.ownerid, 0); } #endif USB2UARTPort.ESCDet.EscChar = EscChar; USB2UARTPort.ESCDet.GuardTime = ESCGuardtime; if (USB2UARTPort.ESCDet.GuardTime) { USB2UARTPort.Rec_state = UART_RecNormal; GPTI_StartItem(USB2UARTPort.handle, (USB2UARTPort.ESCDet.GuardTime/10), USB2UART_Timeout, &USB2UARTPort); } }
/************************************************************************* * FUNCTION * EINT_TIMER_CALLBACK * * DESCRIPTION * This function implements main external interrupt LISR registered in * global ISR jump table. * * CALLS * * PARAMETERS * * RETURNS * No return * * GLOBALS AFFECTED * *************************************************************************/ void EINT_TIMER_CALLBACK(void *data) { EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data; GPTI_StopItem(sw_debounce->eint_sw_debounce_handle); sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE; /* * This timer is to avoid if interrupt status is changed but * sw_debounce->eint_intr_allow is still in KAL_TRUE state * because of no interrupt */ if (sw_debounce->eint_intr_allow) { GPTI_StartItem(sw_debounce->eint_sw_debounce_handle, eint_sw_debounce_time_delay[sw_debounce->eint_no], /*0.5 second*/ EINT_TIMER_CALLBACK, data); } EINT_UnMask(sw_debounce->eint_no); }
/* Determine transmit data If return value is large than 0, the caller should send the data in parameter. This function and "USB2UART_Update_Transmit_Data" function must be pair. */ static kal_uint32 USB2UART_Check_Transmit_Data(kal_uint32* addr, kal_bool b_check) { kal_uint32 length = 0; kal_uint32 savedMask; // g_UsbACM.force_ISR_buffer = KAL_FALSE; if(g_UsbACM.ring_buffer_timer_counting == KAL_TRUE) { GPTI_StopItem(g_UsbACM.ring_buffer_handle); g_UsbACM.ring_buffer_timer_counting = KAL_FALSE; } /* First, check if TX ISR buffer has "enough" data to send out */ /* The data in the ISR TX buffer must be sent out all at one time. Otherwise, the catcher cannot decode the log correctly */ savedMask = SaveAndSetIRQMask(); if (USB2UARTPort.Tx_Buffer_ISR.Write != USB2UARTPort.Tx_Buffer_ISR.Read) { /* used for callback function to know sent source */ USB2Uart_MemType = USBTRX_MEM_ISR; *addr = (kal_uint32)USB2UARTPort.Tx_Buffer_ISR.CharBuffer+USB2UARTPort.Tx_Buffer_ISR.Read; if (USB2UARTPort.Tx_Buffer_ISR.Write >= USB2UARTPort.Tx_Buffer_ISR.Read) { length = USB2UARTPort.Tx_Buffer_ISR.Write - USB2UARTPort.Tx_Buffer_ISR.Read; if(b_check == KAL_TRUE) { if(length <= (g_UsbACM.acm_param->txisr_ringbuff_size/2)) { length = 0; g_UsbACM.ring_buffer_timer_counting = KAL_TRUE; } } } else { /* ISR TX buffer must have data to send out */ length = USB2UARTPort.Tx_Buffer_ISR.Length - USB2UARTPort.Tx_Buffer_ISR.Read; } } /* check if TX buffer has enough data to send out */ if((USB2UARTPort.Tx_Buffer.Write != USB2UARTPort.Tx_Buffer.Read) && (length == 0)) { g_UsbACM.ring_buffer_timer_counting = KAL_FALSE; /* used for callback function to know sent source */ USB2Uart_MemType = USBTRX_MEM_TASK; *addr = (kal_uint32)USB2UARTPort.Tx_Buffer.CharBuffer+USB2UARTPort.Tx_Buffer.Read; if(USB2UARTPort.Tx_Buffer.Write >= USB2UARTPort.Tx_Buffer.Read) { length = USB2UARTPort.Tx_Buffer.Write - USB2UARTPort.Tx_Buffer.Read; #ifndef __L1_STANDALONE__ if(b_check == KAL_TRUE) { if(length <= (g_UsbACM.acm_param->tx_ringbuff_size/2)) { length = 0; g_UsbACM.ring_buffer_timer_counting = KAL_TRUE; } } #endif } else { length = USB2UARTPort.Tx_Buffer.Length - USB2UARTPort.Tx_Buffer.Read; } } RestoreIRQMask(savedMask); if(g_UsbACM.ring_buffer_timer_counting == KAL_TRUE) { USB2Uart_MemType = USBTRX_MEM_UNKOWN; GPTI_StartItem(g_UsbACM.ring_buffer_handle, USBACM_RING_BUFFER_TIMEOUT, USB_Acm_Ring_Buffer_Timeout, NULL); } /* If the packet size is multiple of 64, make the last one to be less than 64. Otherwise the last packet may not be seen on WinXP */ if(((length&0x3f) == 0) && (length != 0)) USB2Uart_WriteLength = length - 1; else USB2Uart_WriteLength = length; return USB2Uart_WriteLength; }
*************************************************************************/ kal_int32 GIF_DecodeNext(void* dest) { kal_uint8 status; kal_uint8 bg_index; kal_uint16 *gct_ptr; DRV_WriteReg32(GIF_GCE_REG,((gif_dcb.gif_info.transparent_index<< 1)| \ (gif_dcb.gif_info.transparent_flag))); DRV_WriteReg32(GIF_ORGB_BASE_ADDR,dest); gif_dcb.is_timeout = KAL_FALSE; GIF_START(); GPTI_StartItem(gif_dcb.gpt_handle, gif_dcb.timeout_period, GIF_TimeOutHandler, NULL); // busy waiting may be replaced by retreive event group while(1) { volatile kal_bool *timeout = &gif_dcb.is_timeout; status = DRV_Reg(GIF_STATUS_REG); // check if gif decoder is completed or not if(status & ~GIF_STATUS_GCE) { GPTI_StopItem(gif_dcb.gpt_handle); gif_dcb.is_timeout = KAL_FALSE; break; } if(*timeout) { status = DRV_Reg(GIF_STATUS_REG); // check if gif decoder is completed or not if(status & ~GIF_STATUS_GCE) { GPTI_StopItem(gif_dcb.gpt_handle); gif_dcb.is_timeout = KAL_FALSE; break; } break; } } // check if the guard pattern still exists GIF_CheckGuardPatternValid(); // retreive gif info and backgroud color GIF_GetInfo(&gif_dcb.gif_info); bg_index = gif_dcb.gif_info.bg; gct_ptr = (kal_uint16*)gif_resource.GCT; if(bg_index < (1 << (gif_dcb.gif_info.GCT_size+1))) { gif_dcb.gif_info.bg_color = gct_ptr[bg_index]; } else { gif_dcb.gif_info.bg_color = 0xFFFF; //dbg_print("!!!!Background index exceed the size of GCT!!!!\r\n"); } if(status & (GIF_STATUS_FINISH_FRMAE |GIF_STATUS_FINISH_FILE)) // one frame { if(status & GIF_STATUS_FINISH_FILE) { //dbg_print("HW file finish!\r\n"); return GIF_LAST_FRAME; } else { //dbg_print("HW frame finish!\r\n"); return GIF_FINISH_FRAME; } } else if(status & GIF_STATUS_END) // truncated gif file { //ASSERT(0); return GIF_TRUNCATED_FILE; } else if(gif_dcb.is_timeout) // hw decoder failed to decode the gif file { //ASSERT(0); return GIF_DECODE_TIMEOUT; } //ASSERT(0); return GIF_FORMAT_ERROR;
/***************************************************************************** * FUNCTION * gmiWriteToDSP * DESCRIPTION * This function is the call-back function of GPT for playing notes. *****************************************************************************/ static void gmiWriteToDSP( void *data ) { GMI_Note *note; uint16 I; uint32 curtime; uint32 note_time; uint32 next_time; uint16 rb_count_org; rb_count_org = RB_Count(); curtime = (uint32)(QTMF_COUNTER - gmi.start_time); next_time = curtime; while( !RB_Empty() ) { note = RB_Peek(); note_time = gmi.note_time + note->delta_time; if( note_time > next_time ) { next_time = note_time; } else if( note_time < curtime ) { RB_Consume(); gmi.note_time = note_time; continue; } /* search for the first available DSP tone */ for( I = 0; I < MAX_DPRAM_BUFFER; I++ ) { #if defined(MT6205) if( QTMF_DURA(I) == 0 && gmi.dsp_time[I] <= note_time ) { #else if( QTMF_DURA(I) == 0 ) { #endif QTMF_FREQ(I) = Pitch2Frequency[ note->pitch ]; QTMF_AMP(I) = (uint16)note->amplitude; QTMF_DURA(I) = note->duration << 4; /* QTMF_DURA(I) = (note->duration << 4) + ((note->timbre >> 3) & 0x0F ); */ QTMF_TIME(I) = (uint16)note_time + gmi.start_time; gmi.dsp_time[I] = note_time + note->duration; if( gmi.end_time < gmi.dsp_time[I] ) gmi.end_time = gmi.dsp_time[I]; RB_Consume(); gmi.note_time = note_time; break; } } if( I == MAX_DPRAM_BUFFER ) break; } switch( gmi.state ) { case GMI_STATE_INIT: QTMF_CONTROL = 3; gmi.state = GMI_STATE_PLAY; break; case GMI_STATE_PLAY: if( rb_count_org >= GMI_RB_SIZE/2 && RB_Count() < GMI_RB_SIZE/2 ) L1Audio_SetEvent( gmi.aud_id, (void*)GMI_NOTE_REQUEST ); if( gmi.eof_flag ) gmi.state = GMI_STATE_DATA_COMPLETE; break; case GMI_STATE_DATA_COMPLETE: if( RB_Empty() ) { GPTI_StartItem( gmi.gpt, (gmi.end_time - curtime + 5) * 2, gmiTerminate, 0 ); return; } break; } if( next_time > curtime ) next_time = next_time - curtime; else next_time = 1; GPTI_StartItem( gmi.gpt, next_time, gmiWriteToDSP, 0 ); } /***************************************************************************** * FUNCTION * GMI_Play * DESCRIPTION * This function is used to start melody playing. * * PARAMETERS * gmi_handler - a call back function used to be notified an event that * the end of a song is reached. *****************************************************************************/ void GMI_Play( void (*gmi_handler)( GMI_Event event ) ) { int16 I; if( L1Audio_CheckFlag( gmi.aud_id ) ) return; if( gmi_handler == 0 ) return; if( gmi.state != GMI_STATE_IDLE ) return; L1Audio_SetFlag( gmi.aud_id ); GPTI_StopItem( gmi.gpt ); for( I = 0; I < MAX_DPRAM_BUFFER; I++ ) { gmi.dsp_time[I] = 0; QTMF_DURA(I) = 0; } gmi.rb_head = 0; gmi.rb_tail = 0; gmi.mmi_time = 0; gmi.start_time = QTMF_COUNTER; gmi.end_time = 0; gmi.state = GMI_STATE_INIT; gmi.note_time = 0; gmi.eof_flag = false; gmi.gmi_handler = gmi_handler; gmi.gmi_handler( GMI_NOTE_REQUEST ); AM_MelodyOn(); gmiWriteToDSP( 0 ); } /* end of gmiPlay */