Changeset - 460153f9c03f
[Not reviewed]
default
0 2 0
mkroening@CL-ENS241-07.cedarville.edu - 12 years ago 2013-02-25 17:01:44
mkroening@CL-ENS241-07.cedarville.edu
EEPROM attempt 1
2 files changed with 9 insertions and 5 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/inputOutput.c
Show inline comments
 
@@ -38,16 +38,12 @@ int8_t	moduleID;	// Slave Module ID from
 
	ADCSRA |= (1 << ADEN);									// Enable ADC
 
	ADCSRA |= (1 << ADSC);									// Start ADC measurements.  ADC should now continuously run conversions, which are stored in ADCH 0x79
 
	
 
 }
 
 
 
 
 
 
   
 
 
 
 
 
 void io_readModuleId()
 
 {
 
	// Get ID from rotary dip and return it. 
 
	moduleID = 0;
 
	
 
	// This method is temporary as the next release will read the module ID from EEPROM
 
@@ -61,15 +57,16 @@ int8_t	moduleID;	// Slave Module ID from
 
	moduleID = (moduleID & 0b0111);				//Mask bits
 
 
 
/*
 
	while(moduleID==0)
 
	{
 
		moduleID = i2c_read(EEPROM_ADDR, 0x04);
 
		moduleID = i2c_read(EEPROM_ADDR, 0x05);
 
	}
 
*/
 
 //moduleID = i2c_read(EEPROM_ADDR, 0x05);
 
 
 
 }
 
 
 
 
 
 uint8_t io_getModuleId()
slave/slave/slave.c
Show inline comments
 
@@ -42,12 +42,16 @@ void micro_setup()
 
	
 
}
 

	
 

	
 
int main(void)
 
{
 
	// Writes ID to EEPROM, change for all modules and delete after programming
 
	// 0 is for generic setup, 1 is for sensors, 2 is for Geiger, 3 is for cameras
 

	
 
		
 
	// Initialize		
 
	micro_setup();			// Generic microcontroller config options
 
	time_setup();			// Setup loop timer and interrupts (TIMER0)
 
	led_configure();		// Configure ports and registers for LED operation
 
	io_configure();			// Configure IO ports and registers
 
	i2c_init();				// Setup I2C
 
@@ -74,20 +78,23 @@ int main(void)
 
			led_on(0);
 
			
 
			sensors_readBatt();				// Read Battery level
 
			sensors_readBoardTemp();		// Read board temperature sensor (Common on all slaves) (Data Read)
 
			modules_run(io_getModuleId());	// Runs specific module functions (like data reading)
 
			
 
			i2c_write(EEPROM_ADDR, 0x05, 0x01);
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 

	
 
			//snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Lux: %lu |Pressure: %lu |Altitude: %lu |Battery: %u \r\n ",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLux(),sensors_getPressure(),sensors_getAltitude(),sensors_getBatt()); //DEBUG
 
			//serial0_sendString(buff); //DEBUG
 

	
 
			_delay_ms(1);		// Delay to prevent the sensor loop from running again before time_millis changes
 
			led_off(0);
 
			led_off(2);
 
			led_output(i2c_read(EEPROM_ADDR, 0x05));
 
		}
 

	
 
    }
 
	
 
	return 0;
 
}
0 comments (0 inline, 0 general)