Ejemplo n.º 1
0
void init(void)
{
    int i;
    volatile WordVal src_addr = {SRC_ADDR};
    volatile WordVal src_pan_id = {SRC_PAN_ID};

    SetupClock();
    SwitchClocks();
    SetupPorts();

    for (i = 0; i < 6; i++)
    {
        LED_RED = ~LED_RED;
        delay_ms(50);
        LED_YLW1 = ~LED_YLW1;
        delay_ms(50);
        LED_YLW2 = ~LED_YLW2;
        delay_ms(50);
        LED_BLU = ~LED_BLU;
        delay_ms(50);
    }

    SetupUART1();
    SetupInterrupts();
    EnableIntU1TX;
    EnableIntU1RX;
    radioInit(src_addr, src_pan_id, 150, 150);
    atSetPromMode(1);  //This turns off Automatic Acknowledgements and puts the radio in prom mode
    radioSetChannel(MY_CHAN); //Set to my channel

    //atSetAntDiversity(1);
}
Ejemplo n.º 2
0
int main(void) {

    WordVal src_addr_init = {SRC_ADDR};
    WordVal src_pan_id_init = {SRC_PAN_ID};
    WordVal dst_addr_init = {DST_ADDR};

    SetupClock();
    SwitchClocks();
    SetupPorts();
    batSetup();

    swatchSetup();
    radioInit(src_addr_init, src_pan_id_init, RXPQ_MAX_SIZE, TXPQ_MAX_SIZE);
	radioSetChannel(MY_CHAN); //Set to my channel
    macSetDestAddr(dst_addr_init);

    dfmemSetup();
	unsigned char memsize;
	memsize = dfmemGetChipSize();
    xlSetup();
    gyroSetup();
    mcSetup();
    cmdSetup();
    //senSetup();
	adcSetup();
    pidSetup();
    steeringSetup();
	
    //radioReadTrxId(id);

    LED_RED = 1;
    LED_BLUE = 0;
	LED_YELLOW = 0;

	//while(1);

    if(phyGetState() == 0x16)  { LED_GREEN = 1; }

    //print("Ready");	

	//readDFMemBySample(5);

    while(1) {
     	cmdHandleRadioRxBuffer();

		//Simple idle ; reduces idle current to 70 mA
        // TODO (abuchan, apullin, fgb) : Idle() causes unexpected behavior
		//if(radioIsRxQueueEmpty()){
		//	Idle();
		//}

    }
}
Ejemplo n.º 3
0
/*
 * Application entry point.
 */
