Esempio n. 1
0
void main (void)
{
    Display_Intro();
    init_I2C();
    port_config();
    DISABLE_USB_5V;                     // Disable USB 5v (for Host support)

    if(MAX3353_Init())
        printf("\nMAX3353 not Present\n");
    else
        printf("\nMAX3353 Present\n");
    MAX3353_ISR();

    while(1)
    {
        in_char();   

#if 0 //CW        
        enter_vlps();
#endif //kevin

        //enter_stop();  
        mcg_pbe_2_pee();
        
        if(FLAG_CHK(_MAX3353,gu8ISR_Flags))
        {
            if(gu8MAX3353StatusRegister & ID_GND_EVENT)
            {
                ENABLE_USB_5V;
                printf("\nID-GND   --> Changing to HOST mode (Enabling 5V)");
            }    
            if(gu8MAX3353StatusRegister & ID_FLOAT_EVENT)
            {
                DISABLE_USB_5V;
                printf("\nID-FLOAT --> Changing to DEVICE mode (Disabling 5V)");
            }    
            if(gu8MAX3353StatusRegister & VBUS_HIGH_EVENT)
                printf("\nVBUS is Up");

            if(gu8MAX3353StatusRegister & VBUS_LOW_EVENT)
                printf("\nVBUS is Down");
        
            FLAG_CLR(_MAX3353,gu8ISR_Flags);
        }
    } 
}
Esempio n. 2
0
void Init_Task(uint32_t task_init_data)
{
		int tester=0;
	//uint_8 sys=0;
	bool bInitOpen=FALSE;
  bool	bInitStill=FALSE;
	bool bInitVLPS=FALSE;
	MQX_TICK_STRUCT ttt;
	 _mqx_uint       mqx_ret;
	  trace_init();
	 show_version_information();
		//////////////zga add
	//Set LPTMR to timeout about 5 seconds
		Lptmr_Init(1000, LPOCLK);	
		ADC_Init();
		Calibrate_ADC();
		ADC_Init();
		DMA1_Init();
	//////////////zga add
		// clear flag  
		APP_TRACE("start 1\n\r");
	 _task_create_at(0, SHELL_TASK, 0, shell_task_stack, SHELL_TASK_STACK_SIZE);
	 _task_create_at(0, MMA8415_TASK, 0, mma8451_task_stack, MMA8451_TASK_STACK_SIZE);
	
		Lptmr_Start();
	

	
for(;;)
	{
		 mqx_ret = _lwsem_wait(&g_lptmr_int_sem);

	
	//	_time_delay_ticks(10);
		tester++;
//_time_delay_ticks(10);
		//APP_TRACE("tester is: %d\r\n",tester);
		_time_get_elapsed_ticks(&ttt);
          APP_TRACE("high ttt %d, low ttt%d\r\n", ttt.TICKS[1],ttt.TICKS[0]);
		if(Measured)
		{	Measured=0;
			APP_TRACE ("light: %d ,%d \r\n", (uint16_t) MeasuredValues[1],tester);
		}
		if((GetTouchON()==TRUE))
			{
				SetSysStatus(ACTIVE_OPEN);
			}
			// for test 
			SetSysStatus(ACTIVE_OPEN);
		switch (sysStatus)
	{
		case ACTIVE_OPEN:
					bInitStill=FALSE;
					bInitVLPS=FALSE;
					APP_TRACE ("ACTIVE_OPEN\r\n");
					if(bInitOpen==FALSE)
					{
						bInitOpen=TRUE;
						putmma8451running();
						SysTick_PDD_EnableDevice(SysTick_BASE_PTR, PDD_ENABLE);
					}
					
					
			break;

    case ACTIVE_STILL:
					bInitOpen=FALSE;
					bInitVLPS=FALSE;
				APP_TRACE ("ACTIVE_still\r\n");
					if(bInitStill==FALSE)
					{
						bInitStill=TRUE;
						putmma8451detect();
					}
					enter_vlps();
		case 	VLPSMODE:
					bInitOpen=FALSE;
					bInitStill=FALSE;
				APP_TRACE ("vlpsmode\r\n");
					if(bInitVLPS==FALSE)
					{
						bInitVLPS=TRUE;
						putmma8451standby();
					}
					enter_vlps();
    default:
            break;
	}


	} 
	
}