コード例 #1
0
ファイル: tick.c プロジェクト: Saladan/robolib
int main (void) {
  // initialize system
  system_init();

  // endless loop
  while (1) {
    // current time
    uint16_t time;
    uint8_t  minutes;
    uint8_t  seconds;

    // update current time
    time = tick_get();
    minutes = tick_tomin(time);
    seconds = tick_tosec(time);


    // print result to uart0
    string_from_const(uart0_send, "current time - ");
    string_from_uint (uart0_send, minutes, 2);
    string_from_const(uart0_send, ":");
    string_from_uint (uart0_send, seconds, 2);
    string_from_const(uart0_send, "\r\n");

    // wait for 0.25 seconds
    tick_delay(250);
  }

  return (0);
}
コード例 #2
0
ファイル: time.c プロジェクト: richard-nellist/idl4k
void ndelay (unsigned long nsec)		/* delay in nano-seconds */
{
	u64 delta = usec_to_tick(nsec);		/* time to wait */

	delta /= 1000ull;			/* remember: nsec not usec ! */

	tick_delay (delta);			/* wait ... */
}
コード例 #3
0
int battery_charging(void)
{
    char	str[128];
    int i = 0, j = 5, first_up = 1;
    int sleep_val = 0;
    int tmp=-1, charging_percentage=-2;

#ifdef	CONFIG_UBI_SUPPORT    
    run_command ("ubi part system", 0);    
    run_command ("ubifsmount system", 0);
    //run_command ("ubifsls", 0);
#endif

    set_charging_mode(1);

    while(1)
    {
        if(!is_ac_connected())
        {
            printf("Ac adapter removed!!!\n");
            power_down();
            printf("Power Down!\n");
            hang();
        }
		//printf("33333333333333333333333\n");
        //if(powerkey_scan() || any_key_pressed())
        if (any_key_pressed())
        {
			if(sleep_val >= 7)
            {
                run_command("lcd bl on", 0);
            }
            sleep_val = 0;
        }
        if(powerkey_hold(1000))
        {
            return  0;
        } 

		if(j >= 5)
		{
			if(j >= 5) j = 0;
	        if(sleep_val++ < 7)
		    {
		        if(get_charging_status())
		        {
#ifdef	CONFIG_UBI_SUPPORT
		            sprintf(str, "ubifsload ${loadaddr} resource/battery_pic/%d.bmp", (bat_pic_num-1));
#else
		            sprintf(str, "nand read ${loadaddr} %x %x",
		                bat_pic_start+bat_pic_size*(bat_pic_num-1), bat_pic_size);
#endif
		            run_command(str, 0);
		            sprintf(str, "bmp display ${loadaddr} %d %d", bat_pic_x, bat_pic_y);
		            if(run_command(str, 0))
		        	{
		//						AsciiPrintf("Battery Charging...", 260, 200, 0x00ff00);
		//						AsciiPrintf("Press POWER will plug into the ANDROID world!", 130, 240, 0x00ff00);
					}
		            if(first_up)
		            {
		                run_command ("lcd bl on", 0);
		                first_up = 0;
		            }
		            if(tmp != 100)
		            {
		                tmp = charging_percentage = 100;
		                //lcd_printf("\b\b\b\b%3d% ", charging_percentage);
		            }
		        }
		        else
			    {
#ifdef	CONFIG_UBI_SUPPORT
			        sprintf(str, "ubifsload ${loadaddr} resource/battery_pic/%d.bmp", i);
#else
			        sprintf(str, "nand read ${loadaddr} %x %x",
			        bat_pic_start+bat_pic_size*i, bat_pic_size);
#endif
			        run_command(str, 0);
			        sprintf(str, "bmp display ${loadaddr} %d %d", bat_pic_x, bat_pic_y);
			        if(run_command(str, 0))
			    	{
			//						AsciiPrintf("Battery Charging...", 260, 200, 0x00ff00);
			//						AsciiPrintf("Press POWER will plug into the ANDROID world!", 130, 240, 0x00ff00);
					}
			        if(first_up)
			        {
			            run_command ("lcd bl on", 0);
			            first_up = 0;
			        }
			        
			        i = (i+1)%bat_pic_num;

			        charging_percentage = get_charging_percentage();
			        if(tmp != charging_percentage)
			        {
			            tmp = charging_percentage;
			            //lcd_printf("\b\b\b\b%3d% ", charging_percentage);
			        }
			    }
		        if(sleep_val >= 7)
		        {
		            tmp = -1;
		            run_command("lcd bl off", 0);
		        }
		    }
		}
		if(tick_delay(50))
        {
            return  1;
        }
		j++;
    }
}
コード例 #4
0
ファイル: time.c プロジェクト: richard-nellist/idl4k
void udelay (unsigned long usec)		/* delay in micro-seconds */
{
	u64 delta = usec_to_tick(usec);		/* time to wait */

	tick_delay (delta);			/* wait ... */
}