Esempio n. 1
0
int main (void) 
{
  SystemCoreClockUpdate();
	
  /* Initialize 32-bits timer 0 */
  init_timer32(0, TIME_INTERVAL);
  enable_timer32(0);
	
  /* Initialize the PWM in timer32_1 enabling match0 output */
  init_timer32PWM(1, period, MATCH0);
  setMatch_timer32PWM (1, 0, period/4);
  enable_timer32(1);

  /* Initialize the PWM in timer16_0 enabling match1 output */
  init_timer16PWM(0, period, MATCH1, 0);
  setMatch_timer16PWM (0, 1, period/2);
  enable_timer16(0);

  /* Enable AHB clock to the GPIO domain. */
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
	
  /* Set port 1_19 to output */
  GPIOSetDir( 1, 6, 1 );
	
  
  while (1)                                /* Loop forever */
  {
	/* I/O configuration and LED setting pending. */
	if ( (timer32_0_counter[0] > 0) && (timer32_0_counter[0] <= 50) )
	{
	  GPIOSetBitValue( 1, 6, 0 );
	}
	if ( (timer32_0_counter[0] > 50) && (timer32_0_counter[0] <= 100) )
	{
	  GPIOSetBitValue( 1, 6, 1 );
	}
	else if ( timer32_0_counter[0] > 100 )
	{
	  timer32_0_counter[0] = 0;
	}
  }
}
Esempio n. 2
0
void setup() {
#if !defined(GPS_PROMINI)
    UARTInit(115200);
#endif
    LEDPIN_PINMODE;
    SHIELDLED_PINMODE;
    //POWERPIN_PINMODE;
    //BUZZERPIN_PINMODE;
    //STABLEPIN_PINMODE;
    //POWERPIN_OFF;


    /* Initialize GPIO (sets up clock) */
    GPIOInit();
    init_microsec();
    enable_microsec();
    init_timer16PWM();
    enable_PWMtimer();

    /********  special version of MultiWii to calibrate all attached ESCs ************/
#if defined(ESC_CALIB_CANNOT_FLY)
    writeAllMotors(ESC_CALIB_HIGH);
    delayMs(3000);
    writeAllMotors(ESC_CALIB_LOW);
    delayMs(500);
    while (1) {
        delayMs(5000);
        blinkLED(2,20, 2);
    }
    // statement never reached
#endif

    writeAllMotors(MINCOMMAND);
    delayMs(300);

    readEEPROM();
    checkFirstTime();
    configureReceiver();
#if defined(OPENLRSv2MULTI)
    initOpenLRS();
#endif
    initSensors();
#if defined(I2C_GPS) || defined(GPS_SERIAL) || defined(GPS_FROM_OSD)||defined(I2C_NAV)
    GPS_set_pids();
#endif
    previousTime = micros();
#if defined(GIMBAL)
    calibratingA = 400;
#endif
    calibratingG = 400;
    calibratingB = 200;  // 10 seconds init_delay + 200 * 25 ms = 15 seconds before ground pressure settles
#if defined(POWERMETER)
    for(uint8_t i=0;i<=PMOTOR_SUM;i++)
        pMeter[i]=0;
#endif
#if defined(ARMEDTIMEWARNING)
    ArmedTimeWarningMicroSeconds = (ARMEDTIMEWARNING *1000000);
#endif
    /************************************/
#if defined(GPS_SERIAL)
    SerialOpen(GPS_SERIAL,GPS_BAUD);
    delay(400);
    for(uint8_t i=0;i<=5;i++){
        GPS_NewData();
        LEDPIN_ON
        delay(20);
        LEDPIN_OFF
        delay(80);
    }
    if(!GPS_Present){
        SerialEnd(GPS_SERIAL);
        SerialOpen(0,SERIAL_COM_SPEED);
    }
#if !defined(GPS_PROMINI)
    GPS_Present = 1;
#endif
    GPS_Enable = GPS_Present;
#endif
    /************************************/

#if defined(I2C_GPS) || defined(TINY_GPS) || defined(GPS_FROM_OSD)|| defined(I2C_NAV)
    GPS_Enable = 1;
#endif

#if defined(LCD_ETPP) || defined(LCD_LCD03) || defined(OLED_I2C_128x64)
    initLCD();
#endif
#ifdef LCD_TELEMETRY_DEBUG
    telemetry_auto = 1;
#endif
#ifdef LCD_CONF_DEBUG
    configurationLoop();
#endif
#ifdef LANDING_LIGHTS_DDR
    init_landing_lights();
#endif

#if defined(LED_FLASHER)
    init_led_flasher();
    led_flasher_set_sequence(LED_FLASHER_SEQUENCE);
#endif
    f.SMALL_ANGLES_25=1; // important for gyro only conf

    //initialise median filter structures
#ifdef MEDFILTER
#ifdef SONAR
    initMedianFilter(&SonarFilter, 5);
#endif
#endif

    initWatchDog();
}