int main(void)
{
	InitIO();
	init_ADC();
	InitTimer1();
	InitTimer2();
	InitExtInt();
	
    while(1)
    {
        switch(display_select)
		{
			case 0x00:
				MusicOnLed();
			break;
			case 0x01:
				FadeOnLed();
			break;
			case 0x02:
				StrobeOnLed(100, 100, 100);
			break;
			/*
			.
			.	TODO:: Sync up pin change interrupts for the last push button
			.
			*/
			case 0xFF:
				ColorOnLed(1,0,1);
			break;
		}
    }
}
示例#2
0
文件: main.c 项目: rcacho/book
void main (void) 
{
	OSInit();    
    InitTimer2();
    OSTaskCreate(sys_init, (void *)0, &sys_init_Stk[0],1);
    OSStart();
}
示例#3
0
void Timer2Switch(uchar switchEn)
{
    if(switchEn)
    {
        Manage100usEvent = EmptyTask;
        #if(TIMEER_10MS_ENABLE != 0)
            memset(timeInf10ms,0,sizeof(timeInf10ms));
        #endif
        InitTimer2();
#if(CONFIG_METER_SW_DEBUG_MODE == GAL_YES)
        InitTimer5();
        #endif
    }
    else
    {
        ;
    }
}
void main() {
  Display_Init();
  MCU_Init();
  #ifdef INIT_BLE
  BLE_Init();
  delay_ms(2000);
  #else
  RN_WAKE = 1;
  wait_response("CMD");
  #endif
  DrawFrame();
  InitTimer2();
  while(1)
  {
    if(data_ready)
    {
      //If characteristic is configured as write
      //received messages come here
      Display_Message();
      reset_buff();
    }
    else
    {
       //Test: every 5sec increase baterry level (0 to 100%)
       //and send value via Bluetooth Low Energy
       if (tmr_flg)
       {
          batt_level++;
          if(batt_level > 100)
          {
            batt_level = 0;
          }
          Display_BatteryLevel();
          if(RN_CONN)
          { //send battery level value if BLE connected
            shorttohex(batt_level, batt_level_txt);
            ltrim(batt_level_txt);
            ble2_write_server_characteristic_value_via_UUID("2A19",batt_level_txt);
          }
          tmr_flg = 0;
       }
    }
  }
}
示例#5
0
void CShiftPWM::Start(int ledFrequency, unsigned char maxBrightness){
	// Configure and enable timer1 or timer 2 for a compare and match A interrupt.    

	m_ledFrequency = ledFrequency;
	m_maxBrightness = maxBrightness;

	if(LoadNotTooHigh() ){
		if(m_timer==1){ 
			InitTimer1();
		}
		else if(m_timer==2){
			InitTimer2();
		}
	}
	else{
		Serial.println("Interrupts are disabled because load is too high.");
		cli(); //Disable interrupts
	}
}
示例#6
0
/********************************* 
	main entry point
*********************************/
int main ( void )
{
    // Init the basic hardware
    InitCnsts();
    InitHardware();

    // Start the main 1Khz timer and PWM timer
    InitTimer1();
    InitTimer2();
    InitPWM();

    // Initialize A2D, 
    InitA2D();

    UART1_Init(XBEE_SPEED);         // for communication and control signals
    UART2_Init(LOGGING_RC_SPEED);   // for spektrum RC satellite receiver

    // Wait for a bit before doing rate gyro bias calibration
    // TODO: test this length of wait
    uint16_t i=0;for(i=0;i<60000;i++){Nop();}

    // turn on the leds until the bias calibration is complete
    led_on(LED_RED);
    led_on(LED_GREEN);

    // Initialize the AHRS
    AHRS_init();

    // Initialize the Controller variables
    Controller_Init();

    // MAIN CONTROL LOOP: Loop forever
    while (1)
    {
        // Gyro propagation
        if(loop.GyroProp){
            loop.GyroProp = 0;
            // Call gyro propagation
            AHRS_GyroProp();
        }

        // Attitude control
        if(loop.AttCtl){
            loop.AttCtl = 0;
            // Call attitude control
            Controller_Update();
        }

        // Accelerometer correction
        if( loop.ReadAccMag ){
            loop.ReadAccMag = 0;
            AHRS_AccMagCorrect( );
        }

        // Send data over modem - runs at ~20Hz
        if(loop.SendSerial){
            loop.SendSerial = 0;

            // Send debug packet
            UART1_SendAHRSpacket();
        }

        // Process Spektrum RC data
        if(loop.ProcessSpektrum){
            loop.ProcessSpektrum = 0;
            UART2_ProcessSpektrumData();
        }

        // Read data from UART RX buffers - 500 Hz
        if(loop.ReadSerial){
            loop.ReadSerial = 0;

            // Read serial data
            //UART2_FlushRX_Spektrum();

        }


        // Toggle Red LED at 1Hz
        if(loop.ToggleLED){
            loop.ToggleLED = 0;
            
            // Toggle LED
            led_toggle(LED_RED);
        }

    } // End while(1)
	
}