/*FUNCTION*------------------------------------------------------------- * * Function Name : Custom_Delay * PARAMS : Delay in msec * * Returned Value : none * Comments : * Starts a timer for specified number of msec, puts EFM in EM2 mode. * EFM will wake up when timer fires. * *END*-----------------------------------------------------------------*/ void Custom_Delay(A_UINT32 delay) { #if MQX_VERSION == (402) /* Install the timer */ if (MQX_OK != _lpt_install (0, delay*1000 , LPT_FLAG_CLOCK_SOURCE_LPO, 2, timer_wakeup_isr, TRUE)) { printf ("\nError during installation of timer interrupt!\n"); _task_block(); } /* Stop the timer */ _lpt_run (0, FALSE); /* start timer */ _lpt_run (CUSTOM_DELAY_TMR, TRUE); #else if (MQX_OK != hwtimer_init(&hwtimer2, &BSP_HWTIMER2_DEV, BSP_HWTIMER2_ID, (BSP_DEFAULT_MQX_HARDWARE_INTERRUPT_LEVEL_MAX + 1))) { printf ("\nError during installation of timer interrupt!\n"); _task_block(); } hwtimer_set_period(&hwtimer2, BSP_HWTIMER2_SOURCE_CLK, delay*1000); hwtimer_callback_reg(&hwtimer2,(HWTIMER_CALLBACK_FPTR)timer_wakeup_isr, NULL); /* Start hwtimer2*/ hwtimer_start(&hwtimer2); #endif /* Setting operation mode to LPM_OPERATION_MODE_SLEEP */ _lpm_set_operation_mode (LPM_OPERATION_MODE_STOP); /* Return to RUN mode */ _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN); if (CM_ERR_OK != _lpm_set_clock_configuration(BSP_CLOCK_CONFIGURATION_DEFAULT)) { printf("Cannot change clock configuration"); _task_block(); } }
/*TASK*----------------------------------------------------- * * Task Name : YaDa * Comments : * * *END*-----------------------------------------------------*/ void YaDa ( uint_32 initial_data ) { #ifdef _GUI_DBUG_ printf("\n----------MAIN&GUI_Task----------\n"); printf("\n---------- ----------\n"); printf("\n---------- ----------\n"); printf("\n---------- END ----------\n"); #endif UartLCD_init(); // uart initialization UartTouch_init(); flg_int(); // wk --> 初始化一些标志 ! spi2_dma_int(); // dsp2k60 spi2 初始化 YADA_70(PageStart); //必要的初始化后进入首页 delay_ms(1000); // wk -->test 延时1s delay_ms(4000); // wk -->test 延时4s,等待U盘启动完成 // YADA_E4(); // wk --> 屏幕校正 YADA_70(MenuTop); // 进入菜单首页 RefreshFlg = 0; //页面无刷新 SHELL_CONTEXT_PTR shell_ptr; shell_ptr = _mem_alloc_zero( sizeof( SHELL_CONTEXT )); _mem_set_type(shell_ptr, MEM_TYPE_SHELL_CONTEXT); uint_32 file_size; uchar status; /* wk @130401 --> 在 flash中 新建 sysset 用于系统变量保存 */ shell_ptr->ARGC = 2; shell_ptr->ARGV[0]="cd"; shell_ptr->ARGV[1]="f:\\"; Shell_cd(shell_ptr->ARGC, shell_ptr->ARGV); // shell_ptr->ARGC = 2; // shell_ptr->ARGV[0]="df_s"; shell_ptr->ARGV[1]="SYSSET"; //wk --> 注意:查找的文件名暂时必须要是大写 status=Shell_search_file_r1(shell_ptr->ARGC, shell_ptr->ARGV,&file_size); if(status==0) { // shell_ptr->ARGC = 2; // shell_ptr->ARGV[0]="mkdir"; shell_ptr->ARGV[1]="SYSSET"; Shell_mkdir(shell_ptr->ARGC, shell_ptr->ARGV); } _mem_free(shell_ptr); /* button1 into interrupt for shell or maingui task change */ GPIO_PIN_STRUCT pins_int[] = { BSP_BUTTON1 | GPIO_PIN_IRQ_RISING , GPIO_LIST_END }; MQX_FILE_PTR port_file4; /* 这是按键1 上升沿中断*/ port_file4 = fopen("gpio:read", (char_ptr) &pins_int ); ioctl(port_file4, GPIO_IOCTL_SET_IRQ_FUNCTION, (pointer)int_callback); /* end */ /* wk @130330 -->timer of lpt */ /* wk @130504 --> 调试事件,先关闭 */ _lpt_install (0,3 * 1000000 , LPT_FLAG_CLOCK_SOURCE_LPO, 11, timer_isr, TRUE);//3 * 1000000 --> 3秒 /* wk @130330 -->timer end */ // delay_ms(4000); _rtc_init ( RTC_INIT_FLAG_CLEAR); // wk @130510 --> 在应用程序中再初始化并打开 _rtc_init ( RTC_INIT_FLAG_ENABLE); /* wk@130511-->程序有时可能因为此处影响触摸屏的应用 */ // TimeSet(); while(1) { if(SysFlashData[5]) //背光标志,1为开背光,0为关。 { YADA_5F(0x3f); //背光全开 } else { YADA_5F(0x08); //背光部分开 } MainLoop(); //循环主程序 } }