Example #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);
}
Example #2
0
void initializeRobot()
{
  SensorsInit();
	AbortIfNoSMUX();
	MechanismInit();

	DrivePowerMultiplier = 1;

	return;
}
void PacketData_Update()
{
        uint8_t         flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
			  PACKET_INCR++; //Incrementing the value
	      
	      incr_cnt++;
	      if(incr_cnt==50)
				{
				 incr_cnt = 0;
				 SensorsInit();
				}

     	  supercap_measure_start();
	      TWI_init();    //Initializing TWI and reading values
				__HUMIDITY = HDC1008_ReadHumidity();
	      __PRESSURE = MPL3115A2_Read_Baro()>>6;
			  __PRESSURE/=10;	//Result in tens of Pascals (9500 equals 95000 Pa etc.)
			  __TEMP = MPL3115A2_Read_Temp();
	      HDC1008_TriggerHumidity();
	      TWI_powerdown(); //Power-down of TWI
				m_beacon_info[6]  = __PRESSURE>>8; //Putting data into 2.4 Ghz beacon packet and update advertising data
				m_beacon_info[7]  = (__PRESSURE & 0xFF);
				m_beacon_info[8]  = __TEMP>>8;
				m_beacon_info[9]  = (__TEMP & 0xFF);
	      m_beacon_info[10] = __HUMIDITY;
	      m_beacon_info[4]  = PACKET_INCR;
	      m_beacon_info[12] = __SUPERCAP_VOLTAGE>>8;
	      m_beacon_info[13] = __SUPERCAP_VOLTAGE&0xFF;
    
     	  manuf_specific_data.data.p_data        = (uint8_t *) m_beacon_info;

        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));

        advdata.flags.size              = sizeof(flags);
        advdata.flags.p_data            = &flags;
        advdata.p_manuf_specific_data   = &manuf_specific_data;

        ble_advdata_set(&advdata, NULL);
				
				CC110L_PACKETCONTENT[2+6]  = __PRESSURE>>8;   //Putting data into 868 Mhz packet
				CC110L_PACKETCONTENT[2+7]  = (__PRESSURE & 0xFF);
				CC110L_PACKETCONTENT[2+8]  = __TEMP>>8;
				CC110L_PACKETCONTENT[2+9]  = (__TEMP & 0xFF);
	      CC110L_PACKETCONTENT[2+10] = __HUMIDITY;
	      CC110L_PACKETCONTENT[2+4]  = PACKET_INCR;
	      CC110L_PACKETCONTENT[2+12] = __SUPERCAP_VOLTAGE>>8;
	      CC110L_PACKETCONTENT[2+13] = __SUPERCAP_VOLTAGE&0xFF;
}
int main(void)
{
	/*Ждем пока все включится*/
	_delay_ms(100);
	
	/*Настраиваем порты ввода-вывода*/
	DDRB = 1<<PORTB0|1<<PORTB1|1<<PORTB2|1<<PORTB3|1<<PORTB4|1<<PORTB5|1<<PORTB6|1<<PORTB7;
	DDRC = 1<<PORTC0|1<<PORTC1|1<<PORTC2|0<<PORTC3|0<<PORTC4|0<<PORTC5|0<<PORTC6|0<<PORTC7;
	DDRD = 0<<PORTD0|0<<PORTD1|0<<PORTD2|0<<PORTD3|1<<PORTD4|0<<PORTD5|0<<PORTD6|1<<PORTD7;

	PORTB = 1;
	PORTD = 1 << PORTD2;
    
	/*Тяга двигателей на минимум*/
    for(uint8_t k = 0; k < CHANNELS_COUNT; ++k)
    {
        counter[k] = LOW;
    }
	
	/*Настраиваем I2C*/
	TWSR = 0x00;
	TWBR = ((F_CPU / I2C_SPEED) - 16) / 2;  
	_delay_us(10);

	/*Включаем Таймер0*/
	TCCR0 = 1<<CS02 | 0<<CS01 | 0<<CS00;
	
	/*Включаем Таймер1*/
	OCR1A=HIGH; //TOP
	TCCR1A=0<<COM1A1|0<<COM1A0|1<<COM1B1|0<<COM1B0|0<<FOC1A|0<<FOC1B|1<<WGM11|1<<WGM10;
	TCCR1B=0<<ICNC1|0<<ICES1|1<<WGM13|1<<WGM12|0<<CS12|0<<CS11|1<<CS10;
	TIMSK= 1<<TOIE2 | 1<<OCIE1A|1<<OCIE1B|0<<TOIE1|1<<TOIE0|0<<OCIE0;
	OCR1B=LOW;
	
	/*Включаем АЦП*/
	ADC_Init();   
    
	/*Включаем прерывание INT0(высотомер)*/
	INT0_Init();
	
	/*Разрешаем работу прерываний*/
	sei();
	
	/*Настраиваем Modbus*/
	eMBErrorCode eStatus = eMBInit( MB_RTU, 0x01, 0, 57600, MB_PAR_NONE );
	eStatus = eMBEnable();
    
	/*Настраиваем сенсоры*/    
	SensorsInit();
	
	/*Загружаем в Holding Registers и в массив параметров значения из EEPROM*/
	ModbusInitValues();
	
	filterInit();	
		
	while(1)
	{
		/*Актуализируем значения Modbus-регистров в соответствии со значениями параметров*/
		ModbusLoader();
		/*Актуализируем значения параметров в соответствии со значениями Holding Registers*/
		ModbusSaver();
		
		/*Итерация Modbus*/
		eMBPoll();
		
		/*Ресурсоемкий расчет курса*/		
		Course_Calc();
	}
}
Example #5
0
task main()
{
  SensorsInit();
  MechanismInit();
  FieldInit();

  /*
  while ( true )
  {
    nxtDisplayCenteredTextLine(0, (string)LEFT_LIGHT_SENSOR());
    nxtDisplayCenteredTextLine(1, (string)RIGHT_LIGHT_SENSOR());
  }
  */


  StartTask(log);


  Node start = NodeLine3BottomEnd;
  Node end = NodeFriendBridgeCenter;



  //RobotFindWhiteLine();
  //wait10Msec(1000);



  ///RobotFindWhiteLine();
  //RobotFollowWhiteLineForDistance(15, false);

  //wait10Msec(1000);


  CurrentRobotPosition.orientation = PI / 2.0;
  FieldGetNodeLocation(start, CurrentRobotPosition.location);


  //wait10Msec(1000);




  RobotTravelFromNodeToNode(start, end, false);







  //MechanismElevatorSetHeight(8);


  //RobotMoveDistance(-20, false);

  PlaySound(soundBeepBeep);
  wait10Msec(100);


}