int main(void) {

	/*
	 * System initializations.
	 * - HAL initialization, this also initializes the configured device drivers
	 *   and performs the board-specific initializations.
	 * - Kernel initialization, the main() function becomes a thread and the
	 *   RTOS is active.
	 */
	halInit();
	chSysInit();

	chEvtInit(&eventImuIrq);
	chEvtInit(&eventMagnIrq);
	chEvtInit(&eventImuRead);
	chEvtInit(&eventMagnRead);
	chEvtInit(&eventEKFDone);

	palSetPadMode(GPIOB, 3, PAL_MODE_OUTPUT_PUSHPULL); // BLUE
	palSetPadMode(GPIOB, 4, PAL_MODE_OUTPUT_PUSHPULL); // GREEN
	palSetPadMode(GPIOB, 5, PAL_MODE_OUTPUT_PUSHPULL); // RED
	chThdCreateStatic(waThreadLed, sizeof(waThreadLed), NORMALPRIO, ThreadLed, NULL );

	I2CInitLocal();
	configInit();
	mavlinkInit();
	initSensors();

	TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);
	TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
	TIM_TimeBaseStructure.TIM_Prescaler = 84 - 1;
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure);
	TIM_Cmd(TIM5, ENABLE);

	startEstimation();
	startSensors();
	radioInit();
	motorsInit();

	extStart(&EXTD1, &extcfg);
	extChannelEnable(&EXTD1, 0);
	extChannelEnable(&EXTD1, 1);

	chEvtBroadcastFlags(&eventEKFDone, EVT_EKF_DONE);

	while (TRUE) {
		chThdSleepMilliseconds(1000);
	}
}
int main ( void )
{
    fun_queue = queueInit(FUN_Q_LEN);
    rx_pay_queue = pqInit(12); //replace 12 with a #define const later
    test_function tf;

    /* Initialization */
    SetupClock();
    SwitchClocks();
    SetupPorts();

    SetupInterrupts();
    SetupI2C();
    SetupADC();
    SetupTimer1();
    SetupPWM();
    SetupTimer2();
    gyroSetup();
    xlSetup();
    dfmemSetup();

    WordVal pan_id    = {RADIO_PAN_ID};
    WordVal src_addr  = {RADIO_SRC_ADDR};
    WordVal dest_addr = {RADIO_DEST_ADDR};

    radioInit(src_addr, pan_id, RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE);
    radioSetDestAddr(dest_addr);
    radioSetChannel(RADIO_MY_CHAN);

    char j;
    for(j=0; j<3; j++){
        LED_2 = ON;
        delay_ms(500);
        LED_2 = OFF;
        delay_ms(500);
    }

    LED_2 = ON;

    EnableIntT2;
    while(1){
        while(!queueIsEmpty(fun_queue))
        {
            rx_payload = pqPop(rx_pay_queue);
            tf = (test_function)queuePop(fun_queue);
            (*tf)(payGetType(rx_payload), payGetStatus(rx_payload), payGetDataLength(rx_payload), payGetData(rx_payload));
            payDelete(rx_payload);
        }
    }
    return 0;
}
Ejemplo n.º 5
0
int main (void)
{
    unsigned int i;

    /* Initialization */
    SetupClock();
    SetupPorts();
    batSetup();
    cmdSetup();
    mcSetup();
    SetupADC();
    SwitchClocks();
    sclockSetup();

    radioInit(TXPQ_MAX_SIZE, RXPQ_MAX_SIZE);
    radioSetChannel(MY_CHAN);
    radioSetSrcPanID(PAN_ID);
    radioSetSrcAddr(SRC_ADDR);

    dfmemSetup();
    camSetup();
    cambuffSetup();
    gyroSetup();

    cmdResetSettings();

    for (i = 0; i < 6; i++)
    {
        LED_GREEN  = ~LED_GREEN;  delay_ms(50);
        LED_RED    = ~LED_RED;    delay_ms(50);
        LED_ORANGE = ~LED_ORANGE; delay_ms(50);
    }
    LED_GREEN = 0; LED_RED = 0; LED_ORANGE = 0;

    /* Program */
    while (1)
    {
        cmdHandleRadioRxBuffer();
        radioProcess();
    }
}
Ejemplo n.º 6
0
/*
 * @brief Initialize the minimal amount of hardware for the bootloader to function
 * @returns void
 */
