Esempio n. 1
0
static void SetKeyBoard()
{
	char str[]=" 1.按键音开启"
			  " 2.按键音关闭";
	int select;
	uchar DateBuf;
	BROWINFO bi;
	bi.lPtr = 0;
	bi.cPtr = 0;
	bi.iStr = str;
	while(1)
	{
	   DispStr_CE(0,1,"按键音设置菜单",DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
	   bi.mInt=2;//显示总行数
	   bi.lineMax=13;//每行显示最大字符数 
	   bi.startLine=3;//起始行 
	   bi.dispLines=2;//
	   bi.sFont=0;	//0 -大字体
	   bi.numEnable=1;//是否允许键盘方向键 1-允许
	   bi.qEvent=(EXIT_KEY_F1);
	   bi.autoexit =120;
		 
	   select=EXT_Brow_Select(&bi);
	   switch(select)
	   {
		  case 0:
				DateBuf=1;
			   G_KeySound=1;
			   KEY_Init(KEY_BEEP_KEY|KEY_AUTO_EL_ON);
			   WriteParameter(E_KeySondAddr,&DateBuf,1);
			   DispStr_CE(0,4,"按键音已开启",DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
			   delay_and_wait_key (DISP_OK_DELAY_TIME,EXIT_KEY_F1,120);
			   WaringBeep(OK_WARNING_BEEP);
			   break;
		  case 1:
			   DateBuf=0;
			   G_KeySound=0;
			   KEY_Init(KEY_AUTO_EL_ON);
			   WriteParameter(E_KeySondAddr,&DateBuf,1);
			   DispStr_CE(0,4,"按键音已关闭",DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
			   delay_and_wait_key (DISP_OK_DELAY_TIME,EXIT_KEY_F1,120);
			   WaringBeep(OK_WARNING_BEEP);
			   break;
		  default :
			   return;
	   }
	 }
}
Esempio n. 2
0
int main(void)
{	 
	delay_init();	    	//???????	  
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); 	//??NVIC????2:2??????,2??????
	uart_init(115200);	 	//??????115200
 	LED_Init();			    //LED?????
	TFTLCD_Init();			//LCD???	
	KEY_Init();	 			//?????
ctp_dev.init();		//??????
	FSMC_SRAM_Init();		//???SRAM
	TIM3_Int_Init(999,71);	//1KHZ ???1ms 
	TIM6_Int_Init(999,719);	//10ms??
	my_mem_init(SRAMIN); 		//????????
	my_mem_init(SRAMEX);  		//????????
	
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC,ENABLE);//??CRC??,??STemWin???? 

	GUI_Init();
	WM_SetCreateFlags(WM_CF_MEMDEV);
	
	GUI_Init();//???????? demo???????? ?????????  

  startUp_Window(); //??????
while(1);

	
}
Esempio n. 3
0
int main(void)
{
	Disp_Init(DISP_INIT_ON);		//初始化 LCD
	Disp_Clear();				
	
	KEY_Init(KEY_BEEP_KEY|KEY_AUTO_EL_ON);	//初始化 Keyborad
	KEY_Beep_Mask_Set(0xffffffff);			
	KEY_EL_Mask_Set(0xffffffff);
	EL_Set_Timeout(20);			//定时关闭背光灯
	Sys_Auto_Poweroff_Set(60*2);		//定时待机
	
	//Meanless for 0218/0318/0518
	Disp_Icon_Battery_Time_Set(1,ICON_AT_TAIL);
	Disp_Icon_Battery_Time_Refresh();
	Disp_Set_Color(SET_FONT_COLOR, 0x0000);		//黑
	Disp_Set_Color(SET_BACK_COLOR, 0xFFFF);		//白
	Disp_Set_Color(SET_SELECT_COLOR, 0x07E0);	//绿
	Disp_Set_Color(SET_CLEAR_COLOR, 0xFFFF);	//白

	adminPsd_init();	//一次性初始化,数据初置
	db_check();	//数据库检查
	//wifiInit_open();	//wifi初始化
	main_task();
	return 0;
}
Esempio n. 4
0
//ALIENTEK战舰STM32开发板实验3
//按键输入实验  
//技术支持:www.openedv.com
//广州市星翼电子科技有限公司 	 
 int main(void)
 {
 	u8 t;
	delay_init();	    	 //延时函数初始化	  
 	LED_Init();			     //LED端口初始化
	KEY_Init();              //初始化与按键连接的硬件接口
	BEEP_Init();         	 //初始化蜂鸣器端口
	LED0=0;					 //先点亮红灯
	while(1)
	{
 		t=KEY_Scan(0);		//得到键值
	   	if(t)
		{						   
			switch(t)
			{				 
				case KEY_UP:	//控制蜂鸣器
					LED4=!LED4;
					LED1=!LED1;
					LED2=!LED2;
					LED3=!LED3;
					break;
				case KEY_LEFT:	//控制LED0翻转
					LED1=!LED1;
					break;
				case KEY_DOWN:	//控制LED1翻转	 
					LED2=!LED2;
					break;
				case KEY_RIGHT:	//同时控制LED0,LED1翻转 
					LED3=!LED3;
					break;
			}
		}else delay_ms(10); 
	}	 
 }
Esempio n. 5
0
int main(void)
{
	u8 key;
	delay_init(168);
	LED_Init();
	KEY_Init();

	LED0 = 1;
	while(1)
		{
			key = KEY_Scan(0);
			if(key)
				{
					switch ( key)
					{
					    case 1:
					        LED0 = !LED0;
					        break;
					    default:
					        break;
					}
				}
		}
	
}
Esempio n. 6
0
int main(void)
{
	u8 key;
	Stm32_Clock_Init(336,8,2,7);
	delay_init(168);
	LED_Init();
	BEEP_Init();
	KEY_Init();
	LED0 = 0;	//点亮红灯
	
	while(1)
	{
		key = KEY_Scan(0);
//		key = KEY_Scan_Custom(0);
		if(key)//有按键按下
		{
			switch(key)
			{
				case WKUP_PRES: BEEP = !BEEP;break;
				case KEY2_PRES: LED0 = !LED0;break;
				case KEY1_PRES: LED1 = ~LED1;break;
				case KEY0_PRES: LED1 = !LED1; LED0 = !LED0;break;
			}
		}
		else
			delay_ms(10);
	}
	
}
Esempio n. 7
0
void EXTIX_Init(void)
{
    EXTI_InitTypeDef EXTI_INITSTRUCT;
    NVIC_InitTypeDef NVIC_Initstruct;
    EXTI_INITSTRUCT.EXTI_Line=EXTI_Line4;
    EXTI_INITSTRUCT.EXTI_LineCmd=ENABLE;
    EXTI_INITSTRUCT.EXTI_Mode=EXTI_Mode_Interrupt;
    EXTI_INITSTRUCT.EXTI_Trigger=EXTI_Trigger_Falling;
    
    
    NVIC_Initstruct.NVIC_IRQChannel=EXTI4_IRQn;
    NVIC_Initstruct.NVIC_IRQChannelCmd=ENABLE;
    NVIC_Initstruct.NVIC_IRQChannelPreemptionPriority=3;
    NVIC_Initstruct.NVIC_IRQChannelSubPriority=3;
    
    //STEP1:
    KEY_Init();//init GPIOx
    //STEP2:    enable AFIO
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
    //STEP3:
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource4);
    //STEP4:
    EXTI_Init(&EXTI_INITSTRUCT);
    //STEP5:
    NVIC_Init(&NVIC_Initstruct);
 
}
Esempio n. 8
0
/***********************************************************************
  * @brief  Initialise the resource for count.
  * @param  None
  * @retval None
************************************************************************/
void key_event_handler(void * p_event_data, uint16_t event_size)
{
	key_event_t * key_event_tmp = p_event_data;
	
	switch(key_event_tmp->eKey_event)
	{
		case KEY_INIT:
			KEY_Init();
			break;

		case KEY_HANDLE:
			#ifdef KEY_DEBUG
				printf("[KEY] KEY_HANDLE...\r\n");
			#endif
			if(key_is_pressed)
			{
				if(DataMem_GetTopGas() < REMAIN_GAS_MIN)
				{
					beeper_event.eBeeper_event = BEEPER;
					beeper_event.beeper_times = BEEPER_TIMES_REMEAN_GAS_LOW;
					app_sched_event_put(&beeper_event,sizeof(beeper_event),beeper_event_handler);
				}
				
				lcd_event.eLcd_event = LCD_DISPLAY_REMAIN_GAS;
            	app_sched_event_put(&lcd_event,sizeof(lcd_event),lcd_event_handler);

				key_is_pressed = 0;
			}
			break;
			
		default:
			break;
	}
}
Esempio n. 9
0
void EXTIX_Init(void)
{

	EXTI_InitTypeDef EXTI_InitStructure;
	NVIC_InitTypeDef NVIC_InitStructure;
	
	KEY_Init();				//IO口初始化
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);	//打开AFIO时钟以操作中断配置寄存器?
	GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource13);	//PC3 映射到中断线EXTI13上
	GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource0);		//PE0 映射到中断线exti0上
	
	
