Changeset - 88a84e3b4dd9
[Not reviewed]
default
0 6 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-04-08 17:21:07
kripperger@CL-SEC241-09.cedarville.edu
Fixed Geiger
6 files changed with 18 insertions and 12 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/geiger.c
Show inline comments
 
@@ -30,14 +30,20 @@ ISR(TIMER2_OVF_vect)    // Timer 2 overf
 
		counts = 0;
 
	}
 
}
 
 
ISR(PCINT0_vect)    // Interrupt on PA0
 
{
 
	// Interrupts when pulse received from Geiger tube
 
	counts++;	// Increment counter.
 
	if(((PINA & 0b00000001))==1)
 
	{
 
		// Interrupts when pulse received from Geiger tube
 
		counts++;	// Increment counter.
 
		led_toggle(2);
 
		_delay_ms(5);
 
	}
 
 
}
 
 
uint16_t geiger_getCpm()
 
{
 
	return cpm;
 
}
slave/slave/lib/inputOutput.c
Show inline comments
 
@@ -40,13 +40,13 @@ int8_t	moduleID;	// Slave Module ID from
 
 }
 
 
 
  
 
 void io_readModuleId()
 
 {
 
	// Get ID from rotary dip and return it. 
 
	moduleID = 1;
 
	moduleID = 2;
 
	
 
	/*
 
	// This method is temporary as the next release will read the module ID from EEPROM
 
	PORTC |= (1 << PC2);	// Pull pins on rotary dip high
 
	PORTC |= (1 << PC3);	// Pull pins on rotary dip high
 
	PORTC |= (1 << PC4);	// Pull pins on rotary dip high
slave/slave/lib/masterComm.c
Show inline comments
 
@@ -108,13 +108,13 @@ void masterComm_modules()
 
			break;
 
		
 
		case 1:
 
			// Sensors
 
			
 
			// Send SPI Temperature (Air)
 
			masterComm_packetSend_unsigned(3,sensors_getSpiTemp());
 
			masterComm_packetSend_signed(3,sensors_getSpiTemp());
 
			
 
			// Send Ambient Light (Needs to be formatted)
 
			masterComm_packetSend_unsigned(4,sensors_getLux());
 
			
 
			// Send Humidity
 
			masterComm_packetSend_unsigned(5,/*Humidity Get Function Here */999);		
slave/slave/lib/watchdog.c
Show inline comments
 
@@ -14,13 +14,13 @@ void watchdog_setup(void)
 
{
 
	cli();
 
	wdt_reset();
 
	// Set change enable bit, enable the WDT
 
	WDTCSR = (1<<WDCE)|(1<<WDE);
 
	// Start watchdog, 4 second timeout
 
	WDTCSR = (1<<WDE)|(1<<WDP3)|(1<<WDP0);
 
	WDTCSR = (1<<WDE)|(1<<WDP2)|(1<<WDP1);
 
	sei();
 
}
 
 
// ISR for watchdog timeout. ///////////Not currently used, interrupt is disabled.
 
ISR(WDT_vect)
 
{
slave/slave/modules.c
Show inline comments
 
@@ -15,13 +15,13 @@
 
 #include "lib/i2c.h"
 
 #include "lib/sensors.h"
 
 #include "lib/loopTimer.h"
 
 #include "lib/led.h"
 
 
 
 uint32_t lastPicture;
 
// uint32_t lastRefresh;	// Time in ms when last geiger refresh occurred 
 
 uint32_t lastRefresh;	// Time in ms when last geiger refresh occurred 
 
 
 
 void modules_setup(uint8_t id)
 
 {
 
	switch(id)
 
	{
 
		case 0:
 
@@ -87,20 +87,20 @@
 
	sensors_setupPressure();
 
 }
 
  
 
 void modules_geiger_setup()
 
 {
 
	// Pin setup
 
	//DDRA &= ~(1 << DDA0);	// PA0 is an input
 
	//DDRA |= (1 << DDA1);	// PA1 is an output	///////////
 
	DDRA &= ~(1 << DDA0);	// PA0 is an input
 
	DDRA |= (1 << DDA1);	// PA1 is an output
 
	
 
	//geiger_on();	// Turn on HV supply	//////////////
 
	geiger_on();	// Turn on HV supply
 
	
 
	// Setup for interrupt input on PA0 (PCINT0)
 
	//PCMSK0 |= (1 << PCINT0);	// Enable interrupt for PA0
 
	//PCICR |= (1 << PCIE0);		// Enable ioc section PCIF0
 
	PCMSK0 |= (1 << PCINT0);	// Enable interrupt for PA0
 
	PCICR |= (1 << PCIE0);		// Enable ioc section PCIF0
 
	
 
	// Setup for interrupt from Timer2
 
	ASSR &= ~(1 << EXCLK);	// Disable external clock input (enabling crystal use)
 
	ASSR |= (1 << AS2);		// Enable timer2 async mode with an external crystal	
 
	_delay_ms(100);			// Let external 32KHz crystal stabilize
 
	TCCR2B = 0x05;			// Set the prescaler to 128: 32.768kHz / 128 = 1Hz overflow
slave/slave/slave.c
Show inline comments
 
@@ -41,12 +41,13 @@ bool WDTreset = false;
 
void micro_setup()
 
{
 
	// Generic microcontroller config options
 
	WDTreset = ((MCUSR & 0b00001000) > 0);	// Check if WDT reset occured
 
	MCUSR = 0;		// Clear reset flags
 
	wdt_disable();	// Disable WDT
 
	watchdog_setup();		// Setup watchdog timer
 
	_delay_ms(50);	// Power debounce
 
	sei();			// Enable interrupts
 
}
 

	
 

	
 

	
 
@@ -54,13 +55,12 @@ int main(void)
 
{
 

	
 
		
 
	// Initialize	
 
	micro_setup();			// Generic microcontroller config options
 
	time_setup();			// Setup loop timer and interrupts (TIMER0)
 
	watchdog_setup();		// Setup watchdog timer
 
	led_configure();		// Configure ports and registers for LED operation
 
	io_configure();			// Configure IO ports and registers
 
	i2c_init();				// Setup I2C
 
	serial0_setup();		// Config serial port 0
 
	serial1_setup();		// Config serial port 1
 
	
0 comments (0 inline, 0 general)