void systemInit(void) {
	uint32 i, j;

	MAP_IntMasterDisable();

	// increase LDO voltage so that PLL operates properly
	MAP_SysCtlLDOSet(SYSCTL_LDO_2_75V);
	#ifdef PART_LM3S8962
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ);
	#endif

	systemIDInit();
	blinkyLedInit();
	buttonsInit();
	srand(roneID);
	serialInit();
	#if defined(RONE_V9) || defined(RONE_V12)
	SPIInit();
	radioInit();
	#endif // defined(RONE_V9) || defined(RONE_V12)

	// Triple blink blinky, startup signal
	for (i = 0; i < 3; i++) {
		blinkyLedSet(1);
		for (j = 0; j < 150000;) {
			j++;
		}
		blinkyLedSet(0);
		for (j = 0; j < 250000;) {
			j++;
		}
	}

	// Initialize 24-bit Systick
	SysTickPeriodSet(0xffffff);
	SysTickEnable();
}
Ejemplo n.º 7
0
void main()
{
  mode = MODE_LEGACY;

  //Init the chip ID
  initId();
  //Init the led and set the leds until the usb is not ready
#ifndef CRPA
  ledInit(CR_LED_RED, CR_LED_GREEN);
#else
  ledInit(CRPA_LED_RED, CRPA_LED_GREEN);
#endif
  ledSet(LED_GREEN | LED_RED, true);

  // Initialise the radio
#ifdef CRPA
    // Enable LNA (PA RX)
    P0DIR &= ~(1<<CRPA_PA_RXEN);
    P0 |= (1<<CRPA_PA_RXEN);
#endif
  radioInit(RADIO_MODE_PTX);
#ifdef PPM_JOYSTICK
  // Initialise the PPM acquisition
  ppmInit();
#endif //PPM_JOYSTICK
  // Initialise and connect the USB
  usbInit();

  //Globally activate the interruptions
  IEN0 |= 0x80;

  //Wait for the USB to be addressed
  while (usbGetState() != ADDRESS);

  //Reset the LEDs
  ledSet(LED_GREEN | LED_RED, false);

  //Wait for the USB to be ready
  while (usbGetState() != CONFIGURED);

  //Activate OUT1
  OUT1BC=0xFF;

  while(1)
  {
    if (mode == MODE_LEGACY)
    {
      // Run legacy mode
      legacyRun();
    }
    else if (mode == MODE_CMD)
    {
      // Run cmd mode
      cmdRun();
    }
    else if (mode == MODE_PRX)
    {
      // Run PRX mode
      prxRun();
    }

    //USB vendor setup handling
    if(usbIsVendorSetup())
      handleUsbVendorSetup();
  }
}
Ejemplo n.º 8
0
int main(void) {

    wakeTime = 0;
    dcCounter = 0;

    WordVal src_addr_init = {RADIO_SRC_ADDR};
    WordVal src_pan_id_init = {RADIO_SRC_PAN_ID};
    WordVal dst_addr_init = {RADIO_DST_ADDR};

    SetupClock();
    SwitchClocks();
    SetupPorts();
    tiHSetup();


    //swatchSetup();
    radioInit(src_addr_init, src_pan_id_init, RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE);
    radioSetChannel(RADIO_CHANNEL); //Set to my channel
    macSetDestAddr(dst_addr_init);
    cmdSetup();
    
    if(phyGetState() == 0x16)  { LED_RED = 1; }
    while(1){
        cmdHandleRadioRxBuffer();
    }

    LED_GREEN = 0;
    LED_RED = 1;
    LED_YELLOW = 1;
    _LATG9 = 1;
    _LATC15 = 1;



    //testRadio();


/*
    LED_GREEN = 1;
    mpuSetup();
    LED_GREEN = 0;
    LED_RED = 1;
    LED_YELLOW = 1;




    //batSetup();

    //int old_ipl;
    //mSET_AND_SAVE_CPU_IP(old_ipl, 1)



    //LED_YELLOW = 1;

    //dfmemSetup();
    //xlSetup();
    //gyroSetup();
    //tiHSetup();
    //mcSetup();
    //cmdSetup();
    //adcSetup();
    //telemSetup(); //Timer 5


    //mcSetDutyCycle(1,70.0);
    //mcSetDutyCycle(2,70.0);
    //mcSetDutyCycle(3,70.0);
    //mcSetDutyCycle(4,70.0);


#ifdef HALL_SENSORS
    //hallSetup();    // Timer 1, Timer 2
    //hallSteeringSetup(); //doesn't exist yet
#else //No hall sensors, standard BEMF control
    //legCtrlSetup(); // Timer 1
    //steeringSetup();  //Timer 5
#endif

    //tailCtrlSetup();

    //ovcamSetup();
    /*
    //radioReadTrxId(id);

    LED_RED = 1; //Red is use an "alive" indicator
    LED_GREEN = 0;
    LED_YELLOW = 0;


    //tiHSetFloat(1,50.0);
    //tiHSetFloat(2,75.0);

    //tiHSetup();

    //LED_GREEN = 1;

    //tiHSetFloat(1,.800);

    //LED_YELLOW = 1;
    //Radio startup verification
    //if(phyGetState() == 0x16)  { LED_GREEN = 1; }

    //Sleeping and low power options
    //_VREGS = 1;
    //gyroSleep();

    //tiHSetFloat(1,98.0);
    //tiHSetFloat(2,30.0);
    //tiHSetFloat(3,99.0);
    //tiHSetFloat(4,99.0);


    
    LED_GREEN = 0;
    LED_RED = 0;
    LED_YELLOW = 1;
    
    int i = 0;
    while (1)
    {
        delay_ms(2000);
        int i = i+1;
        LED_GREEN = i%2;
        
 //       cmdHandleRadioRxBuffer();


#ifndef __DEBUG //Idle will not work with debug
        //Simple idle:
        if (radioIsRxQueueEmpty()) {
            Idle();
            
            //_T1IE = 0;
        }
        
#endif

        //delay_ms(1000);
        //cmdEcho(0, 1 , (unsigned char*)(&i) );
        //i++;
        //if(radioIsRxQueueEmpty() && (t1_ticks >= wakeTime + 5000) ){
        //Idle();
        //LED_RED = 0;
        //gyroSleep();
        //Sleep();
        //}
    }
    
    
    /*
    if(g_radio_duty_cycle){
            if(dcCounter == 0){
                    //LED_GREEN = 1;
                    atSetRXAACKON();
            }else{
                    //LED_GREEN = 0;
                    atSetTRXOFF();
            }
    }
    else{
            //LED_GREEN = 1;
    }

    dcCounter = (dcCounter + 1) % 8;
		
    if(radioIsRxQueueEmpty() && !inMotion){
            //gyroSleep();
            LED_RED = 0;
            _SWDTEN = 1; //restart wdt
            Sleep();
            //Idle();
    }
		
    //should be asleep here, waiting for WTD wakeup
    ClrWdt(); //clear wdt
    _SWDTEN = 0; //software disable wdt
    LED_RED = 1;

    //spin up clock
    if(_COSC != 0b010){
            while(OSCCONbits.LOCK!=1);
    }
    //gyroWake();
    }
}


void testRadio(void)
{
    //designed to be used with testRadio.py.
    //test radio.py should produce many echoes that cycle through the ASCII characters
    //comment out all code in main and use test Radio to test the radio only.
    //This code does not initialize non-radio-nessisary components.
    wakeTime = 0;
    dcCounter = 0;

    WordVal src_addr_init = {RADIO_SRC_ADDR};
    WordVal src_pan_id_init = {RADIO_SRC_PAN_ID};
    WordVal dst_addr_init = {RADIO_DST_ADDR};

    SetupClock();
    SwitchClocks();
    SetupPorts();

    int old_ipl;
    mSET_AND_SAVE_CPU_IP(old_ipl, 1)

swatchSetup();
    radioInit(src_addr_init, src_pan_id_init, RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE);
    radioSetChannel(RADIO_CHANNEL); //Set to my channel
    macSetDestAddr(dst_addr_init);

    cmdSetup();
    LED_GREEN = ON;
    int i = 0;
    while (1) {
        i++;
        cmdHandleRadioRxBuffer();
    }
    LED_RED = OFF;
}*/
}
Ejemplo n.º 9
0
int main() {

    // Processor Initialization
    SetupClock();
    SwitchClocks();
    SetupPorts();
    sclockSetup();

    LED_1 = 1;
    LED_2 = 1;
    LED_3 = 1;

    // Message Passing
    fun_queue = carrayCreate(FUN_Q_LEN);
    cmdSetup();

    // Radio setup
    radioInit(RADIO_RXPQ_MAX_SIZE, RADIO_TXPQ_MAX_SIZE);
    radioSetChannel(RADIO_CHANNEL);
    radioSetSrcAddr(RADIO_SRC_ADDR);
    radioSetSrcPanID(RADIO_PAN_ID);

    uart_tx_packet = NULL;
    uart_tx_flag = 0;
    //uartInit(&cmdPushFunc);
    tactileInit();

    // Need delay for encoders to be ready
    delay_ms(100);
    amsEncoderSetup();
    mpuSetup();
    tiHSetup();
    dfmemSetup();
    telemSetup();
    adcSetup();
    pidSetup();



    LED_1 = 0;
    LED_3 = 1;
    while(1){
        // Send outgoing radio packets
        radioProcess();

        /*
        // Send outgoing uart packets
        if(uart_tx_flag) {
            uartSendPacket(uart_tx_packet);
            uart_tx_flag = 0;
        }*/

        checkTactileBuffer();

        // move received packets to function queue
        while (!radioRxQueueEmpty()) {
            // Check for unprocessed packet
            rx_packet = radioDequeueRxPacket();
            if(rx_packet != NULL) {
                cmdPushFunc(rx_packet);
            }
        }

        // process commands from function queue
        while(!carrayIsEmpty(fun_queue)) {
            rx_packet = carrayPopHead(fun_queue);
            unsigned int rx_src_addr = rx_packet->src_addr.val;
            if(rx_packet != NULL) {
               rx_payload = macGetPayload(rx_packet);
               if(rx_payload != NULL) {
                   rx_function = (test_function)(rx_payload->test);
                   if(rx_function != NULL) {
                       LED_2 = ~LED_2;
                       (rx_function)(payGetType(rx_payload), payGetStatus(rx_payload), payGetDataLength(rx_payload), payGetData(rx_payload), rx_src_addr);
                   }
               }
               ppoolReturnFullPacket(rx_packet);
            }
        }
    }
    return 0;
}
int main(void) {

  uint8_t numSensors = 0, i;
  // unsigned long nextflash = 0;

  // Configure all pins as inputs with pullups initially
  DDRA = 0x00;
  PORTA = 0xff;
  DDRB = 0x00;
  PORTB = 0xff;

  // Serial output line
  DDRB |= _BV(PINB0);
  PORTB |= _BV(PINB0);

  // LED
  // DDRA |= _BV(PINA0);

  // Radio power is PA1
  PORTA &= ~_BV(PINA1);
  DDRA |= _BV(PINA1);

  // Onewire power is PA2
  PORTA &= ~_BV(PINA2);
  DDRA |= _BV(PINA2);

  myPutStr("Hello world\r\n");

  // Various power-saving things

  // Disable BOD while sleeping. I hope.
  MCUCR |= (_BV(BODS) | _BV(BODSE));
  MCUCR &= ~_BV(BODSE);
  MCUCR |= (_BV(BODS));
 
  // Disable the ADC
  ADCSRA &= ~_BV(ADEN);

  // Disable the Analog Comparator
  ACSR |= _BV(ACD);

  // Disable clocking of timer1 and ADC
  PRR |= (_BV(PRTIM1)|_BV(PRADC));

  timerInit();
  wdtInit();
  initInterrupts();


  // Power up the Onewire bus
  PORTA |= _BV(PINA2);
  while(numSensors == 0) {
    myPutStr("Scanning for sensors\r\n");
    numSensors = search_sensors();
    myPutStr("Found ");
    myPutUint8(numSensors);
    myPutStr(" sensors\r\n");

    for (i=0;i<numSensors;i++) {
      uint8_t j;
      myPutStr("Sensor ");
      myPutUint8(i);
      myPutStr(" address ");
      for (j=0;j<OW_ROMCODE_SIZE;j++) {
	myPutUint8(gSensorIDs[i][j]);
      }
      if (gSensorIDs[i][0] == DS18S20_FAMILY_CODE ) {
	myPutStr(" DS18S20/DS1820");
      } else if ( gSensorIDs[i][0] == DS1822_FAMILY_CODE ) {
	myPutStr(" DS1822");
      } else {
	myPutStr(" DS18B20");
      }
      if ( DS18X20_get_power_status( &gSensorIDs[i][0] ) == DS18X20_POWER_PARASITE ) {
	myPutStr(" parasite\r\n");
      } else {
	myPutStr(" external\r\n");
      }

      // Enable 12 bit mode (won't do anything on DS18S20)
      DS18X20_write_scratchpad(&gSensorIDs[i][0], 0, 0, DS18B20_12_BIT);
      DS18X20_scratchpad_to_eeprom(DS18X20_get_power_status( &gSensorIDs[i][0] ),&gSensorIDs[i][0]);
	
    }
      

  }
  while(1) {
    unsigned long wakepoint;
    myRadioBuf_t radiobuf;
    //char debugbuf[10];

    // if ((signed long)now - (signed long)nextflash >= 0) {
    //   debugLedToggle(0);
    //   nextflash = now + 1000;
    // }

    // Power up the Onewire bus
    PORTA |= _BV(PINA2);
    // Let is stabilize for a few ms
    wakepoint = getMillis() + 15;
    numSensors = search_sensors();
    while (! ((signed long)getMillis() - (signed long)wakepoint >= 0)) {
      set_sleep_mode(SLEEP_MODE_IDLE);
      sleep_mode();
    }
    if ( DS18X20_start_meas( DS18X20_POWER_PARASITE, NULL ) == DS18X20_OK) {
      wakepoint = getMillis() + DS18B20_TCONV_12BIT;
      while (! ((signed long)getMillis() - (signed long)wakepoint >= 0)) {
	set_sleep_mode(SLEEP_MODE_IDLE);
	sleep_mode();
      }
      // Power the radio up
      PORTA |= _BV(PINA1);
      // Wakepoint set to now +100ms to allow radio to wake
      wakepoint = getMillis() + 100;

      for ( i = 0; i < numSensors; i++ ) {
        radiobuf.tenthousandths = -9999999L;
	if (DS18X20_read_maxres( &gSensorIDs[i][0], &(radiobuf.tenthousandths) ) != DS18X20_OK) {
	  radiobuf.tenthousandths = -9999999L;
	}

	//myPutStr("Sensor ");
	uint8_t j;
	for (j=0;j<OW_ROMCODE_SIZE;j++) {
            radiobuf.sensid[j] = gSensorIDs[i][j];
	    //myPutUint8(gSensorIDs[i][j]);
        }
	//myPutStr(" = ");
	//sprintf(debugbuf, "%d.%d\r\n", (int)(radiobuf.tenthousandths/10000), (int)(radiobuf.tenthousandths % 10000));
	//myPutStr(debugbuf);
        if (0 == i) {
	  // First time around, radio not initialized
	  while (! ((signed long)getMillis() - (signed long)wakepoint >= 0)) {
            set_sleep_mode(SLEEP_MODE_IDLE);
            sleep_mode();
          }
	  radioInit();
	  // No auto ack
	  radioSetAutoAck(0);
	  radioOpenWritingPipe(pipe);
        }
	radiobuf.tstamp = getMillis();
	//myPutStr("about to radioWrite, i=");
	//myPutUint8(i);
	//myPutStr("...");
	radioWrite(&radiobuf,sizeof(radiobuf));
	//myPutStr("Done\r\n");
      }
      // Power the radio down
      PORTA &= ~_BV(PINA1);
      // Plus the CE and CSN pins
      PORTA &= ~_BV(PINA7);
      PORTB &= ~_BV(PINB2);
      // And the onewire bus
      PORTA &= ~_BV(PINA2);
    } else {
      myPutStr("Error measuring sensors\n");
    }
    //tmp = getMillis();
    //radioWrite(&tmp , sizeof(unsigned long) );
    // Sleep hard until WDT fires
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    sleep_mode();
  }
}
Ejemplo n.º 11
0
int main(void) {

    //wakeTime = 0;
    //dcCounter = 0;

    // Processor Initialization
    SetupClock();
    SwitchClocks();
    SetupPorts();
    sclockSetup();

    LED_1 = 0;
    LED_2 = 0;
    LED_3 = 0;

    cmdSetup();
    
    radioInit(RADIO_TXPQ_MAX_SIZE, RADIO_RXPQ_MAX_SIZE);
    radioSetChannel(RADIO_CHANNEL);
    radioSetSrcPanID(RADIO_PAN_ID);
    radioSetSrcAddr(RADIO_SRC_ADDR);

    dfmemSetup();
    uint64_t id = dfmemGetUnqiueID();
    telemSetup(); //Timer 5, HW priority 4

    mpuSetup();
    imuSetup();   //Timer 4, HW priority 3
    
    tiHSetup();
    adcSetup();

    //AMS Encoders
    //encSetup();

    //"Open Loop" vibration & jitter generator, AP 2014
    //olVibeSetup();

    legCtrlSetup();  //Timer 1, HW priority 5
    steeringSetup(); //Timer 5, HW priority 4

    //Tail control is a special case
    //tailCtrlSetup();

    //Camera is untested with current code base, AP 12/6/2012
    //ovcamSetup();

    LED_RED = 1; //Red is use an "alive" indicator
    LED_GREEN = 0;
    LED_YELLOW = 0;

    //Radio startup verification
    //if (phyGetState() == 0x16) {
    //    LED_GREEN = 1;
    //}

    //Sleeping and low power options
    //_VREGS = 1;
    //gyroSleep();

    /////FUNCTION TEST, NOT FOR PRODUCTION
    //olVibeStart();
    ////////////////////

    while (1) {
        cmdHandleRadioRxBuffer();
        radioProcess();
    }
}
Ejemplo n.º 12
0
//----------------------------------------------------------
//      System initialization
//----------------------------------------------------------
static inline void initSystem(void)
{
    bool success;
    (void)success;

    // disable interrupts: disabled on msp430 by default, but other systems might need this
    DISABLE_INTS();

    // stop the watchdog: GCC disables it by default, but other compilers might not be so helpful
    watchdogStop();

    // TODO: init dynamic memory
    // platformMemInit();

    // basic, platform-specific initialization: timers, platform-specific drivers (?)
    initPlatform();

    // start energy accounting (as soon as timers are initialized)
    energyConsumerOn(ENERGY_CONSUMER_MCU);

#ifdef USE_PRINT
    // init printing to serial (makes sense only after clock has been calibrated)
    if (printInit != NULL) printInit();
#endif

    INIT_PRINTF("starting MansOS...\n");

#ifdef USE_LEDS
    INIT_PRINTF("init LED(s)...\n");
    ledsInit();
#endif
#ifdef USE_BEEPER
    beeperInit();
#endif
#ifdef RAMTEXT_START
    if ((MemoryAddress_t)&_end > RAMTEXT_START) {
        // Panic right aways on RAM overflow.
        // In case this happens, you might want to increase the address
        // specified by CONST_RAMTEXT_START in config file
        assertionFailed("Overflow between .data and .ramtext sections", __FILE__, __LINE__);
    }
#endif
#ifdef USE_ADC
    if (adcInit != NULL) {
        INIT_PRINTF("init ADC...\n");
        adcInit();
    }
#endif
#ifdef USE_RANDOM
    INIT_PRINTF("init RNG...\n");
    randomInit();
#endif
#if USE_ALARMS
    INIT_PRINTF("init alarms...\n");
    initAlarms();
#endif
#ifdef USE_RADIO
    INIT_PRINTF("init radio...\n");
    radioInit();
#endif
#ifdef USE_ADDRESSING
    INIT_PRINTF("init communication stack...\n");
    networkingInit();
#endif
#ifdef USE_EXT_FLASH
    INIT_PRINTF("init external flash...\n");
    extFlashInit();
#endif
#ifdef USE_SDCARD
    INIT_PRINTF("init SD card...\n");
    sdcardInit();
#endif
#ifdef USE_EEPROM
    INIT_PRINTF("init EEPROM...\n");
    eepromInit();
#endif
#ifdef USE_ISL29003
    INIT_PRINTF("init ISL light sensor...\n");
    success = islInit();
    if (!success) {
        INIT_PRINTF("ISL init failed!\n");
    }
#endif
#ifdef USE_ADS1115
    INIT_PRINTF("init ADS111x ADC converter chip...\n");
    adsInit();
#endif
#if USE_ADS8638
    INIT_PRINTF("init ADS8638 ADC converter chip...\n");
    ads8638Init();
#endif
#if USE_ADS8328
    INIT_PRINTF("init ADS8328 ADC converter chip...\n");
    ads8328Init();
#endif
#if USE_AD5258
    INIT_PRINTF("init AD5258 digital potentiometer...\n");
    ad5258Init();
#endif
#if USE_DAC7718
    INIT_PRINTF("init DAC7718 DAC converter chip...\n");
    dac7718Init();
#endif
#if USE_ISL1219
    INIT_PRINTF("init ISL1219 real-time clock chip...\n");
    isl1219Init();
#endif
#ifdef USE_HUMIDITY
    INIT_PRINTF("init humidity sensor...\n");
    humidityInit();
#endif
#ifdef USE_ACCEL
    INIT_PRINTF("init accelerometer...\n");
    accelInit();
#endif
#ifdef USE_TIMESYNC
    INIT_PRINTF("init base station time sync...\n");
    timesyncInit();
#endif
#ifdef USE_SMP
    INIT_PRINTF("init SSMP...\n");
    smpInit();
#endif
#ifdef USE_REPROGRAMMING
    INIT_PRINTF("init reprogramming...\n");
    bootParamsInit();
#endif
#ifdef USE_DCO_RECALIBRATION
    extern void dcoRecalibrationInit(void);
    INIT_PRINTF("init DCO recalibration...\n");
    dcoRecalibrationInit();
#endif
#ifdef USE_FS
    INIT_PRINTF("init file system...\n");
    fsInit();
#endif
#ifdef USE_FATFS
    INIT_PRINTF("init FAT file system...\n");
    fatFsInit();
    INIT_PRINTF("init POSIX-like file routines...\n");
    posixStdioInit();
#endif
#ifdef USE_WMP
    INIT_PRINTF("init WMP...\n");
    wmpInit();
#endif
#ifdef USE_SEAL_NET
    INIT_PRINTF("init SEAL networking...\n");
    sealNetInit();
#endif

    INIT_PRINTF("starting the application...\n");
}