//初始化外部中断线
	EXTI_InitStructure.EXTI_Line = 0x2000;	//使用线路为:13,
	EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;	//中断
	EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;	//下降沿
	EXTI_InitStructure.EXTI_LineCmd = ENABLE;
	EXTI_Init(&EXTI_InitStructure);
	
	EXTI_InitStructure.EXTI_Line = EXTI_Line0;	//使用线路为:0,
	EXTI_Init(&EXTI_InitStructure);
	
	//=设置中断优先级
	NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;	//外部中断线15-10中断
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
	NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&NVIC_InitStructure);
	
	NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;	//外部中断线0中断
	NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;	
	NVIC_Init(&NVIC_InitStructure);
}
Esempio n. 10
0
int main(void)
{
	delay_init();	    	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); 
	uart_init(115200);	 //串口初始化为115200
	Uart2_Init(115200);
	OLED_Init();
	LED_Init();
	OLED_Clear(); 	
	KEY_Init();//IO初始化
	TIM3_Int_Init(499,7199);//10Khz的计数频率,计数到500为50ms  
	NET_Init();
	ConnectToDevice();
	delay_ms(300);
	LED2 = 0;
	delay_ms(100);
	LED2 = 1;
	EEPROM_Init();
	// ReadLedStatusFromFlash();
	StartToUploadFlag = 1;
	while(1) 
	{		
		MainMenuIntoSubMenu();
		SwitchDetect();
	}
}
/*******************************************************************************
 * @fn      userAppInit
 *
 * @brief   user Application init
 *
 * @param   void
 *
 * @return  none
 */
