void ProcessTimer() {
    static uint32_t timer = millis();

    if((millis() - timer) >= TIMER_INTERVAL) {

        Watchdog();
        CheckInternetConnection();

        timer = millis();
    }
}
Exemple #2
0
void myRobot::OperatorControl()
{
	GetWatchdog().SetEnabled(true);
	while(IsOperatorControl() && IsEnabled())
	{
		Watchdog().Feed();
		
		float
			//Axis Values, zeroed out /w speed accel.
		x = pad.getAxis(pad.LeftX),
		y = pad.getAxis(pad.LeftY),
		z = pad.getAxis(pad.Triggers),
			fl, fr, bl, br;

		// Still needs to be tested	
		fl = (y + x + z);
		fr = (-y + x - z);
		bl = (y - x + z);
		br = (-y - x - z);
			
		Drive(fl, fr, bl, br);
		Dashboard();
	}
}
Exemple #3
0
static float longitude = 0.0; 
static float altitude = 0.0; 
static unsigned long precision = 0; 
static char date[32];
static unsigned long encoded_chars = 0;
static unsigned short good_sentences = 0;
static unsigned short failed_checksums = 0;
static FILE *logging_file = NULL;
#define LOG_RATE 10.0

//INTERNAL GLOBAL VARS
#define WATCH_DOG_RATE 22.0 //Pet the watchdog every WATCH_DOG_RATE seconds
#define PID_RATE 22.0 //Ideally the PID is activated every PID_RATE seconds for proper heating. 
#define DESIRED_INTERNAL_TEMP 1.0 //Must keep weather balloon above freezing temperature
#define CURR_TEMP 23.0
Watchdog W = Watchdog(); //Watch dog must be petted at least every 26 seconds

//IRIDIUM GLOBAL VARS 
RingBuffer<char> messageBuffer(300); //To store Iridium Messages
#define IRIDIUM_SEND_RATE 60.0 //How often you want to send iridium messages

//LOGGING PINS 
MS5803 p_sensor(D14, D15,ms5803_addrCL); //External pressure and temperature sensor
TMP102 temperature(D14, D15, 0x90); //The internal temperature sensor
Serial gps_ser(D8,D2); //serial to gps, 9600 baud. D8 <-> TX , D2 <-> RX
SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd"); // sd card
TinyGPS gps;
AnalogIn ain(A0); //Reads the power

//INTERNAL PINS
PID controller(1.0, 0.0, 0.0, PID_RATE); //PID Controller for internal heating
Exemple #4
0
/*******************************************************************************
* Function Name  : PollCAN
* Description    : periodièno procesiranje CAN protokola v glavni zanki
* Input          : 
* Output         : 
* Return         : FLASH_COMPLETE na bootloader strani, FLASH_STATUS na strani 
* klienta (glej stm32f10x_flash.h)
*******************************************************************************/
int					PollCAN(CanRxMsg *p) {

static int	addr,n=0;									// statièni register za zaèetno. adreso, index IAP stringa
int					i;												// ....
CanRxMsg		Rx;

						if(!p) {
							if(!CAN_MessagePending(CAN1, CAN_FIFO0))
								return(EOF);
							p=&Rx;
							CAN_Receive(CAN1,CAN_FIFO0, p);
						}
						switch(p->StdId) {
//----------------------------------------------------------------------------------------------
// client - deep sleep (watchdog), no ack.
							case _ID_IAP_GO:
								NVIC_SystemReset();
								break;
//----------------------------------------------------------------------------------------------
// client - sign FW
							case _ID_IAP_SIGN:
								SendAck(crcSIGN());
							break;
//----------------------------------------------------------------------------------------------
// client - setup adrese, no ack	
							case _ID_IAP_ADDRESS:						
								addr=*(int *)p->Data;
							break;
//----------------------------------------------------------------------------------------------
// client - programiranje 2x4 bytov, ack
							case _ID_IAP_DWORD:	
								for(i=p->DLC; i<8; ++i) 
									p->Data[i]=((char *)addr)[i];
								i=FlashProgram32(addr,*(int *)(&p->Data[0]));
								addr+=4;
								++_Words32Received;
								if(p->DLC>4) {
									i |= FlashProgram32(addr,*(int *)(&p->Data[4]));
								}
								addr+=4;
								++_Words32Received;
								SendAck(i);
								break;
//----------------------------------------------------------------------------------------------
// client - brisanje, ack	
							case _ID_IAP_ERASE:	
								_Words32Received=0;
								Watchdog();	
								SendAck(EraseFLASH(*(int *)p->Data));
								break;	
//----------------------------------------------------------------------------------------------
// client - brisanje, ack	
							case _ID_IAP_STRING:
								for(i=0; i<p->DLC && n<_IAP_STRING_LEN; ++i, ++n)
									_Iap_string[n]=p->Data[i];
								if(_Iap_string[n-1]=='\0' || _Iap_string[n-1]=='\r' || _Iap_string[n-1]=='\n' || n==_IAP_STRING_LEN) {
									n=0;
									CanHexProg(NULL);
								}
							break;	
//----------------------------------------------------------------------------------------------
// client - brisanje, ack	
							case _ID_IAP_PING:
								SendAck(0);
							break;	
//----------------------------------------------------------------------------------------------
// server - acknowledge received
							case _ID_IAP_ACK:						
								return(p->Data[0]);
//----------------------------------------------------------------------------------------------
							default:
							break;
						}
						return(EOF);
}