Beispiel #1
0
int main()
{
    int i[4],d,e;
    /* Config LED,BUTTON,LCD,PIT */
    LED_Init();
    Button_init();
    Pit_init();

    MCG_FEI();
    Uart0_init(115200); // selection baud with FEQ =48MHZ
    /*	-	Baud rate: 115200, Data bit: 8; Parity: None; Stop bits: 1; Flow Control: None. */

    LED_On(1); //LED DO;
    LED_On(0); //LED Xanh
    while(1)
    {

        i[0] =string_compare(buffer,command[0]);
        i[1] =string_compare(buffer,command[1]);
        i[2] =string_compare(buffer,command[2]);
        i[3] =string_compare(buffer,command[3]);
        if(i[0] == 1)
            LED_On(1);

        if(i[1] == 1)
            LED_Off(1);

        if(i[2] == 1)
            LED_On(0);

        if(i[3] == 1)
            LED_Off(0);

    }
}
Beispiel #2
0
int main (void)
{
    	char ch,aux1 ,aux2;
      
     
            int UsbDetected = FALSE;
#ifdef CMSIS  // If we are conforming to CMSIS, we need to call start here
    start();
#endif
         vfnMcuConfig();
         
    
  	printf("\n\rRunning the FRDMKL46_Demo project.\n\r");
        vfnLCD_Init();
        gpio_init();
        Pit_init();
        TSI_Init();
        usb_init();
        next_task(vfn_led_test);
        accel_init();
        mag_init();
        eCompassInit();
        adc_init();        
        tpm_init();  //Green LED 50%SIM_SCGC5_PORTC_MASK
        

        
        
// character test        
        vfnLCD_Write_Msg("8888");
        _LCD_DP1_ON();
        _LCD_DP2_ON();
        _LCD_DP3_ON();
        _LCD_COL_ON();
         
 	while(1)
	{
        
#ifdef FRDM_REVA  
          if (uart_getchar_present(UART1_BASE_PTR))
#else
            
          if (uart0_getchar_present(UART0_BASE_PTR))
#endif
            
          {
            ch = in_char();
            printf("\n\r Received char = %c \n\r",ch);            
           if (ch==' ')
           {     
           printf("\n\r light_sensor  = %i",adc_light_sensor);
         //  printf("\n\r Yaw =%4d Pitch =%4d Roll =%4d \r", APhi6DOF, AThe6DOF, APsi6DOF);
           printf("\n\r Yaw =%4d Pitch =%4d Roll =%4d \r", APsi6DOF, APhi6DOF, AThe6DOF);
           
           printf("\n\r tsi %%= %03i  ", AbsolutePercentegePosition);
           }
         }
          
           if (input_rise(SW1_ON, &aux1))
            {  
              printf("\n\r SW1 \n\r");
            }
          
         
            if (input_rise(SW2_ON, &aux2))
            {  
              printf("\n\r SW2 \n\r ");
            }
          
             ptr_next_task();  // do the actual function
             TSI_SliderRead();
             usb_service();
            if (gu8USB_State == uENUMERATED && !UsbDetected) 
            {
              // next_task(vfn_rgb_test);
               UsbDetected = TRUE;
            }        
            
          adc_light_sensor = adc_read(3);
                
                    
              
                
        }
}