void userAppInit(void)
{
	OLED_Init();
// 电池状态读初始化I2C	
    SMB_Init(); 
// 串口初始化	
	bspUartInit();  
	
// 按键初始化要等系统稳定后,防止外部中断引起系统死机
	KEY_Init();

//电池状态检测初始化
	chargeDetection_Init();

	//OLED_ShowString(40,32, "WiCore"); 
	OLED_Clear();
	
	// Create one-shot clocks for internal periodic events.
	Util_constructClock(&periodicClock_10ms, userApp_clockHandler,
	                  10, 0, false, USER_10MS_EVT);
#ifndef INCLUDE_CLKSTOP	
	systemState.powerOffFlag = 1;
	Util_startClock(&periodicClock_10ms);
#else
	Util_stopClock(&periodicClock_10ms);

#endif	
}
Esempio n. 12
0
/**
  * @brief  使用esp8266模块和EDP协议向ONENET平台发送开发板四个LED指示灯的实时状态,并通过平台或者开发板按键控制LED。
**/
int main(void)
{	
		//SystemInit();
		LED_Init();    //LED指示灯初始化函数
		KEY_Init();	   //按键初始化函数
		USART1_Init(); //USART1串口初始化函数
		USART2_Init(); //USART2串口初始化函数
		while(1)
		{		
				LED_Switch(LED_ON,LED_R|LED_G|LED_Y|LED_B);	   //点亮开发板四个指示灯,表示程序进入主流程
				ESP8266_Init();    //ESP8266初始化
				ESP8266_DevLink(DEVICEID,APIKEY,20);    //和平台建立设备连接
				LED_Switch(LED_OFF,LED_R|LED_G|LED_Y|LED_B); //熄灭开发板四个指示灯,表示程序完成设备连接,进入数据发送循环
			
				while(1)
				{								
						if(!(ESP8266_CheckStatus(30)))    //检测ESP8266模块连接状态
						{
								ESP8266_SendDat();     //向平台发送数据
						}
						else
						{
								break;
						}
				}
		}	
}
Esempio n. 13
0
  int main(void)
 {
	 u8 t=0;	
	 u16 Time=0,dis_pre=0;
	 float V_ave;	//平均速度
	 char code_ave[5],code_v[5],code_vr[5], mileage[5];//信息储存数组
	 
	delay_init(72);	    	 			//延时函数初始化	  
	Stm32_Clock_Init(9);		  //系统时钟设置
	uart_init(72,9600);	 	 		  //串口初始化为9600
	usmart_dev.init(72);			//初始化USMART	
	EXTIX_Init();							//外部中断初始化
	TIM3_Int_Init(5000,7199); //10Khz的计数频率,计数到5000为500ms 
	LCD_Init();				 				//  PE.ALL,PD1~5  
	LCD_Display_Dir(1);				//设置显示方向为横屏显示
	LED_Init();		  					//初始化与LED连接的硬件接口
	KEY_Init();								//初始化按键

		while(RTC_Init())
		{	//等待RTC初始化
			delay_ms(200);
			printf("rtc waiting```\r\n");
		} 
		printf("finish\n");
		display_jing();
		//初始化完成
   while(1)
	{	
		POINT_COLOR=RED;
		if(t!=calendar.sec)		//时间更新后显示新时间
		{
				t=calendar.sec;	
				LCD_ShowNum(200,135,calendar.min,2,32);		
				LCD_ShowString(230,135,200,32,32,":");			
				LCD_ShowNum(248,135,calendar.sec,2,32);
			
				Time = 60*calendar.min+calendar.sec;//比赛用时
				if(dis_pre != quanshu_tenfold)			//有位移变化
				{
					V_ave=(0.154*quanshu_tenfold)/Time;
					dis_pre = quanshu_tenfold;
					sprintf(code_ave,"%.2f",V_ave);	
					LCD_ShowString(100,200,200,32,32,code_ave);//修改一下位置
					
				}
		}
			
		sprintf(code_v,"%.2f",V);					//float 转 字符串  
		LCD_ShowString(365,275,200,32,32,code_v);		//速度
		
		sprintf(code_vr,"%d",V_RPM);					//float 转 字符串  
		LCD_ShowString(365,275,200,32,32,code_vr);		//转速
 
		sprintf(mileage,"%.2f",0.154*quanshu_tenfold);
		LCD_ShowString(250,225,200,24,32,mileage);	//里程
		
	  display_dong(V_RPM,V,50);
		delay_ms(300);
	}
 }
