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(); //} } }
// setup Dash for iOS app void DashBot::dashRadioSetup(void){ //servo1.attach(MISO); // attaches the servo on pin 9 to the servo object //servo2.attach(MOSI); startupBlink(); // green LED high setupSystemFunctions(); //sets up serial radio and USB setupIRsensors(); // baseline for IR sensors gyroSetup(); // baseline for gyro }
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; }
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(); } }