// Lancaster University, http://www.comp.lancs.ac.uk/
// 15.07.2002 by Albrecht Schmidt
// http://www.comp.lancs.ac.uk/~albrecht/

// developed for the vision smart-it / weight boards 
// compiled with CCS PCM C Compiler, Version 3.080

#include "core.c"

#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7)

main() {
   int ret; // return value for rfReceiveOnCD
   
   // iitialize core, show boot sign
   init_core();

   // loop forever
   while(1) {
   	// restart the watchdog timer - at least every 2 seconds
	restart_wdt();

	// switch of interrupts while checking for RF data
	disable_interrupts(global);
	disable_interrupts(int_rda);

	// check 900ms whether or not RF data is available
	// if data is available and correct then ret = 0
	ret = rfReceiveOnCD(rf_buffer, MAXBUF, 900);
	if (ret==0) {
		// print the received data
		printf("%s", rf_buffer);
	}
	
	// switch on interrupts for a short time ...
	enable_interrupts(global);
	enable_interrupts(int_rda);
	delay_us(10);	
   } 
}

