示例#1
0
void setup()
{
	setupSystemClock();
	setup_system_tick(SYSTEM_TICK_FREQ);
	setupUART();
#ifdef GPS
	setupGPS();
#endif
	I2C_Init();
	FlashInit();
	UpdateBoardVersion(false);
#ifdef OPTION_RC
	RC_Init();
	if(IsSSVConnected())
		Battery_Init();
	LED_Init();
	TIMER_Init();
	stabilizerInit();
#endif
#ifdef ABROBOT
  ABRobotMotorInit();
#endif
	nvtAHRSInit();
	SensorsInit();
	ChronographSet(ChronMain);
}
示例#2
0
void Mech_Init(void)
{
	RC_Init();
	
	RC_AddPins(GRAB_PIN);

        RC_SetPulseTime(GRAB_PIN, GRAB_UP_TIME);
}
示例#3
0
文件: setters.c 项目: drivkin/cubesat
void init_ESC_pulse(void) {
    // currently using RCpin x4 as defined by RC_Servo.h
    //look to IO_ports.h to figure out what pin this corresponds to on the micro
    //corresponds to B0 on the micro and J5 15 on the UNO32

    RC_Init();
    RC_AddPins(ESC_PIN);
    int i = 0;
    for (i; i < 1000000; i++);
    RC_SetPulseTime(ESC_PIN, 1500); //set intial speed to 0 rpm

}
示例#4
0
文件: bsp.c 项目: BobLiu20/AirPilot
/**
  * @brief  板级初始化
  *         
  * @param  none
  * @retval none
  */
void  BSP_Init (void)
{
	LED_Init();
	Flash_Read();									//读取参数
	Flash_CheckFirstTime(false);	//检查FLASH里是否存在有效数据,如果没有则写入默认数据
//	cfg.mixerConfiguration = MIXERCONFIG;统一在调参软件里设置机型
	Mixer_Init();									//动力初始化
	Serial_Init(cfg.serial_baudrate);//上位机调参初始化
	I2C2_Init();											//I2C2
	Sensor_DetectAndInit();
	IMU_Init();
	Altitude_Init();
	Actuator_Init();
	RC_Init();
	Daemon_Init();
	GPS_Init(cfg.gps_baudrate);
	Telemetry_Init();
#ifdef OPTICALFLOW
	OpticalFlow_Init();
#endif
	EasyCtrl_Init();
	VisionLanding_Init();
	Avoid_Init();
}
示例#5
0
/**
 * Function: Gate_Init
 * @return SUCCESS or ERROR
 * @remark Iniitializes the RC servo for the gate and
 * *    Sets the gate to the closed position
 */
char Gate_Init(){

    RC_Init(SERVO);
    Gate_Close();
    return SUCCESS;
}
示例#6
0
int main(void) {

    // ----------------- Initialization --------------
    SERIAL_Init();
    AD_Init(POT_INPUT);

    // Initialize interrupts
    INTEnableSystemMultiVectoredInt();

    RC_Init(RC_PORT);
    unsigned int wait = 0;
    for (wait = 0; wait <= 1000000; wait++)
        asm("nop");
    RC_SetPulseTime(RC_PORT, 2000);

    printf("\nHello,...");

    while (1) {
        
        // Read and print potentiometer
        unsigned int potValue = ReadPotentiometer();
        //printf("\nPot. reading: %x", potValue);

        // Pause if desired
        #ifdef ADC_PAUSE
        
        #endif

        unsigned int newSpeed = potValue +1000;
        printf("\nPot value to %u", potValue);

        // bound it
        newSpeed = max(newSpeed,MINPULSE);
        newSpeed = min(newSpeed,MAXPULSE);
        // effect the motor
        if (RC_SetPulseTime(RC_PORT, newSpeed) == SUCCESS) {
            printf("\nSuccessfully set PWM to %u", newSpeed);
        }
        else {
            printf("\nFailed to set PWM to %u", newSpeed);
        }
         
/*
        char keyPressed = GetChar();
        if (keyPressed != 0) {
            /*
            if (keyPressed == 'f') {
                // forward
                printf("\nforward");
                if (DIRECTION != FORWARD)
                    DIRECTION = FORWARD;
            }
            else if(keyPressed == 'r') {
                 // reverse
                printf("\nreverse");
                if (DIRECTION != REVERSE)
                    DIRECTION = REVERSE;
            }
            else if(keyPressed == 'q') {
                printf("\nGoodbye!");
                PWM_End();
                return 0;
            }
             
            if(keyPressed == 't') {
                unsigned short int stringMax = 4;
                unsigned short int i = 0;
                char charNumber[1];
                charNumber[0] = 0;
                char stringNumber[stringMax+1];
                printf("\nPlease enter a frequency:");

                while(charNumber[0] != 46) {
                        charNumber[0] = GetChar();
                        //printf("\nGot %s", charNumber);
                        if ((charNumber[0] <= 57 && charNumber[0] >= 48)) {
                            stringNumber[i] = charNumber[0];
                            stringNumber[i+1] = '\0';
                            //printf("\nAppended %c to '%s'",charNumber[0],stringNumber);
                            //stringNumber = strcat(stringNumber, charNumber);
                            i++;
                        }

                        if (i >= stringMax)
                            break;
                        
                }
                //printf("\ni=%u stmax=%u", i, stringMax);
                printf("\nDone");

                unsigned int newFreq = atoi(stringNumber);
                newFreq = max(newFreq,MINPULSE);
                newFreq = min(newFreq,MAXPULSE);
                printf("\nPulse width set to %u",newFreq);
                RC_SetPulseTime(RC_PORT,newFreq);
                
            }
        } // end of keyPressed
        */
 
        while (!IsTransmitEmpty()); // bad, this is blocking code
    } // end of while loop

    return 0;
}