Esempio n. 14
0
/*
-------------------------------------------------------------------------
*  函数名称:
*  函数功能:
*  输入形参:  	
*  返回值:		 	
---------------------------------------------------------------------------
*/
void Board_Init(void)
{	
	u8 i;	
	//系统时钟配置 									   
	SystemInit();
	//延时函数初始化		   	
	delay_init(72);
	//定时器1初始化		 
	TIM1_config();
  	//舵机初始化
	Motor_Init(); 	
	Servo_Init();
	//串口配置
	USART_Config();	
	//串口中断配置   	
	NVIC_Config();
	//LED初始化		
	LED_Init();
	//按键初始化				
	KEY_Init();	 
	//等待电调中间值确定	
	for(i=0;i<3;i++)	
	{
		delay_ms(1000);
	}   	
}
Esempio n. 15
0
//主函数
int main(void)
{
	OS_ERR err;
	CPU_SR_ALLOC();
	
	delay_init(168);  //时钟初始化
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//中断分组配置
	uart_init(115200);   //串口初始化
	LED_Init();         //LED初始化	
	LCD_Init();			//LCD初始化	
	KEY_Init();			//按键初始化
	BEEP_Init();		//初始化蜂鸣器
	FSMC_SRAM_Init();	//初始化SRAM
	my_mem_init(SRAMIN);//初始化内部RAM
	ucos_load_main_ui();//加载主UI
	
	OSInit(&err);		    //初始化UCOSIII
	OS_CRITICAL_ENTER();	//进入临界区			 
	//创建开始任务
	OSTaskCreate((OS_TCB 	* )&StartTaskTCB,		//任务控制块
				 (CPU_CHAR	* )"start task", 		//任务名字
                 (OS_TASK_PTR )start_task, 			//任务函数
                 (void		* )0,					//传递给任务函数的参数
                 (OS_PRIO	  )START_TASK_PRIO,     //任务优先级
                 (CPU_STK   * )&START_TASK_STK[0],	//任务堆栈基地址
                 (CPU_STK_SIZE)START_STK_SIZE/10,	//任务堆栈深度限位
                 (CPU_STK_SIZE)START_STK_SIZE,		//任务堆栈大小
                 (OS_MSG_QTY  )0,					//任务内部消息队列能够接收的最大消息数目,为0时禁止接收消息
                 (OS_TICK	  )0,					//当使能时间片轮转时的时间片长度,为0时为默认长度,
                 (void   	* )0,					//用户补充的存储区
                 (OS_OPT      )OS_OPT_TASK_STK_CHK|OS_OPT_TASK_STK_CLR, //任务选项
                 (OS_ERR 	* )&err);				//存放该函数错误时的返回值
	OS_CRITICAL_EXIT();	//退出临界区	 
	OSStart(&err);      //开启UCOSIII
}
Esempio n. 16
0
void main(void)
{
    u16 trigpos;
    u8 keycode;
    
    SystemState = AutoRunMode;
    // 现在还是使用软件触发
	  ADCState = Triggered;       // ADCState = WaitTrigger;

    CLK_Init();                 // 主时钟初始化
    TIM4_Init();                // TIM4 用于产生系统运行需要的定时信号
    KEY_Init();                 // 按键驱动初始化
    KeyParse_Init();            // 按键处理模块初始化
    LCD_Init();                 // LCD驱动初始化
    WDraw_Init();               // 波形显示模块初始化
    TriggerInterruptInit();     // 外部触发中断初始化
    ADC_Init();                 // ADC采样程控模块初始化
    DProc_Init();               // 数据处理模块初始化
  

    enableInterrupts();

    /* Infinite loop */
    while (1)
    {
    
				if(flag_10ms_ok)
        {
            flag_10ms_ok = 0;
            keycode = KEY_Scan();
						switch(GET_KTYPE(keycode))
            {
                case KTYPE_NORMAL:
                    KeyParse(GET_KCODE(keycode));
                default:
                    break;
            }
        }
        switch(SystemState)
        {
            // to do
            case AutoRunMode:
            case ManualMode:
                //  处理数据
                if( ADCState == ADC_Buffer_Full )
                {
                    trigpos = GetTriggerPostion(0, 64);
                    WDraw_DisplayUpdate(&ADC_Buffer[trigpos]);
                    ADCState = Triggered;
                    ADC_Index = 0;
                }
                break;
            default:
                break;
        }
		
		}
  
}
Esempio n. 17
0
/*****************************************************************************
 Function    : LOS_EvbKeyInit
 Description : Init GIOP Key 
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
void LOS_EvbKeyInit(void)
{   
    //add you code here.
#ifdef LOS_MM32L073PF 
    KEY_Init();
#endif  
    return ;
}
Esempio n. 18
0
 int main(void)
 { 
	u16 i,rxlen;
	u16 lenx;
	u8 key=0XFF;
	u8 upload=0;
	delay_init();	    	 //延时函数初始化	  
	uart_init(38400);	 	//串口初始化为9600
	USART2_Init(38400);	//初始化串口2
	LED_Init();				//初始化与LED连接的硬件接口
	KEY_Init();				//初始化与LED连接的硬件接口
   LCD_Init();				//初始化LCD
 	POINT_COLOR=RED;
	LCD_ShowString(30,20,200,16,16,"ALIENTEK STM32 ^_^");	
	LCD_ShowString(30,40,200,16,16,"NE0-6M GPS TEST");	
	LCD_ShowString(30,60,200,16,16,"ATOM@ALIENTEK");
	LCD_ShowString(30,80,200,16,16,"KEY0:Upload NMEA Data SW");   	 										   	   
   	LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:OFF");   
	if(Ublox_Cfg_Rate(1000,1)!=0)	//设置定位信息更新速度为1000ms,顺便判断GPS模块是否在位. 
	{
   		LCD_ShowString(30,120,200,16,16,"NEO-6M Setting...");
		while((Ublox_Cfg_Rate(1000,1)!=0)&&key)	//持续判断,直到可以检查到NEO-6M,且数据保存成功
		{
			USART2_Init(9600);				//初始化串口2波特率为9600(EEPROM没有保存数据的时候,波特率为9600.)
	  		Ublox_Cfg_Prt(38400);			//重新设置模块的波特率为38400
			USART2_Init(38400);				//初始化串口2波特率为38400 
			Ublox_Cfg_Tp(1000000,100000,1);	//设置PPS为1秒钟输出1次,脉冲宽度为100ms	    
			key=Ublox_Cfg_Cfg_Save();		//保存配置  
		}	  					 
	   	LCD_ShowString(30,120,200,16,16,"NEO-6M Set Done!!");
		delay_ms(500);
		LCD_Fill(30,120,30+200,120+16,WHITE);//清除显示 
	}
	while(1) 
	{		
		delay_ms(1);
		if(USART2_RX_STA&0X8000)		//接收到一次数据了
		{
			rxlen=USART2_RX_STA&0X7FFF;	//得到数据长度
			for(i=0;i<rxlen;i++)USART1_TX_BUF[i]=USART2_RX_BUF[i];	   
 			USART2_RX_STA=0;		   	//启动下一次接收
			USART1_TX_BUF[i]=0;			//自动添加结束符
			GPS_Analysis(&gpsx,(u8*)USART1_TX_BUF);//分析字符串
			Gps_Msg_Show();				//显示信息	
			if(upload)printf("\r\n%s\r\n",USART1_TX_BUF);//发送接收到的数据到串口1
 		}
		key=KEY_Scan(0);
		if(key==KEY0_PRES)
		{
			upload=!upload;
			POINT_COLOR=RED;
			if(upload)LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:ON ");
			else LCD_ShowString(30,100,200,16,16,"NMEA Data Upload:OFF");
 		}
		if((lenx%500)==0)LED0=!LED0; 	    				 
		lenx++;	
	}											    
}	
Esempio n. 19
0
 int main(void)
 {
	u8 key;
	u16 i=0;
	u8 datatemp[SIZE];
 	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
 	uart_init(9600);
 	LED_Init();
 	KEY_Init();
	LCD_Init();
	AT24CXX_Init();		//IIC初始化 
	POINT_COLOR=RED;//设置字体为蓝色	   
	LCD_ShowString(60,50,"Mini STM32");	
	LCD_ShowString(60,70,"IIC TEST");	
	LCD_ShowString(60,90,"ATOM@ALIENTEK");
	LCD_ShowString(60,110,"2011/1/1");			 
	while(AT24CXX_Check())//检测不到24c02
	{
		LCD_ShowString(60,130,"24C02 Check Failed!");
		delay_ms(500);
		LCD_ShowString(60,130,"Please Check!      ");
		delay_ms(500);
		LED0=!LED0;//DS0闪烁
	}
	LCD_ShowString(60,130,"24C02 Ready!");
	//显示提示信息
	LCD_ShowString(60,150,"KEY0:Write KEY2(WK_UP):Read");

	POINT_COLOR=BLUE;//设置字体为蓝色	  
	while(1)
	{
		key=KEY_Scan();
		if(key==1)//KEY0按下,写入24C02
		{
			LCD_Fill(0,170,239,319,WHITE);//清除半屏    
 			LCD_ShowString(60,170,"Start Write 24C02....");
			AT24CXX_Write(0,(u8*)TEXT_Buffer,SIZE);
			LCD_ShowString(60,170,"24C02 Write Finished!");//提示传送完成
		}
		if(key==3)//KEY_UP按下,读取字符串并显示
		{
 			LCD_ShowString(60,170,"Start Read 24C02.... ");
			AT24CXX_Read(0,datatemp,SIZE);
			LCD_ShowString(60,170,"The Data Readed Is:  ");//提示传送完成
			LCD_ShowString(60,190,datatemp);//显示读到的字符串
		}
		i++;
		delay_ms(10);
		if(i==20)
		{
			LED0=!LED0;//提示系统正在运行	
			i=0;
		}		   
	}
 }
Esempio n. 20
0
 int main(void)
 {
 	 char main_str[10];
	 Disp_Init(DISP_INIT_ON);//显示初始化 ,打开显示
	 if(3000 > SYS_Read_Vol())
	 {
		 DispStr_E(0,16,"电量过低",DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
		 Sys_Delay_MS(1000);
		 Sys_Power_Sleep(2);
	 }
	 ReadParameter();//参数初始化
	 Disp_Set_Color(SET_BACK_COLOR,G_BackColor);//背景设置 浅蓝 
	 Disp_Set_Color(SET_CLEAR_COLOR,G_BackColor);//G_BackColor
	 Disp_Set_Color(SET_FONT_COLOR,G_FontColor);//前景颜色
	 Disp_Set_Color(SET_SELECT_COLOR,G_ThemeColor);//主题颜色
	 Sys_Auto_Poweroff_Set((ushort)G_AutoSleep);//30秒自动关机
	 EL_Set_Timeout((ushort)G_AutoElClose);//背光灯自动关闭时间7秒 
	 //WatchDog_Set(25);	//设置看门狗 
	 if(G_KeySound)
	 {
		 KEY_Init(KEY_AUTO_EL_ON|KEY_BEEP_KEY);//按键初始化
	 }
	 else
	 {
		 KEY_Init(KEY_AUTO_EL_ON);//按键初始化
	 }
	 //WriteParameter(E_PassWordAddr,sss,3);
	 //WriteParameter(E_PassWordLenAddr,&ss,1);
	 if(KEY_Read()==KEY_F2)
	 {
		sprintf(main_str,"%s",G_PassWord);
		DispStr_CE(0,4,main_str,DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
		delay_and_wait_key (1,EXIT_KEY_F1,120);
	 }
	 if(G_PassWordStatus)
	 {
		 RunPassWord();
	 }
	 Disp_Icon_Battery_Time_Set(1,ICON_AT_TAIL);
	 CWiFi_SetMSGCallBack((WiFiMSG_CALLBACK)WiFi_MsgDisplay);//设置回调函数
	 Open_WifiModel();
	 Sys_main();
	 return 1;
 }
Esempio n. 21
0
 int main(void)
 {
	u8 key;
	u8 i=0;	
	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
 	uart_init(9600);
 	LED_Init();
 	KEY_Init();
	LCD_Init();

	POINT_COLOR=RED;//设置字体为蓝色	   
	LCD_ShowString(60,50,"Mini STM32");	
	LCD_ShowString(60,70,"TOUCH TEST");	
	LCD_ShowString(60,90,"ATOM@ALIENTEK");
	LCD_ShowString(60,110,"2011/1/1");	
	LCD_ShowString(60,130,"Press KEY0 to Adjust");	
	Touch_Init();
	delay_ms(1500);
	Load_Drow_Dialog();	  
	while(1)
	{	
	 	key=KEY_Scan();
		if(Pen_Point.Key_Sta==Key_Down)//触摸屏被按下
		{
			Pen_Int_Set(0);//关闭中断
			do
			{
				Convert_Pos();
				Pen_Point.Key_Sta=Key_Up;
				if(Pen_Point.X0>216&&Pen_Point.Y0<16)Load_Drow_Dialog();//清除
				else 
				{
					Draw_Big_Point(Pen_Point.X0,Pen_Point.Y0);//画图	    
					GPIOC->ODR|=1<<1;    //PC1 上拉	   
				}
			}while(PEN==0);//如果PEN一直有效,则一直执行
			Pen_Int_Set(1);//开启中断
		}else delay_ms(10);
		if(key==1)//KEY0按下,则执行校准程序
		{
			LCD_Clear(WHITE);//清屏
		    Touch_Adjust();  //屏幕校准 
			Save_Adjdata();	 
			Load_Drow_Dialog();
		}
		i++;
		if(i==20)
		{
			i=0;
			LED0=!LED0;
		}
	};	   
 }
Esempio n. 22
0
int main(void)
{
	u32 i = 0, j = 0;
	float distance = 0.0;
	float light = 0.0;
	
	//SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
	//SysTick_Config(72);
	
	delay_init();	    	   //延时函数初始化
	NVIC_Configuration();  //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
	TIM_Config();
	uart_init(115200);	 	 //串口初始化为115200
	KEY_Init();
 	LED_Init();			       //LED端口初始化
	SW_I2C_Init();
//	HW_I2C2_Init();

	Single_WriteI2C(SlaveAddress1, 0x02, 0x72);

	while(1)
	{
		distance = 0.0;
		light = 0.0;
		
		delay_ms(400);			
		
		// ks103测距
		if (distance_flag)
		{
			distance = Read_KS10X_Data(SlaveAddress1, 0xb0);
			printf("-%04d- distance: %04.3f  cm\r\n", i++, distance);
		}
		
		// ks103测光强
		if (light_flag)
		{
			light = Read_KS10X_Data(SlaveAddress1, 0xa0);
			printf("-%04d- light: %04.3f  cd\r\n", j++, light);
		}
		
		if (distance_flag | distance_flag)
			LED0 = !LED0;
/*
		t1 = tick;
		delay2x(1000);  // 延时167us
		t2 = tick;

		printf("time: %d us\r\n", t2 - t1);
*/
	}
}
Esempio n. 23
0
int main(void)
{
	u8 key,fontok=0; 
   	Stm32_Clock_Init(9);	//系统时钟设置
	delay_init(72);			//延时初始化
	uart_init(72,115200); 	//串口1初始化 
	LCD_Init();				//初始化液晶 
	LED_Init();         	//LED初始化	 
	KEY_Init();				//按键初始化	 
	usmart_dev.init(72);	//usmart初始化	
 	USART2_Init(36,115200);	//初始化串口2 
	TP_Init();				//初始化触摸屏
	mem_init(SRAMIN);		//初始化内部内存池	    
 	exfuns_init();			//为fatfs相关变量申请内存  
  	f_mount(0,fs[0]); 		//挂载SD卡 
	key=KEY_Scan(0);  
	if(key==KEY_RIGHT)		//强制校准
	{
		LCD_Clear(WHITE);	//清屏
		TP_Adjust();  		//屏幕校准 
		TP_Save_Adjdata();	  
		LCD_Clear(WHITE);	//清屏
	}
	fontok=font_init();		//检查字库是否OK
	if(fontok||key==KEY_DOWN)//需要更新字库				 
	{
		LCD_Clear(WHITE);		   	//清屏
 		POINT_COLOR=RED;			//设置字体为红色	   	   	  
		LCD_ShowString(60,50,200,16,16,"ALIENTEK STM32");
		while(SD_Initialize())		//检测SD卡
		{
			LCD_ShowString(60,70,200,16,16,"SD Card Failed!");
			delay_ms(200);
			LCD_Fill(60,70,200+60,70+16,WHITE);
			delay_ms(200);		    
		}								 						    
		LCD_ShowString(60,70,200,16,16,"SD Card OK");
		LCD_ShowString(60,90,200,16,16,"Font Updating...");
		key=update_font(20,110,16,0);//从SD卡更新
		while(key)//更新失败		
		{			 		  
			LCD_ShowString(60,110,200,16,16,"Font Update Failed!");
			delay_ms(200);
			LCD_Fill(20,110,200+20,110+16,WHITE);
			delay_ms(200);		       
		} 		  
		LCD_ShowString(60,110,200,16,16,"Font Update Success!");
		delay_ms(1500);	
		LCD_Clear(WHITE);//清屏	       
	}  
	sim900a_test();
}
Esempio n. 24
0
int main(void)
{
	EXTI_PE5_Init();
	KEY_Init();
	LED_Init();
	LED1(ON);
	LED2(ON);
	LED3(ON);
	while(1)
	{
		;
	}

}
Esempio n. 25
0
File: main.c Progetto: kenziD/ANO
int main(void)
{
    int dianya_fly = 0;
    SysTick_Init();
    Tim3_Init(500);
    Nvic_Init();
    LED_Init();
    ADC1_Init();
    USART1_Config(115200);
    KEY_Init();
    NRF24L01_Init();
    while (NRF24L01_Check())	//检查NRF24L01是否在位.要放在设置TX_MODE之前,否则设置的发送地址会变成check中的0XA5 ,将与原接收地址对不上
    {
        LED2_ON;
        LED1_OFF;
        printf("no");
    }
    LED1_ON;
    LED2_OFF;
    //TX mode
    //NRF24L01_TX_Mode();
    //NRF24L01_Mode_Config(2);

    //RX mode
    NRF24L01_Mode_Config(3);
    while (1)
    {
        key = KEY_scan();


        if (NRF24L01_RxPacket(tmp_buf) == 0)
        {
            NRF24L01_TxPacket_AP(rc_buf);
            LED1_ON;
            if(tmp_buf[0]==0x88 && tmp_buf[1]==0xAE && tmp_buf[2]==0x1C)
            {
                dianya_fly = tmp_buf[17]<<8|tmp_buf[18];
                if(dianya_fly<36 && dianya_fly>20)
                {
                    LED2_ON;
                }
            }
            send_wave(32,tmp_buf);
        }
        else
        {
            LED1_OFF;
        }
    }
}
Esempio n. 26
0
 int main(void)
 {  	
 	u32 sector_size;
	u8 t=0;	
	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
 	uart_init(9600);
 	LED_Init();
 	KEY_Init();
	LCD_Init();
	POINT_COLOR=RED;//设置字体为红色	   
	LCD_ShowString(60,50,"Mini STM32");	
	LCD_ShowString(60,70,"SD Card TEST");	
	LCD_ShowString(60,90,"ATOM@ALIENTEK");
	LCD_ShowString(60,110,"2011/1/1");				 
	while(SD_Initialize()!=0)//检测不到SD卡
	{
		LCD_ShowString(60,130,"SD Card Failed!");
		delay_ms(500);
		LCD_ShowString(60,130,"Please Check!      ");
		delay_ms(500);
		LED0=!LED0;//DS0闪烁
	}
	//检测SD卡成功 											    
	LCD_ShowString(60,130,"SD Card Checked OK ");
	sector_size=SD_GetSectorCount();
	printf(" SD Sector Size:%x\n",sector_size);
	LCD_ShowString(60,150,"SD Card Size:    Mb");
	LCD_ShowNum(164,150,sector_size>>12,4,16);
	while(1)
	{
		if(t==30)//每6s钟执行一次
		{
			if(SD_ReadDisk(buf,0,1)==0)//读取MBR扇区
			{	
				LCD_ShowString(60,170,"USART1 Sending Data...");
				printf("SECTOR 0 DATA:\n");
				for(sector_size=0;sector_size<512;sector_size++)printf("%x ",buf[sector_size]);//打印MBR扇区数据    	   
				printf("\nDATA ENDED\n");
				LCD_ShowString(60,170,"USART1 Send Data Over!");
			}
			t=0;
		}   
		t++;
		delay_ms(200);
		LED0=!LED0;
	}
}
Esempio n. 27
0
//各个外设的初始化
void Peripheral_Init(void)
{
	// 中断向量表配置
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	
	PS_Init();	
    KEY_Init();	
	STATU_Init();
	LED_Init();
	BEEP_Init();
    CAN1_Init();
	CAN2_Init();
    OLED_Init();
    ADC_Configuration();
}
Esempio n. 28
0
//Mini STM32开发板范例代码8
//PWM输出 实验
//正点原子@ALIENTEK
//技术论坛:www.openedv.com	 
 int main(void)
 {
	u16 led0pwmval=0;
	u8 dir=1;
	 u8 i;
	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
	uart_init(9600);
 	LED_Init();
	KEY_Init();          //按键初始化	
	PWM_Init(199,7199);	 //20ms的脉冲  一个脉2us 
	    while(1)
   {          
         TIM_SetCompare2(TIM3,5); 
         delay_ms(300);
         TIM_SetCompare2(TIM3,10); 
         delay_ms(300);
         TIM_SetCompare2(TIM3,15); 
         delay_ms(300);
         TIM_SetCompare2(TIM3,20); 
         delay_ms(300);//
		 
         TIM_SetCompare2(TIM3,15); 
         delay_ms(300);
				TIM_SetCompare2(TIM3,10); 
         delay_ms(300);
	
   }  
	 
	/*	while(1)
	{
 		delay_ms(10);	
			for(i=1;i<1000;i++)
			{
		if(dir)led0pwmval++;
		else led0pwmval--;
			}
		if(led0pwmval==10000)dir=0;	
 	//	if(led0pwmval>2500)led0pwmval=500;
		if(led0pwmval==0)dir=1;	
	
												 
		TIM_SetCompare2(TIM3,led0pwmval);	   
	}	 
	*/

 }
