示例#1
0
int main(void)
{
	initRP6M256();  
	initLCD();
    
	writeString_P_WIFI("\n\nRP6 CONTROL M32 I2C Master Example Program!\n"); 
    writeString_P_WIFI("\nMoving...\n"); 

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 
	
	// ---------------------------------------
	// Init TWI Interface:
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);

	showScreenLCD("################", "################");
	mSleep(1000);
	showScreenLCD("I2C-Master", "Movement...");
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_MED);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	while(true) 
	{ 
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b1000); 
		showScreenLCD("ROTATE", "LEFT");
		writeString_P_WIFI("\nRotating Left...\n"); 
		rotate(60, LEFT, 180, BLOCKING);
		setLEDs(0b1001); 
		showScreenLCD("MOVE", "FWD");
		writeString_P_WIFI("\nMoving Forwards...\n"); 
		move(70, FWD, DIST_MM(300), BLOCKING);
		setLEDs(0b0001); 
		showScreenLCD("ROTATE", "RIGHT");
		writeString_P_WIFI("\nRotating Right...\n"); 
		rotate(60, RIGHT, 180, BLOCKING);
	}
	return 0;
}
示例#2
0
int main(void)
{
	initRP6M256(); 
	initLCD();

	// ---------------------------------------
	WDT_setRequestHandler(watchDogRequest); 

	// ---------------------------------------
	I2CTWI_initMaster(100);  
	I2CTWI_setRequestedDataReadyHandler(I2C_requestedDataReady);
	I2CTWI_setTransmissionErrorHandler(I2C_transmissionError);


	setLEDs(0b1111);
	mSleep(1000);
	setLEDs(0b0000);
	
	// ---------------------------------------
	// Setup ACS power:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_ACS_POWER, ACS_PWR_OFF);
	// Enable Watchdog for Interrupt requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT, true);
	// Enable timed watchdog requests:
	I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, CMD_SET_WDT_RQ, true);

	startStopwatch1();
	startStopwatch2();
	startStopwatch3();
	
	while(true) 
	{ 
		/*
		mSleep(600);
		warnForObs();
		mSleep(600);
		task_checkINT();
		mSleep(600);
		light_detection();
		mSleep(600);
	    task_I2CTWI();
		mSleep(600);*/
		writeIntegerLength_WIFI(adcBat,DEC,4);
		behaviourController();
	}
	return 0;
}