Changeset - 4fc06a89c712
[Not reviewed]
default
0 2 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2012-11-19 22:12:01
kripperger@CL-SEC241-09.cedarville.edu
Gieger Optimization and formatting
2 files changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
slave/slave/modules.c
Show inline comments
 
@@ -62,48 +62,53 @@
 
		 case 3:
 
			modules_cameras();
 
			break;
 
		  
 
		 default:
 
			modules_generic();
 
			break;
 
	 }
 
	  
 
 }
 
 
 
 
 
 void modules_generic_setup()
 
 {
 
	  
 
 }
 
  
 
 void modules_sensors_setup()
 
 {
 
	  
 
 }
 
  
 
 void modules_geiger_setup()
 
 {
 
	// Pin setup
 
	DDRA &= ~(1 << DDRA0);	// PA0 is an input
 
	
 
	
 
	 
 
	// Setup for interrupt input on PA0 (PCINT0)
 
	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(250);			// Let external 32KHz crystal stabilize
 
	TCCR2B = 0x05;			// Set the prescaler to 128: 32.768kHz / 128 = 1Hz overflow
 
	TIFR2 = 0x01;			// Reset timer2 overflow interrupt flag
 
	TIMSK2 = 0x01;			// Enable interrupt on overflow
 
	
 
	sei();					// Enable all interrupts
 
 
 
 
 
 }
 
  
 
 void modules_cameras_setup()
 
 {
 
	  	  
 
 }
 
  
slave/slave/slave.c
Show inline comments
 
@@ -11,64 +11,65 @@
 
 */
 
 
 
#include "config.h"
 
 
#include <inttypes.h>
 
#include <avr/io.h>
 
#include <compat/twi.h>
 
#include <util/delay.h>
 
#include <avr/interrupt.h>
 
#include "modules.h"
 
//#include "lib/serial.h"		//Not made yet
 
#include "lib/led.h"
 
#include "lib/inputOutput.h"
 
#include "lib/i2c.h"
 
#include "lib/spi.h"
 
#include "lib/geiger.h"
 
#include "lib/sensors.h"
 
#include "lib/cameras.h"
 
 
 
void micro_setup()
 
{
 
	// Generic microcontroller config options
 
	DDRA = 0xFE;		//PORTA is output //DEBUG
 
	
 
	//DDRA = 0xFE;		//PORTA is output //DEBUG
 
 
 
}
 
 
 
int main(void)
 
{
 
	// Initialize
 
	micro_setup();			// Generic microcontroller config options
 
	led_configure();		//
 
	i2c_init();				// Setup I2C
 
	//serial_setup();		// Config serial ports
 
	
 
	uint8_t moduleID = io_getModuleId(); // Slave Module ID from rotary dip switch
 
	moduleID=2;	//DEBUG///////////////////////////////////////////////////////////////////////////////////////////
 
	//moduleID=2;	//DEBUG///////////////////////////////////////////////////////////////////////////////////////////
 
	modules_setup(moduleID);
 
 
	
 
 
	
 
	
 
	uint8_t temp;	//DEBUG///////////////////////////////////////////////////////////////////////////////////////
 
	
 
	
 
	//PORTA &= ~(1 << PA1);	//DEBUG///////////////////////////////////////////////////////////////////////////////
 
	//PORTA |= (1 << PA1);	//DEBUG///////////////////////////////////////////////////////////////////////////////
 
	//PORTA=0;//DEBUG/////////////////////////////////////////////////////////////////////////////////////////////
 
	temp=0;//DEBUG////////////////////////////////////////////////////////////////////////////////////////////////
 
	
 
    while(1)
 
    {
 
		
 
		modules_run(moduleID);
 
 
 
 
 
 
0 comments (0 inline, 0 general)