示例#1
0
void application_start( )
{
    /* Initialise the WICED device */
    wiced_init();

    WPRINT_APP_INFO( ( "The color of the RGB is changing every second.\n" ) );

    RGB_Init( D0 );

    while ( 1 )
    {
        RGB_Show(0xFF, 0x00, 0x00);
        wiced_rtos_delay_milliseconds( 500 );

        RGB_Show(0x00, 0xFF, 0x00);
        wiced_rtos_delay_milliseconds( 500 );

        RGB_Show(0x00, 0x00, 0xFF);
        wiced_rtos_delay_milliseconds( 500 );

        RGB_Show(0xFF, 0x00, 0xFF);
        wiced_rtos_delay_milliseconds( 500 );

        RGB_Show(0xFF, 0xFF, 0x00);
        wiced_rtos_delay_milliseconds( 500 );

        RGB_Show(0x00, 0xFF, 0xFF);
        wiced_rtos_delay_milliseconds( 500 );
    }
}
示例#2
0
/**************************************************************/
//程 序 名: main()
//开 发 者: MingH
//入口参数: 无
//功能说明: 主函数
//**************************************************************/
int main(void)
{
	unsigned char err_code;
	RCC_Config();		// 时钟初始化配置
	Beep_Init();		// 蜂鸣器初始化配置
	Touch_Init();
	Pcie_Gpio_Init();
	Tim3_Init();
	
	RGB_Init();     //RGB 初始化
	RCC_GetClocksFreq(&RCC_ClockFreq);		
	SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);	
	USB2Serial_Init(); 	// 串口初始化配置
	Pwm_Init();
	Adc_Init();
	I2C_GPIO_Configuration();
	err_code = LIS3DH_Init();
	
	if (NO_ERROR == err_code)
	{
		printf("\r\nLIS3DH Init is succeed! \r\n");
	}
	else
	{
		printf("\r\nLIS3DH Init is failed! \r\n");
	}
	
	RTC_Init(); 		// RTC 初始化配置


	if(SD_Init() == SD_OK) {
	
		printf ("\r\n发现SD卡!\r\n");
	}
	else {
		printf("\r\n没有发现 SD 卡设备! \r\n");
	}
	printf("\r\n\r\n");
	save_sd_detect = SD_Detect(); //初始化SD卡插入状态
	
	SysTick_Delay_ms(500);
	TIM_Cmd(TIM1, DISABLE);
	TIM_CtrlPWMOutputs(TIM1, DISABLE);
	while (1)
	{
		if(read_sd_detect_flag){
			
			if (save_sd_detect != SD_Detect()){
				/* 蜂鸣器响 */
				TIM_Cmd(TIM1, ENABLE);
				TIM_CtrlPWMOutputs(TIM1, ENABLE);
				sd_detect_change = 1; //SD卡插入状态有变
				buzzer_delay = 0;
				if (SD_Detect() != SD_NOT_PRESENT){
						if(SD_Init() == SD_OK) {
							printf ("\r\n发现SD卡!\r\n");
						}
						else {
							printf("\r\n没有发现 SD 卡设备! \r\n");
						}
						printf("\r\n\r\n");
				}
			}
			save_sd_detect = SD_Detect();
			read_sd_detect_flag = 0;
		}
		
		
		Time_Show();	
		Test_Pcie_Gpio();
		Touch_Key_Proc();
		
		if (read_lis3dh_flag){
			Collect_Data(ACCdata);
			for (i=0; i<3; i++){
				if (oldACCdata[i] < ACCdata[i]){
					ACCdiff[i] = ACCdata[i] - oldACCdata[i];
				}
				else{
					ACCdiff[i] = oldACCdata[i] - ACCdata[i];
				}
			}
			RGB_Control(ACCdiff[0]<<1, ACCdiff[1]<<1, ACCdiff[2]<<1);
			for (i=0; i<3; i++){
				oldACCdata[i] = ACCdata[i];
			}
			read_lis3dh_flag = 0;
		}
		if (one_second_flag){
			printf("X=%d, Y=%d, Z=%d\r\n\r\n", ACCdata[1], ACCdata[0], ACCdata[2]);
			Adc_Proc();
			one_second_flag = 0;
		}
	}
}