Changeset - f510f51941a0
[Not reviewed]
default
0 5 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-02-14 14:45:54
kripperger@CL-SEC241-09.cedarville.edu
Got i2c sensors working!
5 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
slave/slave/config.h
Show inline comments
 
@@ -34,9 +34,9 @@
 
 //I2C Addresses
 
 #define EEPROM_ADDR 0xA0		// Read 0xA1 - Write 0xA0
 
 #define BOARDTEMP_ADDR 0x90	// Read 0x91 - Write 0x90
 
 #define PRESSURE_ADDR 0xEF		// Read 0xEF - Write 0xEE
 
 #define HUMID_ADDR 0x27		// Read 0x27 - Write 0x26
 
 #define LIGHT_ADDR 0x95		// Read 0x95 - Write 0x94
 
 #define PRESSURE_ADDR 0xEE		// Read 0xEF - Write 0xEE
 
 #define HUMID_ADDR 0x26		// Read 0x27 - Write 0x26
 
 #define LIGHT_ADDR 0x94		// Read 0x95 - Write 0x94
 
 #define RTC_ADDR 0xB2			//DEBUG [Used for testing]      // Read 0xA3 - Write 0xA2
 
 
slave/slave/lib/masterComm.c
Show inline comments
 
@@ -111,16 +111,16 @@ void masterComm_modules()
 
			masterComm_packetSend_unsigned(3,sensors_getSpiTemp());
 
			
 
			// Send Ambient Light (Needs to be formatted)
 
			masterComm_packetSend_unsigned(4,/*Ambient Light Get Function Here */123);
 
			masterComm_packetSend_unsigned(4,/*Ambient Light Get Function Here */44);
 
			
 
			// Send Humidity
 
			masterComm_packetSend_unsigned(5,/*Humidity Get Function Here */456);		
 
			masterComm_packetSend_unsigned(5,/*Humidity Get Function Here */55);		
 
			
 
			// Send Pressure 
 
			masterComm_packetSend_unsigned(6,/*Pressure Get Function Here */7890);			
 
			masterComm_packetSend_unsigned(6,/*Pressure Get Function Here */66);			
 
			
 
			// Send Altitude
 
			masterComm_packetSend_unsigned(7,/*Altitude Get Function Here */456789);
 
			masterComm_packetSend_unsigned(7,/*Altitude Get Function Here */77);
 
			break;
 
			
 
		case 2:
slave/slave/lib/sensors.c
Show inline comments
 
@@ -132,13 +132,13 @@ void sensors_readBoardTemp()
 
 
void sensors_readPressure()
 
{
 
	i2c_write(0xEE, 0xF4, 0x2E);				//write 0x2E (temp) into 0xF4 (control register), (write is 0xEE)
 
	i2c_write(PRESSURE_ADDR, 0xF4, 0x2E);				//write 0x2E (temp) into 0xF4 (control register), (write is 0xEE)
 
	_delay_us(4500);							//wait 4.5 ms
 
	ut = i2c_read(PRESSURE_ADDR, 0xF6);
 
	ut = ut << 8;
 
	ut = ut | i2c_read(PRESSURE_ADDR, 0xF7);	//ut = MSB<<8 + LSB
 
	
 
	i2c_write(0xEE, 0xF4, 0x34);				//write 0x34 (pressure) into 0xF4 (control register), (write is 0xEE)
 
	i2c_write(PRESSURE_ADDR, 0xF4, 0x34);				//write 0x34 (pressure) into 0xF4 (control register), (write is 0xEE)
 
	_delay_us(4500);							//wait 4.5 ms
 
	up = i2c_read(PRESSURE_ADDR, 0xF6);
 
	up = up << 8;
slave/slave/modules.c
Show inline comments
 
@@ -123,9 +123,9 @@
 
	// Gathers data and performs functions for sensor daughter board
 
	sensors_readBoardTemp();		//Data Read
 
	sensors_readSpiTemp();			//Data Read
 
	//sensors_readPressure();			//Data Read
 
	sensors_readPressure();			//Data Read
 
	//sensors_readHumid();				//Data Read
 
	//sensors_readLight();				//Data Read
 
	sensors_readLight();				//Data Read
 
	sensors_readBatt();
 
	 
 
 }
slave/slave/slave.c
Show inline comments
 
@@ -82,8 +82,8 @@ int main(void)
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 

	
 
			//snprintf(buff,64,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |SpiTemp: %i\r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getSpiTemp()); //DEBUG
 
			//serial0_sendString(buff); //DEBUG
 
			snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Light: %u |Pressure: %u \r\n",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLight(),sensors_getPressure()); //DEBUG
 
			serial0_sendString(buff); //DEBUG
 

	
 
			_delay_ms(2);		// Delay to prevent the sensor loop from running again before time_millis changes
 
			led_off(0);
0 comments (0 inline, 0 general)