Esempio n. 29
0
/* user main function, called by AppFramework after system init done && wifi
 * station on in user_main thread.
 */
OSStatus user_main( app_context_t * const app_context )
{
    OSStatus err = kNoErr;
    int time_sencond = 50*1000;  /* 60s */


    require(app_context, exit);
    net_init(app_context);

    /* Create a new thread */

    err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "RGB_LED", LED_handleThread, 1024, NULL );
    require_noerr_string( err, exit, "ERROR: Unable to start the RGB LED thread ." );

    err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "MP3_PLAY", MP3_handleThread, 1024, NULL );
    require_noerr_string( err, exit, "ERROR: Unable to start the MP3 PLAY thread" );

    err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "BAT_DETECT", BAT_handleThread, 500, NULL );
    require_noerr_string( err, exit, "ERROR: Unable to start the BAT DETECT thread ." );

    KEY_Init(KEY_irq_handler); //按键初始化

    mico_rtos_init_semaphore(&cupTimeObj.playMp3_sem, 1);  //信号量初始化
    mico_rtos_init_semaphore(&cupTimeObj.playLed_sem, 1);
    mico_rtos_init_semaphore(&cupTimeObj.stopLed_sem, 1);

    err = mico_init_timer(&cupTimeObj.cup_timer, time_sencond, cup_timer_timeout_handler, (void *)&cupTimeObj);
    cupTimeObj.drinkTime = 1;
    cupTimeObj.playMode = PLAY_MP3_LED;
    if (KEY_getValue() == KEY_DOWN)
    {
        TIMER_start(); //启动定时喝水
    }

    while(1)
    {
        // printf("this is main thread.\r\n");
        //net_test(app_context);
        mico_thread_sleep(10);
    }

exit:
    if(kNoErr != err) {
        printf("ERROR: user_main thread exit with err=%d", err);
    }
    mico_rtos_delete_thread(NULL);
    return kNoErr;
}
Esempio n. 30
0
 int main(void)
 {
 	SystemInit();
	delay_init(72);	     //延时初始化
	NVIC_Configuration();
	uart_init(9600);
 	LED_Init();
	KEY_Init();          //按键初始化	 
	LED0=0;
	delay_ms(300);	  
	WWDG_Init(0X7F,0X5F,WWDG_Prescaler_8);//计数器值为7f,窗口寄存器为5f,分频数为8	   
 	while(1)
	{
		LED0=1;			  	   
	}	 
 }