void main(void) { char pinStatus = 0, TXon = 0, boxOpen = 0; long int runTime = 0; // /* device setup */ set32MHzXOSC(); timerSetup(TICKS_FREQ025, T1_PRE); timer4Setup(T4_PRE); // CSPT = 0xFF; // PICTL |= BIT7; P0DIR |= 0x8C; //P0 BIT2,3,7 are output, BIT1,4,5,6 are input if (P0 & BOX) P0 = RED_LED; else P0 = GREEN_LED; /* interrupt setup */ setT1int(); //TIMER1 interrupts setT4int(); //TIMER4 interrupts //void setP0int(); //Port 0 interrupts while(P0 & BOX); //wait for box to close before reading setup parameters T1_ovf_cnt = 0; //restart transmitting period after closing the box pinStatus = readPin(); setupTX(pinStatus); IEN0 |= BIT7; //enable global interrupts. T1CTL |= BIT0; //start timer1 in free running mode if (pinStatus == 0x02) runTime = 322; //total run time is approx. 3 hours else runTime = 18; //total run time is approx. 10 minutes while(T1_ovf_cnt < runTime) //stop program after XXX hours { while(!(P0 & BOX) && T1_ovf_cnt < runTime) //Box is closed { if (!TXon) { if (pinStatus == 0x22) freqSweep(FREQ2395, FREQ2507, 4); else startTX(); TXon = 1; } } stopTX(); TXon = 0; // if (P0 & BOX) boxOpen = 1; // else // { // while(P0 & BOX); //wait for box to close before reading setup parameters // } while (P0 & BOX) boxOpen = 1; if (boxOpen == 1) T1_ovf_cnt = 0; //restart transmitting period after closing the box pinStatus = readPin(); setupTX(pinStatus); if (pinStatus == 0x02) runTime = 645; //total run time is approx. 6 hours else runTime = 18; //total run time is approx. 10 minutes boxOpen = 0; } stopTX(); }
void wdsp_init(int rx,int pixels,int protocol) { int rc; receiver=rx; spectrumWIDTH=pixels; fprintf(stderr,"wdsp_init: %d\n",rx); if(protocol==ORIGINAL_PROTOCOL) { micOutputRate=48000; } else { micOutputRate=192000; } while (gtk_events_pending ()) gtk_main_iteration (); fprintf(stderr,"OpenChannel %d buffer_size=%d fft_size=%d sample_rate=%d dspRate=%d outputRate=%d\n", rx, buffer_size, fft_size, sample_rate, dspRate, outputRate); OpenChannel(rx, buffer_size, fft_size, sample_rate, dspRate, outputRate, 0, // receive 1, // run 0.010, 0.025, 0.0, 0.010, 0); while (gtk_events_pending ()) gtk_main_iteration (); switch(sample_rate) { case 48000: tx_buffer_size=BUFFER_SIZE; break; case 96000: tx_buffer_size=BUFFER_SIZE/2; break; case 192000: tx_buffer_size=BUFFER_SIZE/4; break; case 384000: tx_buffer_size=BUFFER_SIZE/8; break; } fprintf(stderr,"OpenChannel %d buffer_size=%d fft_size=%d sample_rate=%d dspRate=%d outputRate=%d\n", CHANNEL_TX, tx_buffer_size, fft_size, sample_rate, //micSampleRate, micDspRate, micOutputRate); OpenChannel(CHANNEL_TX, buffer_size, fft_size, sample_rate, //micSampleRate, micDspRate, micOutputRate, 1, // transmit 1, // run 0.010, 0.025, 0.0, 0.010, 0); while (gtk_events_pending ()) gtk_main_iteration (); fprintf(stderr,"XCreateAnalyzer %d\n",rx); int success; XCreateAnalyzer(rx, &success, 262144, 1, 1, ""); if (success != 0) { fprintf(stderr, "XCreateAnalyzer %d failed: %d\n" ,rx,success); } initAnalyzer(rx,buffer_size); SetDisplayDetectorMode(rx, 0, display_detector_mode); SetDisplayAverageMode(rx, 0, display_average_mode); calculate_display_average(); //SetDisplayAvBackmult(rx, 0, display_avb); //SetDisplayNumAverage(rx, 0, display_average); while (gtk_events_pending ()) gtk_main_iteration (); XCreateAnalyzer(CHANNEL_TX, &success, 262144, 1, 1, ""); if (success != 0) { fprintf(stderr, "XCreateAnalyzer CHANNEL_TX failed: %d\n" ,success); } initAnalyzer(CHANNEL_TX,tx_buffer_size); setupRX(rx); setupTX(CHANNEL_TX); }