Exemplo n.º 1
0
/******************************************************
 * FunctionName : user_application
 * Description  : 用户APP程序段
 * Parameters   : none
 * Returns      : none
******************************************************/
void user_application()
{
	char buf[64];
	memset(buf,0,64);
	memcpy(buf,"Hello EEPROM..\n",15);
	EEPROM_SectorErase(0);  //擦除扇区0
	EEPROM_write(0,buf,15); //写EEPROM
	delay_ms(2000);  //延时
	memset(buf,0,64); //清空buf
	EEPROM_read(0,buf,15); //读取EEPROM
	UartwriteStr(buf,0);  //通过串口发送读取内容
	while(true)
	{
	}
}
Exemplo n.º 2
0
void main()
{
	u8 time_counter_for_cycle = 4;
    disable_all_interrupt();
	//设置输出口、中断
	require_delay_init();
	InitUart();
	init_system_component();
	//初始化端口
	P33 = 0;
	enable_all_interrupt();
	//检测当前状态
	detect_current_state();
    while(1) {
    	// Feed dog
    	reset_watch_dog();
    	// 驱动灯光开关
 //   	toggle_once();
   		// 5ms system tick-tock
    	if (INT_PROC & TICK_DUTY) {
    		cycle_based_adjust(counter_for_cycle);
            INT_PROC &= ~TICK_DUTY;
 //   		continue;
    	}

    	if (INT_PROC & EXINT_PROC) {
            EX0 = 0;
 //           SendData(time_counter>>8);
 //           SendData(time_counter);
    		if(time_counter <= 80)
            {
    			if(display_mode_set == combination)
                {
                    -- time_counter_for_cycle;
                }
                // 循环四次跳至下一个功能
                if(!time_counter_for_cycle)
                {
                    display_mode_logic++;
                    time_counter_for_cycle = 4;
                }
                if(display_mode_logic == 13)
                    display_mode_logic = 1;
 //               SendData(display_mode_logic);
                display_mode_set_changed();
            }
            if(display_mode_set == bi_directional_storbing)
    		{
    			if(time_counter >= 4000 && time_counter < 20000){
    				display_mode_logic ++;
                    if(display_mode_logic == 13)
                        display_mode_logic = 1;
                }
    			if(time_counter >= 40000)
    				display_mode_logic = 2;
                EEPROM_SectorErase(IAP_ADDRESS);
    			EEPROM_write(IAP_ADDRESS, display_mode_logic);
//                SendData(display_mode_logic);
    			display_mode_set_changed();
    		}
    		time_counter = 0;
    		INT_PROC &= ~EXINT_PROC;
            EX0 = 1;
    		continue;
    	}
    }
}